jruby-pgp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # PGP
2
2
 
3
- This is a Java + JRuby wrapper around the Bouncy Castle PGP APIs.
3
+ This is a Java + JRuby wrapper around the Bouncy Castle PGP APIs. The goal is to write
4
+ anything that is memory / object intensive in Java. Use JRuby for everything else.
4
5
 
5
6
  ## Installation
6
7
 
@@ -16,10 +17,36 @@ Or install it yourself as:
16
17
 
17
18
  $ gem install jruby-pgp
18
19
 
20
+ ## Feature Support:
21
+
22
+ The feature set is very bare, and restricted to the following operations:
23
+
24
+ - Encrypt a file to a known list of Public Key(s).
25
+
26
+ - Decrypt a file using a given set of Private Key(s).
27
+
28
+ - Public and Private keys may be read in from disk or from memory.
29
+
30
+ Currently, you **cannot** do the following:
31
+
32
+ - Create new Private Keys / generate public keys from a given Private Key.
33
+
34
+ - Sign a file that you are encrypting.
35
+
36
+ - Verify the signature of a file that you are decrypting.
37
+
38
+ - Use password-protected Private Keys. (This is a trivial change that can later be added.)
39
+
40
+ - Obtain the name of the file that was encrypted. (Should be an easy feature to add.)
41
+
42
+ - Obtain the "modificationTime" (timestamp) of the encrypted data / file.
43
+
19
44
  ## Notes
20
45
 
21
46
  This gem currently features everything I need and nothing I don't. Pull requests are very much welcome;
22
- feature requests will be considered.
47
+ feature requests will be considered. You may also find examples for certain operations, using the
48
+ Bouncy Castle PGP APIs, and link to them in an Issue. That would make their implementation (by me) far
49
+ more likely to happen.
23
50
 
24
51
  The general goal is to provide fast, non-terrible wrappers around the Bouncy Castle PGP APIs. Bare-metal
25
52
  JRuby code will then plug into those wrappers, to minimize memory bloat. Directly hooking JRuby into the
@@ -2,5 +2,35 @@ module PGP
2
2
  class Decryptor < org.sgonyea.pgp.Decryptor
3
3
  include_package "org.bouncycastle.openpgp"
4
4
 
5
+ def add_keys(key_string)
6
+ self.private_keys = keyring_from_string(key_string)
7
+ end
8
+
9
+ def add_keys_from_file(filename)
10
+ self.private_keys = keyring_from_file(filename)
11
+ end
12
+
13
+ def decrypt(encrypted_data)
14
+ input_stream = PGP.string_to_bais(encrypted_data)
15
+ decrypted_data = decrypt_stream(input_stream)
16
+ String.from_java_bytes(decrypted_data)
17
+ end
18
+
19
+ protected
20
+ def keyring_from_file(filename)
21
+ file = File.open(filename)
22
+ keyring_from_stream(file.to_inputstream)
23
+ end
24
+
25
+ def keyring_from_string(string)
26
+ input_stream = PGP.string_to_bais(string)
27
+ keyring_from_stream(input_stream)
28
+ end
29
+
30
+ def keyring_from_stream(stream)
31
+ yafs = PGPUtil.get_decoder_stream(stream)
32
+ PGPSecretKeyRingCollection.new(yafs)
33
+ end
34
+
5
35
  end
6
36
  end
@@ -19,7 +19,6 @@ module PGP
19
19
  sec_key.extract_private_key(nil, BC_Provider_Code) if sec_key
20
20
  end
21
21
 
22
- protected
23
22
  def self.keyring_from_file(filename)
24
23
  file = File.open(filename)
25
24
  keyring_from_stream(file.to_inputstream)
@@ -1,3 +1,3 @@
1
1
  module PGP
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -13,12 +13,11 @@ describe PGP::Decryptor do
13
13
 
14
14
  describe '#decrypt' do
15
15
  before {
16
- keyring = PGP::PrivateKey.send(:keyring_from_file, private_key_path)
17
- decryptor.private_keys = keyring
16
+ decryptor.add_keys_from_file(private_key_path)
18
17
  }
19
18
 
20
19
  it "should successfully decrypt an encrypted file" do
21
- String.from_java_bytes(decryptor.decrypt_stream(PGP.string_to_bais encrypted_text)).should == unencrypted_text
20
+ decryptor.decrypt(encrypted_text).should == unencrypted_text
22
21
  end
23
22
  end
24
23
  end
metadata CHANGED
@@ -1,134 +1,118 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jruby-pgp
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
6
  platform: ruby
7
- authors:
8
- - Scott Gonyea
9
- autorequire:
7
+ authors:
8
+ - Scott Gonyea
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-18 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
16
- version_requirements: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ! '>='
19
- - !ruby/object:Gem::Version
20
- version: !binary |-
21
- MA==
22
- none: false
23
- requirement: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ! '>='
26
- - !ruby/object:Gem::Version
27
- version: !binary |-
28
- MA==
29
- none: false
30
- prerelease: false
31
- type: :development
32
- - !ruby/object:Gem::Dependency
33
- name: rspec
34
- version_requirements: !ruby/object:Gem::Requirement
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: !binary |-
39
- MA==
40
- none: false
41
- requirement: !ruby/object:Gem::Requirement
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: !binary |-
46
- MA==
47
- none: false
48
- prerelease: false
49
- type: :development
50
- - !ruby/object:Gem::Dependency
51
- name: rake-compiler
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: !binary |-
57
- MA==
58
- none: false
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: !binary |-
64
- MA==
65
- none: false
66
- prerelease: false
67
- type: :development
12
+
13
+ date: 2012-11-19 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake-compiler
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
68
48
  description: PGP for JRuby
