jruby-jruby-openssl 0.5.0.4

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.
Files changed (56) hide show
  1. data/History.txt +34 -0
  2. data/License.txt +30 -0
  3. data/README.txt +24 -0
  4. data/lib/bcmail-jdk14-139.jar +0 -0
  5. data/lib/bcprov-jdk14-139.jar +0 -0
  6. data/lib/jopenssl.jar +0 -0
  7. data/lib/jopenssl/version.rb +5 -0
  8. data/lib/openssl.rb +24 -0
  9. data/lib/openssl/bn.rb +35 -0
  10. data/lib/openssl/buffering.rb +239 -0
  11. data/lib/openssl/cipher.rb +58 -0
  12. data/lib/openssl/digest.rb +48 -0
  13. data/lib/openssl/dummy.rb +34 -0
  14. data/lib/openssl/dummyssl.rb +13 -0
  15. data/lib/openssl/ssl.rb +135 -0
  16. data/lib/openssl/x509.rb +154 -0
  17. data/test/fixture/cacert.pem +23 -0
  18. data/test/fixture/cert_localhost.pem +19 -0
  19. data/test/fixture/localhost_keypair.pem +18 -0
  20. data/test/openssl/ssl_server.rb +99 -0
  21. data/test/openssl/test_asn1.rb +199 -0
  22. data/test/openssl/test_cipher.rb +174 -0
  23. data/test/openssl/test_digest.rb +88 -0
  24. data/test/openssl/test_hmac.rb +44 -0
  25. data/test/openssl/test_ns_spki.rb +69 -0
  26. data/test/openssl/test_pair.rb +149 -0
  27. data/test/openssl/test_pkcs7.rb +159 -0
  28. data/test/openssl/test_pkey_rsa.rb +49 -0
  29. data/test/openssl/test_ssl.rb +307 -0
  30. data/test/openssl/test_x509cert.rb +236 -0
  31. data/test/openssl/test_x509crl.rb +234 -0
  32. data/test/openssl/test_x509ext.rb +74 -0
  33. data/test/openssl/test_x509name.rb +265 -0
  34. data/test/openssl/test_x509req.rb +178 -0
  35. data/test/openssl/test_x509store.rb +245 -0
  36. data/test/openssl/utils.rb +135 -0
  37. data/test/pkcs7_mime_enveloped.message +19 -0
  38. data/test/pkcs7_mime_signed.message +30 -0
  39. data/test/pkcs7_multipart_signed.message +45 -0
  40. data/test/ref/a.out +0 -0
  41. data/test/ref/compile.rb +8 -0
  42. data/test/ref/pkcs1 +0 -0
  43. data/test/ref/pkcs1.c +21 -0
  44. data/test/test_cipher.rb +81 -0
  45. data/test/test_integration.rb +100 -0
  46. data/test/test_java.rb +98 -0
  47. data/test/test_java_attribute.rb +25 -0
  48. data/test/test_java_bio.rb +42 -0
  49. data/test/test_java_mime.rb +173 -0
  50. data/test/test_java_pkcs7.rb +769 -0
  51. data/test/test_java_smime.rb +177 -0
  52. data/test/test_openssl.rb +34 -0
  53. data/test/test_openssl_x509.rb +34 -0
  54. data/test/test_pkey.rb +46 -0
  55. data/test/ut_eof.rb +128 -0
  56. metadata +120 -0
