jruby-pgp 0.3.0 → 0.4.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de4c087ff39c48c74f55fadcc25cc1e83b12ad9e
4
+ data.tar.gz: be35ef02a31e8863787e32ee5d94fde15987367d
5
+ SHA512:
6
+ metadata.gz: 4b4d0535aa20052ec21b8197581028f83188487544d06c6a08bcc545a68e06584131706eb67e4be4a218812a38daf0bd7a17a0bdee97d32e4a529e7519378f4b
7
+ data.tar.gz: 3d6005d40df0a4ae37e51a346a1bc5fbf1ca727f7b3a4d7bb0e451de5ef68281c07d9949b8f25ded4e8ee89538f436eb5fbf70dc41cc16304b2705e1780b642d
@@ -43,6 +43,18 @@ import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
43
43
  import org.bouncycastle.openpgp.PGPSecretKey;
44
44
  import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
45
45
  import org.bouncycastle.openpgp.PGPUtil;
46
+ import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
47
+ import org.bouncycastle.openpgp.jcajce.JcaPGPSecretKeyRingCollection;
48
+ import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
49
+ import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
50
+ import org.bouncycastle.openpgp.operator.PGPContentVerifierBuilderProvider;
51
+ import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
52
+ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
53
+ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
54
+ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
55
+ import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
56
+ import org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory;
57
+ import org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory;
46
58
 