69
- email:
70
- - me@sgonyea.com
49
+ email:
50
+ - me@sgonyea.com
71
51
  executables: []
52
+
72
53
  extensions: []
54
+
73
55
  extra_rdoc_files: []
74
- files:
75
- - .gitignore
76
- - .rspec
77
- - Gemfile
78
- - LICENSE.txt
79
- - README.md
80
- - Rakefile
81
- - ext/org/sgonyea/pgp/Decryptor.java
82
- - ext/org/sgonyea/pgp/Encryptor.java
83
- - jruby-pgp.gemspec
84
- - lib/jruby-pgp.rb
85
- - lib/pgp.rb
86
- - lib/pgp/decryptor.rb
87
- - lib/pgp/encryptor.rb
88
- - lib/pgp/jars/bcpg-jdk15on-147.jar
89
- - lib/pgp/jars/bcprov-jdk15on-147.jar
90
- - lib/pgp/private_key.rb
91
- - lib/pgp/ruby_decryptor.rb
92
- - lib/pgp/version.rb
93
- - spec/lib/pgp/decryptor_spec.rb
94
- - spec/lib/pgp/encryptor_spec.rb
95
- - spec/spec_helper.rb
96
- - spec/support/fixtures/private_key.asc
97
- - spec/support/fixtures/public_key.asc
98
- - spec/support/fixtures/unencrypted_file.txt
99
- - spec/support/fixtures/unencrypted_file.txt.asc
100
- - lib/pgp/jruby-pgp.jar
56
+
57
+ files:
58
+ - .gitignore
59
+ - .rspec
60
+ - Gemfile
61
+ - LICENSE.txt
62
+ - README.md
63
+ - Rakefile
64
+ - ext/org/sgonyea/pgp/Decryptor.java
65
+ - ext/org/sgonyea/pgp/Encryptor.java
66
+ - jruby-pgp.gemspec
67
+ - lib/jruby-pgp.rb
68
+ - lib/pgp.rb
69
+ - lib/pgp/decryptor.rb
70
+ - lib/pgp/encryptor.rb
71
+ - lib/pgp/jars/bcpg-jdk15on-147.jar
72
+ - lib/pgp/jars/bcprov-jdk15on-147.jar
73
+ - lib/pgp/private_key.rb
74
+ - lib/pgp/ruby_decryptor.rb
75
+ - lib/pgp/version.rb
76
+ - spec/lib/pgp/decryptor_spec.rb
77
+ - spec/lib/pgp/encryptor_spec.rb
78
+ - spec/spec_helper.rb
79
+ - spec/support/fixtures/private_key.asc
80
+ - spec/support/fixtures/public_key.asc
81
+ - spec/support/fixtures/unencrypted_file.txt
82
+ - spec/support/fixtures/unencrypted_file.txt.asc
83
+ - lib/pgp/jruby-pgp.jar
101
84
  homepage: https://github.com/sgonyea/jruby-pgp
102
85
  licenses: []
103
- post_install_message:
86
+
87
+ post_install_message:
104
88
  rdoc_options: []
105
- require_paths:
106
- - lib
107
- required_ruby_version: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ! '>='
110
- - !ruby/object:Gem::Version
111
- version: !binary |-
112
- MA==
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
113
93
  none: false
114
- required_rubygems_version: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: !binary |-
119
- MA==
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: "0"
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
99
  none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
121
104
  requirements: []
122
- rubyforge_project:
105
+
106
+ rubyforge_project:
123
107
  rubygems_version: 1.8.24
124
- signing_key:
108
+ signing_key:
125
109
  specification_version: 3
126
110
  summary: This is a Java+JRuby wrapper around the Bouncy Castle PGP APIs
127
- test_files:
128
- - spec/lib/pgp/decryptor_spec.rb
129
- - spec/lib/pgp/encryptor_spec.rb
130
- - spec/spec_helper.rb
131
- - spec/support/fixtures/private_key.asc
132
- - spec/support/fixtures/public_key.asc
133
- - spec/support/fixtures/unencrypted_file.txt
134
- - spec/support/fixtures/unencrypted_file.txt.asc
111
+ test_files:
112
+ - spec/lib/pgp/decryptor_spec.rb
113
+ - spec/lib/pgp/encryptor_spec.rb
114
+ - spec/spec_helper.rb
115
+ - spec/support/fixtures/private_key.asc
116
+ - spec/support/fixtures/public_key.asc
117
+ - spec/support/fixtures/unencrypted_file.txt
118
+ - spec/support/fixtures/unencrypted_file.txt.asc