@@ -0,0 +1,34 @@
1
+ == 0.5
2
+
3
+ * Fixed JRUBY-3614: Unsupported HMAC algorithm (HMACSHA-256)
4
+ * Fixed JRUBY-3570: ActiveMerchant's AuthorizeNet Gateway throws OpenSSL Cert Validation Error, when there should be no error
5
+ * Fixed JRUBY-3557 Class cast exception in PKeyRSA.java
6
+ * Fixed JRUBY-3468 X.509 certificates: subjectKeyIdentifier corrupted
7
+ * Fixed JRUBY-3285 Unsupported HMAC algorithm (HMACSHA1) error when generating digest
8
+ * Misc code cleanup
9
+
10
+ == 0.2
11
+
12
+ - Enable remaining tests; fix a nil string issue in SSLSocket.sysread (JRUBY-1888)
13
+ - Fix socket buffering issue by setting socket IO sync = true
14
+ - Fix bad file descriptor issue caused by unnecessary close (JRUBY-2152)
15
+ - Fix AES key length (JRUBY-2187)
16
+ - Fix cipher initialization (JRUBY-1100)
17
+ - Now, only compatible with JRuby 1.1
18
+
19
+ == 0.1.1
20
+
21
+ - Fixed blocker issue preventing HTTPS/SSL from working (JRUBY-1222)
22
+
23
+ == 0.1
24
+
25
+ - PLEASE NOTE: This release is not compatible with JRuby releases earlier than
26
+ 1.0.3 or 1.1b2. If you must use JRuby 1.0.2 or earlier, please install the
27
+ 0.6 release.
28
+ - Release coincides with JRuby 1.0.3 and JRuby 1.1b2 releases
29
+ - Simultaneous support for JRuby trunk and 1.0 branch
30
+ - Start of support for OpenSSL::BN
31
+
32
+ == 0.0.5 and prior
33
+
34
+ - Initial versions with maintenance updates
@@ -0,0 +1,30 @@
1
+ JRuby-OpenSSL is distributed under the same license as JRuby (http://www.jruby.org/).
2
+
3
+ Version: CPL 1.0/GPL 2.0/LGPL 2.1
4
+
5
+ The contents of this file are subject to the Common Public
6
+ License Version 1.0 (the "License"); you may not use this file
7
+ except in compliance with the License. You may obtain a copy of
8
+ the License at http://www.eclipse.org/legal/cpl-v10.html
9
+
10
+ Software distributed under the License is distributed on an "AS
11
+ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12
+ implied. See the License for the specific language governing
13
+ rights and limitations under the License.
14
+
15
+ Copyright (C) 2007 Ola Bini <ola.bini@gmail.com>
16
+
17
+ Alternatively, the contents of this file may be used under the terms of
18
+ either of the GNU General Public License Version 2 or later (the "GPL"),
19
+ or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20
+ in which case the provisions of the GPL or the LGPL are applicable instead
21
+ of those above. If you wish to allow use of your version of this file only
22
+ under the terms of either the GPL or the LGPL, and not to allow others to
23
+ use your version of this file under the terms of the CPL, indicate your
24
+ decision by deleting the provisions above and replace them with the notice
25
+ and other provisions required by the GPL or the LGPL. If you do not delete
26
+ the provisions above, a recipient may use your version of this file under
27
+ the terms of any one of the CPL, the GPL or the LGPL.
28
+
29
+ JRuby-OpenSSL includes software by the Legion of the Bouncy Castle
30
+ (http://bouncycastle.org/license.html).
@@ -0,0 +1,24 @@
1
+ = JRuby-OpenSSL
2
+
3
+ * http://jruby-extras.rubyforge.org/jruby-openssl
4
+
5
+ == DESCRIPTION:
6
+
7
+ JRuby-OpenSSL is an add-on gem for JRuby that emulates the Ruby OpenSSL native library.
8
+
9
+ JRuby offers *just enough* compatibility for most Ruby applications that use OpenSSL.
10
+
11
+ Libraries that appear to work fine:
12
+
13
+ Rails, Net::HTTPS
14
+
15
+ Notable libraries that do *not* yet work include:
16
+
17
+ Net::SSH, Net::SFTP, etc.
18
+
19
+ Please report bugs and incompatibilities (preferably with testcases) to either the JRuby
20
+ mailing list [1] or the JRuby bug tracker [2].
21
+
22
+ [1]: http://xircles.codehaus.org/projects/jruby/lists
23
+
24
+ [2]: http://jira.codehaus.org/browse/JRUBY
Binary file
Binary file
Binary file
@@ -0,0 +1,5 @@
1
+ module Jopenssl
2
+ module Version
3
+ VERSION = "0.5"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ =begin
2
+ = $RCSfile: openssl.rb,v $ -- Loader for all OpenSSL C-space and Ruby-space definitions
3
+
4
+ = Info
5
+ 'OpenSSL for Ruby 2' project
6
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
7
+ All rights reserved.
8
+
9
+ = Licence
10
+ This program is licenced under the same licence as Ruby.
11
+ (See the file 'LICENCE'.)
12
+
13
+ = Version
14
+ $Id: openssl.rb,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
15
+ =end
16
+
17
+ require 'jopenssl'
18
+
19
+ require 'openssl/bn'
20
+ require 'openssl/cipher'
21
+ require 'openssl/digest'
22
+ require 'openssl/ssl'
23
+ require 'openssl/x509'
24
+
@@ -0,0 +1,35 @@
1
+ =begin
2
+ = $RCSfile: bn.rb,v $ -- Ruby-space definitions that completes C-space funcs for BN
3
+
4
+ = Info
5
+ 'OpenSSL for Ruby 2' project
6
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
7
+ All rights reserved.
8
+
9
+ = Licence
10
+ This program is licenced under the same licence as Ruby.
11
+ (See the file 'LICENCE'.)
12
+
13
+ = Version
14
+ $Id: bn.rb,v 1.1 2003/07/23 16:11:30 gotoyuzo Exp $
15
+ =end
16
+
17
+ ##
18
+ # Should we care what if somebody require this file directly?
19
+ #require 'openssl'
20
+
21
+ module OpenSSL
22
+ class BN
23
+ include Comparable
24
+ end # BN
25
+ end # OpenSSL
26
+
27
+ ##
28
+ # Add double dispatch to Integer
29
+ #
30
+ class Integer
31
+ def to_bn
32
+ OpenSSL::BN::new(self)
33
+ end
34
+ end # Integer
35
+
@@ -0,0 +1,239 @@
1
+ =begin
2
+ = $RCSfile: buffering.rb,v $ -- Buffering mix-in module.
3
+
4
+ = Info
5
+ 'OpenSSL for Ruby 2' project
6
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
7
+ All rights reserved.
8
+
9
+ = Licence
10
+ This program is licenced under the same licence as Ruby.
11
+ (See the file 'LICENCE'.)
12
+
13
+ = Version
14
+ $Id: buffering.rb,v 1.5.2.4 2005/09/04 22:03:24 gotoyuzo Exp $
15
+ =end
16
+
17
+ module Buffering
18
+ include Enumerable
19
+ attr_accessor :sync
20
+ BLOCK_SIZE = 1024*16
21
+
22
+ def initialize(*args)
23
+ @eof = false
24
+ @rbuffer = ""
25
+ @sync = @io.sync
26
+ end
27
+
28
+ #
29
+ # for reading.
30
+ #
31
+ private
32
+
33
+ def fill_rbuff
34
+ begin
35
+ @rbuffer << self.sysread(BLOCK_SIZE)
36
+ rescue Errno::EAGAIN
37
+ retry
38
+ rescue EOFError
39
+ @eof = true
40
+ end
41
+ end
42
+
43
+ def consume_rbuff(size=nil)
44
+ if @rbuffer.empty?
45
+ nil
46
+ else
47
+ size = @rbuffer.size unless size
48
+ ret = @rbuffer[0, size]
49
+ @rbuffer[0, size] = ""
50
+ ret
51
+ end
52
+ end
53
+
54
+ public
55
+
56
+ def read(size=nil, buf=nil)
57
+ if size == 0
58
+ if buf
59
+ buf.clear
60
+ else
61
+ buf = ""
62
+ end
63
+ return @eof ? nil : buf
64
+ end
65
+ until @eof
66
+ break if size && size <= @rbuffer.size
67
+ fill_rbuff
68
+ end
69
+ ret = consume_rbuff(size) || ""
70
+ if buf
71
+ buf.replace(ret)
72
+ ret = buf
73
+ end
74
+ (size && ret.empty?) ? nil : ret
75
+ end
76
+
77
+ def readpartial(maxlen, buf=nil)
78
+ if maxlen == 0
79
+ if buf
80
+ buf.clear
81
+ else
82
+ buf = ""
83
+ end
84
+ return @eof ? nil : buf
85
+ end
86
+ if @rbuffer.empty?
87
+ begin
88
+ return sysread(maxlen, buf)
89
+ rescue Errno::EAGAIN
90
+ retry
91
+ end
92
+ end
93
+ ret = consume_rbuff(maxlen)
94
+ if buf
95
+ buf.replace(ret)
96
+ ret = buf
97
+ end
98
+ raise EOFError if ret.empty?
99
+ ret
100
+ end
101
+
102
+ def gets(eol=$/)
103
+ idx = @rbuffer.index(eol)
104
+ until @eof
105
+ break if idx
106
+ fill_rbuff
107
+ idx = @rbuffer.index(eol)
108
+ end
109
+ if eol.is_a?(Regexp)
110
+ size = idx ? idx+$&.size : nil
111
+ else
112
+ size = idx ? idx+eol.size : nil
113
+ end
114
+ consume_rbuff(size)
115
+ end
116
+
117
+ def each(eol=$/)
118
+ while line = self.gets(eol)
119
+ yield line
120
+ end
121
+ end
122
+ alias each_line each
123
+
124
+ def readlines(eol=$/)
125
+ ary = []
126
+ while line = self.gets(eol)
127
+ ary << line
128
+ end
129
+ ary
130
+ end
131
+
132
+ def readline(eol=$/)
133
+ raise EOFError if eof?
134
+ gets(eol)
135
+ end
136
+
137
+ def getc
138
+ c = read(1)
139
+ c ? c[0] : nil
140
+ end
141
+
142
+ def each_byte
143
+ while c = getc
144
+ yield(c)
145
+ end
146
+ end
147
+
148
+ def readchar
149
+ raise EOFError if eof?
150
+ getc
151
+ end
152
+
153
+ def ungetc(c)
154
+ @rbuffer[0,0] = c.chr
155
+ end
156
+
157
+ def eof?
158
+ fill_rbuff if !@eof && @rbuffer.empty?
159
+ @eof && @rbuffer.empty?
160
+ end
161
+ alias eof eof?
162
+
163
+ #
164
+ # for writing.
165
+ #
166
+ private
167
+
168
+ def do_write(s)
169
+ @wbuffer = "" unless defined? @wbuffer
170
+ @wbuffer << s
171
+ @sync ||= false
172
+ if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
173
+ remain = idx ? idx + $/.size : @wbuffer.length
174
+ nwritten = 0
175
+ while remain > 0
176
+ str = @wbuffer[nwritten,remain]
177
+ begin
178
+ nwrote = syswrite(str)
179
+ rescue Errno::EAGAIN
180
+ retry
181
+ end
182
+ remain -= nwrote
183
+ nwritten += nwrote
184
+ end
185
+ @wbuffer[0,nwritten] = ""
186
+ end
187
+ end
188
+
189
+ public
190
+
191
+ def write(s)
192
+ do_write(s)
193
+ s.length
194
+ end
195
+
196
+ def << (s)
197
+ do_write(s)
198
+ self
199
+ end
200
+
201
+ def puts(*args)
202
+ s = ""
203
+ if args.empty?
204
+ s << "\n"
205
+ end
206
+ args.each{|arg|
207
+ s << arg.to_s
208
+ if $/ && /\n\z/ !~ s
209
+ s << "\n"
210
+ end
211
+ }
212
+ do_write(s)
213
+ nil
214
+ end
215
+
216
+ def print(*args)
217
+ s = ""
218
+ args.each{ |arg| s << arg.to_s }
219
+ do_write(s)
220
+ nil
221
+ end
222
+
223
+ def printf(s, *args)
224
+ do_write(s % args)
225
+ nil
226
+ end
227
+
228
+ def flush
229
+ osync = @sync
230
+ @sync = true
231
+ do_write ""
232
+ @sync = osync
233
+ end
234
+
235
+ def close
236
+ flush rescue nil
237
+ sysclose
238
+ end
239
+ end
@@ -0,0 +1,58 @@
1
+ =begin
2
+ = $RCSfile: cipher.rb,v $ -- Ruby-space predefined Cipher subclasses
3
+
4
+ = Info
5
+ 'OpenSSL for Ruby 2' project
6
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
7
+ All rights reserved.
8
+
9
+ = Licence
10
+ This program is licenced under the same licence as Ruby.
11
+ (See the file 'LICENCE'.)
12
+
13
+ = Version
14
+ $Id: cipher.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
15
+ =end
16
+
17
+ ##
18
+ # Should we care what if somebody require this file directly?
19
+ #require 'openssl'
20
+
21
+ module OpenSSL
22
+ module Cipher
23
+ %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
24
+ klass = Class.new(Cipher){
25
+ define_method(:initialize){|*args|
26
+ cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
27
+ super(cipher_name)
28
+ }
29
+ }
30
+ const_set(name, klass)
31
+ }
32
+
33
+ %w(128 192 256).each{|keylen|
34
+ klass = Class.new(Cipher){
35
+ define_method(:initialize){|mode|
36
+ mode ||= "CBC"
37
+ cipher_name = "AES-#{keylen}-#{mode}"
38
+ super(cipher_name)
39
+ }
40
+ }
41
+ const_set("AES#{keylen}", klass)
42
+ }
43
+
44
+ class Cipher
45
+ def random_key
46
+ str = OpenSSL::Random.random_bytes(self.key_len)
47
+ self.key = str
48
+ return str
49
+ end
50
+
51
+ def random_iv
52
+ str = OpenSSL::Random.random_bytes(self.iv_len)
53
+ self.iv = str
54
+ return str
55
+ end
56
+ end
57
+ end # Cipher
58
+ end # OpenSSL