mailman_pgp.pgp package¶
Subpackages¶
Submodules¶
mailman_pgp.pgp.base module¶
mailman_pgp.pgp.inline module¶
Strict inline PGP message wrapper.
-
class
mailman_pgp.pgp.inline.InlineWrapper(msg, copy=False)[source]¶ Bases:
mailman_pgp.pgp.base.BaseWrapperInline PGP wrapper.
-
attach_revocs(*key_revocations)[source]¶ Attach a key revocation signature to the message.
Parameters: key_revocations (pgpy.PGPSignature) – A key revocation signature to attach. Returns: Return type: InlineWrapper
-
decrypt(key)[source]¶ Decrypt this message with key.
Parameters: key (pgpy.PGPKey) – The key to decrypt with. Returns: Return type: InlineWrapper
-
encrypt(*keys, cipher=<SymmetricKeyAlgorithm.AES256: 9>, **kwargs)[source]¶ Encrypt the message with key/s, using cipher.
Parameters: - keys (pgpy.PGPKey) – The key/s to encrypt with.
- cipher (SymmetricKeyAlgorithm) – The symmetric cipher to use.
Returns: Return type:
-
has_encryption()[source]¶ Whether some parts of the message are inline encrypted.
Returns: If some parts of the message are inline encrypted. Return type: bool
-
has_keys()[source]¶ Whether the message contains public or private keys.
Returns: If the message contains keys. Return type: bool
-
has_signature()[source]¶ Whether some parts of the message are inline signed.
Returns: If some parts of the message are inline signed. Return type: bool
-
is_encrypted()[source]¶ Whether the message is inline encrypted.
Returns: If the message is inline encrypted. Return type: bool
-
is_keys()[source]¶ Whether the message is all keys (all parts).
Returns: If the message is keys. Return type: bool
-
is_signed()[source]¶ Whether the message is inline signed.
Returns: If the message is inline signed. Return type: bool
-
keys()[source]¶ Get the collection of keys in this message.
Returns: A collection of keys. Return type: Generator[pgpy.PGPKey]
-
sign(key, **kwargs)[source]¶ Sign a message with key.
Parameters: key (pgpy.PGPKey) – The key to sign with. Returns: Return type: InlineWrapper
-
sign_encrypt(key, *keys, hash=None, cipher=<SymmetricKeyAlgorithm.AES256: 9>, **kwargs)[source]¶ Sign and encrypt the message, in one go.
Parameters: - key (pgpy.PGPKey) – The key to sign with.
- keys (pgpy.PGPKey) – The key/s to encrypt with.
- hash (pgpy.constants.HashAlgorithm) –
- cipher (pgpy.constants.SymmetricKeyAlgorithm) –
Returns: Return type:
-
mailman_pgp.pgp.keygen module¶
List key generator runs in a separate process to not block for the potentially long key generation operation.
mailman_pgp.pgp.mime module¶
RFC1847 and RFC3156 compliant message wrapped.
-
class
mailman_pgp.pgp.mime.MIMEWrapper(msg, copy=False)[source]¶ Bases:
mailman_pgp.pgp.base.BaseWrapperPGP/MIME (RFC1847 + RFC3156) compliant wrapper.
-
attach_keys(*keys)[source]¶ Attach a key to this message, as per RFC3156 section 7.
Parameters: keys (pgpy.PGPKey) – Keys to attach. Returns: Return type: MIMEWrapper
-
attach_revocs(*key_revocations)[source]¶ Attach a key revocation signature to the message, as a key subpart.
Parameters: key_revocations (pgpy.PGPSignature) – A key revocation signature to attach. Returns: Return type: MIMEWrapper
-
decrypt(key)[source]¶ Decrypt this message with key.
Parameters: key (pgpy.PGPKey) – The key to decrypt with. Returns: The decrypted message. Return type: mailman.email.message.Message
-
encrypt(*keys, cipher=<SymmetricKeyAlgorithm.AES256: 9>, **kwargs)[source]¶ Encrypt the message with key/s, using cipher.
Parameters: - keys (pgpy.PGPKey) – The key/s to encrypt with.
- cipher (pgpy.constants.SymmetricKeyAlgorithm) – The symmetric cipher to use.
Returns: Return type:
-
has_keys()[source]¶ Whether the message contains keys as per RFC3156 section 7.
Returns: If the message contains keys. Return type: bool
-
is_encrypted()[source]¶ Whether the whole message is MIME encrypted as per RFC3156 section 4.
Returns: If the message is MIME encrypted. Return type: bool
-
is_keys()[source]¶ Whether the message has only keys as per RFC3156 section 7.
Returns: If the message is keys. Return type: bool
-
is_signed()[source]¶ Whether the whole message is MIME signed as per RFC3156 section 5.
Returns: If the message is MIME signed. Return type: bool
-
sign(key, **kwargs)[source]¶ Sign a message with key.
Parameters: key (pgpy.PGPKey) – The key to sign with. Return type: MIMEWrapper
-
sign_encrypt(key, *keys, hash=None, cipher=<SymmetricKeyAlgorithm.AES256: 9>, **kwargs)[source]¶ Sign and encrypt the message, in one go.
This is as per RFC 3156 section 6.2 - Combined method.
Parameters: - key (pgpy.PGPKey) – The key to sign with.
- keys (pgpy.PGPKey) – The key/s to encrypt with.
- hash (pgpy.constants.HashAlgorithm) –
- cipher (pgpy.constants.SymmetricKeyAlgorithm) –
Returns: Return type:
-
strip_signature()[source]¶ Returns: Return type: MIMEWrapper
-
mailman_pgp.pgp.mime_multisig module¶
MIMEWrapper with multiple signature as per draft-ietf-openpgp-multsig-02.
-
class
mailman_pgp.pgp.mime_multisig.MIMEMultiSigWrapper(msg, copy=False)[source]¶ Bases:
mailman_pgp.pgp.mime.MIMEWrapperhttps://tools.ietf.org/html/draft-ietf-openpgp-multsig-02
-
decrypt(key)[source]¶ Decrypt this message with key.
Parameters: key (pgpy.PGPKey) – The key to decrypt with. Returns: Return type: MIMEMultiSigWrapper
-
is_signed()[source]¶ Whether the message is signed as per draft-ietf-openpgp-multsig-02.
Returns: If the message is MIME signed. Return type: bool
-
sign(key, **kwargs)[source]¶ Sign a message with key.
Parameters: key (pgpy.PGPKey) – The key to sign with. Returns: Return type: MIMEMultiSigWrapper
-
mailman_pgp.pgp.wrapper module¶
A combined PGP/MIME + inline PGP wrapper.
-
class
mailman_pgp.pgp.wrapper.PGPWrapper(msg, copy=False, default=<class 'mailman_pgp.pgp.mime.MIMEWrapper'>)[source]¶ Bases:
mailman_pgp.pgp.base.BaseWrapperA combined PGP/MIME + inline PGP wrapper.
-
decrypt(key)[source]¶ Decrypt this message with key.
Parameters: key (pgpy.PGPKey) – The key to decrypt with. Raises: pgpy.errors.PGPError Returns: Return type: PGPWrapper
-
encrypt(*keys, **kwargs)[source]¶ Encrypt the message with key/s, using cipher.
Parameters: keys (pgpy.PGPKey) – The key/s to encrypt with. Returns: Return type: PGPWrapper
-
get_signature()[source]¶ Returns: Return type: typing.Generator[pgpy.PGPMessage|pgpy.PGPSignature| pgpy.PGPDetachedSignature]
-
get_signed()[source]¶ Get the signed content of the message.
Returns: The signed contents of the message. Return type: typing.Generator[str]
-
has_encryption()[source]¶ Whether some parts of the message are encrypted.
Returns: If some parts of the message are encrypted. Return type: bool
-
has_keys()[source]¶ Whether the message contains public or private keys.
Returns: If the message contains keys. Return type: bool
-
has_signature()[source]¶ Whether some parts of the message are signed.
Returns: If some parts of the message are signed. Return type: bool
-
is_encrypted()[source]¶ Whether the message is encrypted.
Returns: If the message is encrypted. Return type: bool
-
is_keys()[source]¶ Whether the message is all keys (all parts).
Returns: If the message is keys. Return type: bool
-
is_signed()[source]¶ Whether this message is signed.
Returns: If the message is signed. Return type: bool
-
keys()[source]¶ Get the collection of keys in this message.
Returns: A collection of keys. Return type: typing.Generator[pgpy.PGPKey]
-
sign(key, **kwargs)[source]¶ Sign a message with key.
Parameters: key (pgpy.PGPKey) – The key to sign with. Returns: Return type: PGPWrapper
-
sign_encrypt(key, *keys, **kwargs)[source]¶ Sign and encrypt the message, in one go.
Parameters: - key (pgpy.PGPKey) – The key to sign with.
- keys (pgpy.PGPKey) – The key/s to encrypt with.
- hash (pgpy.constants.HashAlgorithm) –
- cipher (pgpy.constants.SymmetricKeyAlgorithm) –
Returns: Return type:
-
strip_signature()[source]¶ Returns: Return type: PGPWrapper
-
try_decrypt(key)[source]¶ Try decrypting the message with given key.
Parameters: key (pgpy.PGPKey) – The key to decrypt with. Returns: The decrypted message, if successfully decrypted, else original message. Return type: PGPWrapper
-