pftg-jruby-openssl 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.txt +48 -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 +33 -0
  10. data/lib/openssl/buffering.rb +239 -0
  11. data/lib/openssl/cipher.rb +56 -0
  12. data/lib/openssl/digest.rb +46 -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/common.pem +48 -0
  20. data/test/fixture/localhost_keypair.pem +18 -0
  21. data/test/fixture/max.pem +29 -0
  22. data/test/openssl/ssl_server.rb +99 -0
  23. data/test/openssl/test_asn1.rb +199 -0
  24. data/test/openssl/test_cipher.rb +196 -0
  25. data/test/openssl/test_digest.rb +88 -0
  26. data/test/openssl/test_hmac.rb +44 -0
  27. data/test/openssl/test_ns_spki.rb +69 -0
  28. data/test/openssl/test_pair.rb +149 -0
  29. data/test/openssl/test_pkcs7.rb +159 -0
  30. data/test/openssl/test_pkey_rsa.rb +49 -0
  31. data/test/openssl/test_ssl.rb +413 -0
  32. data/test/openssl/test_x509cert.rb +236 -0
  33. data/test/openssl/test_x509crl.rb +234 -0
  34. data/test/openssl/test_x509ext.rb +95 -0
  35. data/test/openssl/test_x509name.rb +265 -0
  36. data/test/openssl/test_x509req.rb +178 -0
  37. data/test/openssl/test_x509store.rb +245 -0
  38. data/test/openssl/utils.rb +135 -0
  39. data/test/pkcs7_mime_enveloped.message +19 -0
  40. data/test/pkcs7_mime_signed.message +30 -0
  41. data/test/pkcs7_multipart_signed.message +45 -0
  42. data/test/ref/a.out +0 -0
  43. data/test/ref/compile.rb +8 -0
  44. data/test/ref/pkcs1 +0 -0
  45. data/test/ref/pkcs1.c +21 -0
  46. data/test/test_cipher.rb +90 -0
  47. data/test/test_integration.rb +100 -0
  48. data/test/test_java.rb +98 -0
  49. data/test/test_java_attribute.rb +25 -0
  50. data/test/test_java_bio.rb +42 -0
  51. data/test/test_java_mime.rb +173 -0
  52. data/test/test_java_pkcs7.rb +769 -0
  53. data/test/test_java_smime.rb +177 -0
  54. data/test/test_openssl.rb +34 -0
  55. data/test/test_openssl_x509.rb +34 -0
  56. data/test/test_pkey.rb +46 -0
  57. data/test/ut_eof.rb +128 -0
  58. metadata +124 -0
@@ -0,0 +1,48 @@
1
+ == 0.5.2
2
+
3
+ * Multiple bugs fixed:
4
+ ** JRUBY-3895 Could not verify server signature with net-ssh against Cygwin
5
+ ** JRUBY-3864 jruby-openssl depends on Base64Coder from JvYAMLb
6
+ ** JRUBY-3790 JRuby-OpenSSL test_post_connection_check is not passing
7
+ ** JRUBY-3767 OpenSSL ssl implementation doesn't support client auth
8
+ ** JRUBY-3673 jRuby-OpenSSL does not properly load certificate authority file
9
+
10
+ == 0.5.1
11
+
12
+ * Multiple fixes by Brice Figureau to get net/ssh working. Requires JRuby 1.3.1 to be 100%
13
+ * Fix by Frederic Jean for a character-decoding issue for some certificates
14
+
15
+ == 0.5
16
+
17
+ * Fixed JRUBY-3614: Unsupported HMAC algorithm (HMACSHA-256)
18
+ * Fixed JRUBY-3570: ActiveMerchant's AuthorizeNet Gateway throws OpenSSL Cert Validation Error, when there should be no error
19
+ * Fixed JRUBY-3557 Class cast exception in PKeyRSA.java
20
+ * Fixed JRUBY-3468 X.509 certificates: subjectKeyIdentifier corrupted
21
+ * Fixed JRUBY-3285 Unsupported HMAC algorithm (HMACSHA1) error when generating digest
22
+ * Misc code cleanup
23
+
24
+ == 0.2
25
+
26
+ - Enable remaining tests; fix a nil string issue in SSLSocket.sysread (JRUBY-1888)
27
+ - Fix socket buffering issue by setting socket IO sync = true
28
+ - Fix bad file descriptor issue caused by unnecessary close (JRUBY-2152)
29
+ - Fix AES key length (JRUBY-2187)
30
+ - Fix cipher initialization (JRUBY-1100)
31
+ - Now, only compatible with JRuby 1.1
32
+
33
+ == 0.1.1
34
+
35
+ - Fixed blocker issue preventing HTTPS/SSL from working (JRUBY-1222)
36
+
37
+ == 0.1
38
+
39
+ - PLEASE NOTE: This release is not compatible with JRuby releases earlier than
40
+ 1.0.3 or 1.1b2. If you must use JRuby 1.0.2 or earlier, please install the
41
+ 0.6 release.
42
+ - Release coincides with JRuby 1.0.3 and JRuby 1.1b2 releases
43
+ - Simultaneous support for JRuby trunk and 1.0 branch
44
+ - Start of support for OpenSSL::BN
45
+
46
+ == 0.0.5 and prior
47
+
48
+ - 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.3"
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,33 @@
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
+ require 'openssl'
18
+
19
+ module OpenSSL
20
+ class BN
21
+ include Comparable
22
+ end # BN
23
+ end # OpenSSL
24
+
25
+ ##
26
+ # Add double dispatch to Integer
27
+ #
28
+ class Integer
29
+ def to_bn
30
+ OpenSSL::BN::new(self)
31
+ end
32
+ end # Integer
33
+
@@ -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,56 @@
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
+ require 'openssl'
18
+
19
+ module OpenSSL
20
+ module Cipher
21
+ class Cipher
22
+ def random_key
23
+ str = OpenSSL::Random.random_bytes(self.key_len)
24
+ self.key = str
25
+ return str
26
+ end
27
+
28
+ def random_iv
29
+ str = OpenSSL::Random.random_bytes(self.iv_len)
30
+ self.iv = str
31
+ return str
32
+ end
33
+ end
34
+
35
+ %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
36
+ klass = Class.new(Cipher){
37
+ define_method(:initialize){|*args|
38
+ cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
39
+ super(cipher_name)
40
+ }
41
+ }
42
+ const_set(name, klass)
43
+ }
44
+
45
+ %w(128 192 256).each{|keylen|
46
+ klass = Class.new(Cipher){
47
+ define_method(:initialize){|mode|
48
+ mode ||= "CBC"
49
+ cipher_name = "AES-#{keylen}-#{mode}"
50
+ super(cipher_name)
51
+ }
52
+ }
53
+ const_set("AES#{keylen}", klass)
54
+ }
55
+ end # Cipher
56
+ end # OpenSSL