47
59
  public class Decryptor {
48
60
 
@@ -77,7 +89,15 @@ public class Decryptor {
77
89
  if (pgpSecKey == null)
78
90
  return null;
79
91
 
80
- return pgpSecKey.extractPrivateKey((passphrase == null ? null : passphrase.toCharArray()), "BC");
92
+ PGPDigestCalculatorProvider calcProvider = new JcaPGPDigestCalculatorProviderBuilder().
93
+ setProvider(BouncyCastleProvider.PROVIDER_NAME).
94
+ build();
95
+
96
+ PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(calcProvider).
97
+ setProvider(BouncyCastleProvider.PROVIDER_NAME).
98
+ build((passphrase == null ? null : passphrase.toCharArray()));
99
+
100
+ return pgpSecKey.extractPrivateKey(decryptor);
81
101
  }
82
102
 
83
103
  /** End Accessor Methods **/
@@ -97,7 +117,7 @@ public class Decryptor {
97
117
 
98
118
  InputStream decoderStream = PGPUtil.getDecoderStream(encryptedStream);
99
119
 
100
- PGPObjectFactory pgpF = new PGPObjectFactory(decoderStream);
120
+ PGPObjectFactory pgpF = new JcaPGPObjectFactory(decoderStream);
101
121
  PGPEncryptedDataList encryptedData = null;
102
122
  Object encryptedObj = pgpF.nextObject();
103
123
  Iterator encryptedDataIterator;
@@ -127,13 +147,14 @@ public class Decryptor {
127
147
  if (privateKey == null)
128
148
  throw new IllegalArgumentException("secret key for message not found.");
129
149
 
130
- decryptedDataStream = publicKeyData.getDataStream(privateKey, "BC");
150
+ PublicKeyDataDecryptorFactory decryptorFactory = new BcPublicKeyDataDecryptorFactory(privateKey);
151
+ decryptedDataStream = publicKeyData.getDataStream(decryptorFactory);
131
152
 
132
- pgpFactory = new PGPObjectFactory(decryptedDataStream);
153
+ pgpFactory = new JcaPGPObjectFactory(decryptedDataStream);
133
154
 
134
155
  compressedData = (PGPCompressedData) pgpFactory.nextObject();
135
156
 
136
- pgpFactory = new PGPObjectFactory(compressedData.getDataStream());
157
+ pgpFactory = new JcaPGPObjectFactory(compressedData.getDataStream());
137
158
 
138
159
  literallyTheRealFuckingData = (PGPLiteralData) pgpFactory.nextObject();
139
160
 
@@ -15,11 +15,24 @@ import org.bouncycastle.openpgp.PGPLiteralData;
15
15
  import org.bouncycastle.openpgp.PGPPrivateKey;
16
16
  import org.bouncycastle.openpgp.PGPPublicKey;
17
17
  import org.bouncycastle.openpgp.PGPPublicKeyRing;
18
- import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
18
+ import org.bouncycastle.openpgp.bc.BcPGPPublicKeyRingCollection;
19
19
  import org.bouncycastle.openpgp.PGPSecretKey;
20
20
  import org.bouncycastle.openpgp.PGPSecretKeyRing;
21
21
  import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
22
22
  import org.bouncycastle.openpgp.PGPUtil;
23
+ import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
24
+ import org.bouncycastle.openpgp.jcajce.JcaPGPSecretKeyRingCollection;
25
+ import org.bouncycastle.jce.provider.BouncyCastleProvider;
26
+ import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
27
+ import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
28
+ import org.bouncycastle.openpgp.operator.PGPContentVerifierBuilderProvider;
29
+ import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
30
+ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
31
+ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
32
+ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
33
+ import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
34
+ import org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory;
35
+ import org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory;
23
36
 
24
37
  class PGPExampleUtil
25
38
  {
@@ -54,7 +67,15 @@ class PGPExampleUtil
54
67
  return null;
55
68
  }
56
69
 
57
- return pgpSecKey.extractPrivateKey(pass, "BC");
70
+ PGPDigestCalculatorProvider calcProvider = new JcaPGPDigestCalculatorProviderBuilder().
71
+ setProvider(BouncyCastleProvider.PROVIDER_NAME).
72
+ build();
73
+
74
+ PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(calcProvider).
75
+ setProvider(BouncyCastleProvider.PROVIDER_NAME).
76
+ build(pass);
77
+
78
+ return pgpSecKey.extractPrivateKey(decryptor);
58
79
  }
59
80
 
60
81
  static PGPPublicKey readPublicKey(String fileName) throws IOException, PGPException
@@ -76,7 +97,7 @@ class PGPExampleUtil
76
97
  */
77
98
  static PGPPublicKey readPublicKey(InputStream input) throws IOException, PGPException
78
99
  {
79
- PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(
100
+ BcPGPPublicKeyRingCollection pgpPub = new BcPGPPublicKeyRingCollection(
80
101
  PGPUtil.getDecoderStream(input));
81
102
 
82
103
  //
@@ -123,7 +144,7 @@ class PGPExampleUtil
123
144
  */
124
145
  static PGPSecretKey readSecretKey(InputStream input) throws IOException, PGPException
125
146
  {
126
- PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(
147
+ PGPSecretKeyRingCollection pgpSec = new JcaPGPSecretKeyRingCollection(
127
148
  PGPUtil.getDecoderStream(input));
128
149
 
129
150
  //
@@ -33,6 +33,7 @@ import org.bouncycastle.openpgp.*;
33
33
  import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
34
34
  import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
35
35
  import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
36
+ import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
36
37
 
37
38
  public class Verifier {
38
39
 
@@ -56,11 +57,11 @@ public class Verifier {
56
57
  {
57
58
  InputStream in = PGPUtil.getDecoderStream(inStream);
58
59
 
59
- PGPObjectFactory pgpFact = new PGPObjectFactory(in);
60
+ PGPObjectFactory pgpFact = new JcaPGPObjectFactory(in);
60
61
 
61
62
  PGPCompressedData c1 = (PGPCompressedData)pgpFact.nextObject();
62
63
 
63
- pgpFact = new PGPObjectFactory(c1.getDataStream());
64
+ pgpFact = new JcaPGPObjectFactory(c1.getDataStream());
64
65
 
65
66
  PGPOnePassSignatureList p1 = (PGPOnePassSignatureList)pgpFact.nextObject();
66
67
 
data/lib/pgp.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'java'
2
- require 'pgp/jars/bcprov-jdk15on-147.jar'
3
- require 'pgp/jars/bcpg-jdk15on-147.jar'
2
+ require 'pgp/jars/bcprov-jdk15on-153.jar'
3
+ require 'pgp/jars/bcpg-jdk15on-153.jar'
4
4
  require 'pgp/jruby-pgp.jar'
5
5
 
6
6
  require 'pgp/decryptor'
@@ -1,6 +1,7 @@
1
1
  module PGP
2
2
  class Decryptor < org.sgonyea.pgp.Decryptor
3
3
  include_package "org.bouncycastle.openpgp"
4
+ include_package "org.bouncycastle.openpgp.jcajce"
4
5
 
5
6
  def add_keys(key_string)
6
7
  self.private_keys = keyring_from_string(key_string)
@@ -33,7 +34,7 @@ module PGP
33
34
 
34
35
  def keyring_from_stream(stream)
35
36
  yafs = PGPUtil.get_decoder_stream(stream)
36
- PGPSecretKeyRingCollection.new(yafs)
37
+ JcaPGPSecretKeyRingCollection.new(yafs)
37
38
  end
38
39
 
39
40
  end
@@ -1,6 +1,7 @@
1
1
  module PGP
2
2
  class Signer < org.sgonyea.pgp.Signer
3
3
  include_package "org.bouncycastle.openpgp"
4
+ include_package "org.bouncycastle.openpgp.jcajce"
4
5
 
5
6
  def add_keys(key_string)
6
7
  self.private_keys = keyring_from_string(key_string)
@@ -32,7 +33,7 @@ module PGP
32
33
 
33
34
  def keyring_from_stream(stream)
34
35
  yafs = PGPUtil.get_decoder_stream(stream)
35
- PGPSecretKeyRingCollection.new(yafs)
36
+ JcaPGPSecretKeyRingCollection.new(yafs)
36
37
  end
37
38
 
38
39
  end
@@ -1,3 +1,3 @@
1
1
  module PGP
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,88 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-pgp
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.3.0
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Scott Gonyea
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-09 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: jruby-openssl
16
- version_requirements: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: !binary |-
21
- MA==
22
- none: false
23
14
  requirement: !ruby/object:Gem::Requirement
24
15
  requirements:
25
16
  - - ">="
26
17
  - !ruby/object:Gem::Version
27
- version: !binary |-
28
- MA==
29
- none: false
18
+ version: '0'
19
+ name: jruby-openssl
30
20
  prerelease: false
31
21
  type: :runtime
32
- - !ruby/object:Gem::Dependency
33
- name: rake
34
22
  version_requirements: !ruby/object:Gem::Requirement
35
23
  requirements:
36
24
  - - ">="
37
25
  - !ruby/object:Gem::Version
38
- version: !binary |-
39
- MA==
40
- none: false
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
41
28
  requirement: !ruby/object:Gem::Requirement
42
29
  requirements:
43
30
  - - ">="
44
31
  - !ruby/object:Gem::Version
45
- version: !binary |-
46
- MA==
47
- none: false
32
+ version: '0'
33
+ name: rake
48
34
  prerelease: false
49
35
  type: :development
50
- - !ruby/object:Gem::Dependency
51
- name: rspec
52
36
  version_requirements: !ruby/object:Gem::Requirement
53
37
  requirements:
54
38
  - - ">="
55
39
  - !ruby/object:Gem::Version
56
- version: !binary |-
57
- MA==
58
- none: false
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
59
42
  requirement: !ruby/object:Gem::Requirement
60
43
  requirements:
61
44
  - - ">="
62
45
  - !ruby/object:Gem::Version
63
- version: !binary |-
64
- MA==
65
- none: false
46
+ version: '0'
47
+ name: rspec
66
48
  prerelease: false
67
49
  type: :development
68
- - !ruby/object:Gem::Dependency
69
- name: rake-compiler
70
50
  version_requirements: !ruby/object:Gem::Requirement
71
51
  requirements:
72
52
  - - ">="
73
53
  - !ruby/object:Gem::Version
74
- version: !binary |-
75
- MA==
76
- none: false
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
77
56
  requirement: !ruby/object:Gem::Requirement
78
57
  requirements:
79
58
  - - ">="
80
59
  - !ruby/object:Gem::Version
81
- version: !binary |-
82
- MA==
83
- none: false
60
+ version: '0'
61
+ name: rake-compiler
84
62
  prerelease: false
85
63
  type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
86
69
  description: PGP for JRuby
87
70
  email:
88
71
  - me@sgonyea.com
@@ -112,8 +95,9 @@ files:
112
95
  - lib/pgp/cli/runner.rb
113
96
  - lib/pgp/decryptor.rb
114
97
  - lib/pgp/encryptor.rb
115
- - lib/pgp/jars/bcpg-jdk15on-147.jar
116
- - lib/pgp/jars/bcprov-jdk15on-147.jar
98
+ - lib/pgp/jars/bcpg-jdk15on-153.jar
99
+ - lib/pgp/jars/bcprov-jdk15on-153.jar
100
+ - lib/pgp/jruby-pgp.jar
117
101
  - lib/pgp/private_key.rb
118
102
  - lib/pgp/ruby_decryptor.rb
119
103
  - lib/pgp/signer.rb
@@ -137,9 +121,9 @@ files:
137
121
  - spec/support/fixtures/unencrypted_file.txt.asc
138
122
  - spec/support/fixtures/wrong_private_key_for_signature.asc
139
123
  - spec/support/fixtures/wrong_public_key_for_signature.asc
140
- - lib/pgp/jruby-pgp.jar
141
124
  homepage: https://github.com/sgonyea/jruby-pgp
142
125
  licenses: []
126
+ metadata: {}
143
127
  post_install_message:
144
128
  rdoc_options: []
145
129
  require_paths:
@@ -148,21 +132,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
132
  requirements:
149
133
  - - ">="
150
134
  - !ruby/object:Gem::Version
151
- version: !binary |-
152
- MA==
153
- none: false
135
+ version: '0'
154
136
  required_rubygems_version: !ruby/object:Gem::Requirement
155
137
  requirements:
156
138
  - - ">="
157
139
  - !ruby/object:Gem::Version
158
- version: !binary |-
159
- MA==
160
- none: false
140
+ version: '0'
161
141
  requirements: []
162
142
  rubyforge_project:
163
- rubygems_version: 1.8.24
143
+ rubygems_version: 2.6.4
164
144
  signing_key:
165
- specification_version: 3
145
+ specification_version: 4
166
146
  summary: This is a Java+JRuby wrapper around the Bouncy Castle PGP APIs
167
147
  test_files:
168
148
  - spec/lib/pgp/cli_spec.rb