jruby-pgp 0.1.0 → 0.1.1
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/README.md +29 -2
- data/lib/pgp/decryptor.rb +30 -0
- data/lib/pgp/private_key.rb +0 -1
- data/lib/pgp/version.rb +1 -1
- data/spec/lib/pgp/decryptor_spec.rb +2 -3
- metadata +101 -117
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
|
data/lib/pgp/decryptor.rb
CHANGED
@@ -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
|
data/lib/pgp/private_key.rb
CHANGED
data/lib/pgp/version.rb
CHANGED
@@ -13,12 +13,11 @@ describe PGP::Decryptor do
|
|
13
13
|
|
14
14
|
describe '#decrypt' do
|
15
15
|
before {
|
16
|
-
|
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
|
-
|
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.
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
75
|
-
|
76
|
-
- .
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
- ext/org/sgonyea/pgp/
|
83
|
-
-
|
84
|
-
-
|
85
|
-
- lib/pgp.rb
|
86
|
-
- lib/pgp
|
87
|
-
- lib/pgp/
|
88
|
-
- lib/pgp/
|
89
|
-
- lib/pgp/jars/
|
90
|
-
- lib/pgp/
|
91
|
-
- lib/pgp/
|
92
|
-
- lib/pgp/
|
93
|
-
-
|
94
|
-
- spec/lib/pgp/
|
95
|
-
- spec/
|
96
|
-
- spec/
|
97
|
-
- spec/support/fixtures/
|
98
|
-
- spec/support/fixtures/
|
99
|
-
- spec/support/fixtures/unencrypted_file.txt
|
100
|
-
-
|
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
|
-
|
86
|
+
|
87
|
+
post_install_message:
|
104
88
|
rdoc_options: []
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
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
|