mail-gpg 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mail/gpg.rb +4 -4
- data/lib/mail/gpg/gpgme_helper.rb +1 -1
- data/lib/mail/gpg/sign_part.rb +14 -13
- data/lib/mail/gpg/version.rb +1 -1
- data/test/gpg_test.rb +9 -2
- data/test/gpghome/random_seed +0 -0
- metadata +2 -2
data/lib/mail/gpg.rb
CHANGED
@@ -15,13 +15,13 @@ require 'mail/gpg/sign_part'
|
|
15
15
|
module Mail
|
16
16
|
module Gpg
|
17
17
|
# options are:
|
18
|
-
# :sign
|
19
|
-
# :sign_as
|
18
|
+
# :sign: sign message using the sender's private key
|
19
|
+
# :sign_as: sign using this key (give the corresponding email address or key fingerprint)
|
20
20
|
# :passphrase: passphrase for the signing key
|
21
|
-
# :keys
|
21
|
+
# :keys: A hash mapping recipient email addresses to public keys or public
|
22
22
|
# key ids. Imports any keys given here that are not already part of the
|
23
23
|
# local keychain before sending the mail.
|
24
|
-
# :always_trust
|
24
|
+
# :always_trust: send encrypted mail to untrusted receivers, true by default
|
25
25
|
def self.encrypt(cleartext_mail, options = {})
|
26
26
|
construct_mail(cleartext_mail, options) do
|
27
27
|
receivers = []
|
@@ -18,7 +18,7 @@ module Mail
|
|
18
18
|
begin
|
19
19
|
if options[:sign]
|
20
20
|
if options[:signers]
|
21
|
-
signers = GPGME::Key.find(:
|
21
|
+
signers = GPGME::Key.find(:secret, options[:signers], :sign)
|
22
22
|
ctx.add_signer(*signers)
|
23
23
|
end
|
24
24
|
ctx.encrypt_sign(recipient_keys, plain_data, cipher_data, flags)
|
data/lib/mail/gpg/sign_part.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
module Mail
|
2
|
-
|
3
|
-
|
2
|
+
module Gpg
|
3
|
+
class SignPart < Mail::Part
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
def initialize(cleartext_mail, options = {})
|
6
|
+
signature = GpgmeHelper.sign(cleartext_mail.encoded, options)
|
7
|
+
super() do
|
8
|
+
body signature.to_s
|
9
|
+
content_type "application/pgp-signature; name=\"signature.asc\""
|
10
|
+
content_disposition 'attachment; filename="signature.asc"'
|
11
|
+
content_description 'OpenPGP digital signature'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
16
17
|
end
|
data/lib/mail/gpg/version.rb
CHANGED
data/test/gpg_test.rb
CHANGED
@@ -52,8 +52,15 @@ class GpgTest < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
context "gpg installation" do
|
54
54
|
should "have keys for jane and joe" do
|
55
|
-
assert joe = GPGME::Key.find(:public, 'joe@foo.bar')
|
56
|
-
|
55
|
+
assert joe = GPGME::Key.find(:public, 'joe@foo.bar')
|
56
|
+
assert_equal 1, joe.size
|
57
|
+
joe = joe.first
|
58
|
+
assert jane = GPGME::Key.find(:public, 'jane@foo.bar')
|
59
|
+
assert_equal 1, jane.size
|
60
|
+
jane = jane.first
|
61
|
+
assert id = jane.fingerprint
|
62
|
+
assert jane = GPGME::Key.find(:public, id).first
|
63
|
+
assert_equal id, jane.fingerprint
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
data/test/gpghome/random_seed
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-gpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|