Module: EnMail::Helpers::RFC1847
- Includes:
- MessageManipulation
- Included in:
- Adapters::GPGME, Adapters::RNP, RFC3156
- Defined in:
- lib/enmail/helpers/rfc1847.rb
Overview
Common interface for building adapters conforming to RFC 1847 “Security Multiparts for MIME: Multipart/Signed and Multipart/Encrypted”. It provides sign
and encrypt
public methods.
Instance Method Summary collapse
-
#encrypt(message) ⇒ Object
Encrypts a message in a
multipart/encrypted
fashion as defined in RFC 1847. -
#sign(message) ⇒ Object
Signs a message in a
multipart/signed
fashion as defined in RFC 1847.
Instance Method Details
#encrypt(message) ⇒ Object
Encrypts a message in a multipart/encrypted
fashion as defined in RFC 1847.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/enmail/helpers/rfc1847.rb', line 17 def encrypt() source_part = body_to_part() recipients = find_recipients_for() encrypted = encrypt_string(source_part.encoded, recipients).to_s encrypted_part = build_encrypted_part(encrypted) control_part = build_encryption_control_part rewrite_body( , content_type: multipart_encrypted_content_type, parts: [control_part, encrypted_part], ) end |
#sign(message) ⇒ Object
Signs a message in a multipart/signed
fashion as defined in RFC 1847.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/enmail/helpers/rfc1847.rb', line 35 def sign() source_part = body_to_part() restrict_encoding(source_part) signer = find_signer_for() micalg, signature = compute_signature(source_part.encoded, signer) signature_part = build_signature_part(signature) rewrite_body( , content_type: multipart_signed_content_type(micalg: micalg), parts: [source_part, signature_part], ) end |