jruby-openssl 0.0.4 → 0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jruby-openssl might be problematic. Click here for more details.

@@ -0,0 +1,135 @@
1
+ require "openssl"
2
+ require "test/unit"
3
+
4
+ module OpenSSL::TestUtils
5
+ TEST_KEY_RSA1024 = OpenSSL::PKey::RSA.new <<-_end_of_pem_
6
+ -----BEGIN RSA PRIVATE KEY-----
7
+ MIICXgIBAAKBgQDLwsSw1ECnPtT+PkOgHhcGA71nwC2/nL85VBGnRqDxOqjVh7Cx
8
+ aKPERYHsk4BPCkE3brtThPWc9kjHEQQ7uf9Y1rbCz0layNqHyywQEVLFmp1cpIt/
9
+ Q3geLv8ZD9pihowKJDyMDiN6ArYUmZczvW4976MU3+l54E6lF/JfFEU5hwIDAQAB
10
+ AoGBAKSl/MQarye1yOysqX6P8fDFQt68VvtXkNmlSiKOGuzyho0M+UVSFcs6k1L0
11
+ maDE25AMZUiGzuWHyaU55d7RXDgeskDMakD1v6ZejYtxJkSXbETOTLDwUWTn618T
12
+ gnb17tU1jktUtU67xK/08i/XodlgnQhs6VoHTuCh3Hu77O6RAkEA7+gxqBuZR572
13
+ 74/akiW/SuXm0SXPEviyO1MuSRwtI87B02D0qgV8D1UHRm4AhMnJ8MCs1809kMQE
14
+ JiQUCrp9mQJBANlt2ngBO14us6NnhuAseFDTBzCHXwUUu1YKHpMMmxpnGqaldGgX
15
+ sOZB3lgJsT9VlGf3YGYdkLTNVbogQKlKpB8CQQDiSwkb4vyQfDe8/NpU5Not0fII
16
+ 8jsDUCb+opWUTMmfbxWRR3FBNu8wnym/m19N4fFj8LqYzHX4KY0oVPu6qvJxAkEA
17
+ wa5snNekFcqONLIE4G5cosrIrb74sqL8GbGb+KuTAprzj5z1K8Bm0UW9lTjVDjDi
18
+ qRYgZfZSL+x1P/54+xTFSwJAY1FxA/N3QPCXCjPh5YqFxAMQs2VVYTfg+t0MEcJD
19
+ dPMQD5JX6g5HKnHFg2mZtoXQrWmJSn7p8GJK8yNTopEErA==
20
+ -----END RSA PRIVATE KEY-----
21
+ _end_of_pem_
22
+
23
+ TEST_KEY_RSA2048 = OpenSSL::PKey::RSA.new <<-_end_of_pem_
24
+ -----BEGIN RSA PRIVATE KEY-----
25
+ MIIEpAIBAAKCAQEAuV9ht9J7k4NBs38jOXvvTKY9gW8nLICSno5EETR1cuF7i4pN
26
+ s9I1QJGAFAX0BEO4KbzXmuOvfCpD3CU+Slp1enenfzq/t/e/1IRW0wkJUJUFQign
27
+ 4CtrkJL+P07yx18UjyPlBXb81ApEmAB5mrJVSrWmqbjs07JbuS4QQGGXLc+Su96D
28
+ kYKmSNVjBiLxVVSpyZfAY3hD37d60uG+X8xdW5v68JkRFIhdGlb6JL8fllf/A/bl
29
+ NwdJOhVr9mESHhwGjwfSeTDPfd8ZLE027E5lyAVX9KZYcU00mOX+fdxOSnGqS/8J
30
+ DRh0EPHDL15RcJjV2J6vZjPb0rOYGDoMcH+94wIDAQABAoIBAAzsamqfYQAqwXTb
31
+ I0CJtGg6msUgU7HVkOM+9d3hM2L791oGHV6xBAdpXW2H8LgvZHJ8eOeSghR8+dgq
32
+ PIqAffo4x1Oma+FOg3A0fb0evyiACyrOk+EcBdbBeLo/LcvahBtqnDfiUMQTpy6V
33
+ seSoFCwuN91TSCeGIsDpRjbG1vxZgtx+uI+oH5+ytqJOmfCksRDCkMglGkzyfcl0
34
+ Xc5CUhIJ0my53xijEUQl19rtWdMnNnnkdbG8PT3LZlOta5Do86BElzUYka0C6dUc
35
+ VsBDQ0Nup0P6rEQgy7tephHoRlUGTYamsajGJaAo1F3IQVIrRSuagi7+YpSpCqsW
36
+ wORqorkCgYEA7RdX6MDVrbw7LePnhyuaqTiMK+055/R1TqhB1JvvxJ1CXk2rDL6G
37
+ 0TLHQ7oGofd5LYiemg4ZVtWdJe43BPZlVgT6lvL/iGo8JnrncB9Da6L7nrq/+Rvj
38
+ XGjf1qODCK+LmreZWEsaLPURIoR/Ewwxb9J2zd0CaMjeTwafJo1CZvcCgYEAyCgb
39
+ aqoWvUecX8VvARfuA593Lsi50t4MEArnOXXcd1RnXoZWhbx5rgO8/ATKfXr0BK/n
40
+ h2GF9PfKzHFm/4V6e82OL7gu/kLy2u9bXN74vOvWFL5NOrOKPM7Kg+9I131kNYOw
41
+ Ivnr/VtHE5s0dY7JChYWE1F3vArrOw3T00a4CXUCgYEA0SqY+dS2LvIzW4cHCe9k
42
+ IQqsT0yYm5TFsUEr4sA3xcPfe4cV8sZb9k/QEGYb1+SWWZ+AHPV3UW5fl8kTbSNb
43
+ v4ng8i8rVVQ0ANbJO9e5CUrepein2MPL0AkOATR8M7t7dGGpvYV0cFk8ZrFx0oId
44
+ U0PgYDotF/iueBWlbsOM430CgYEAqYI95dFyPI5/AiSkY5queeb8+mQH62sdcCCr
45
+ vd/w/CZA/K5sbAo4SoTj8dLk4evU6HtIa0DOP63y071eaxvRpTNqLUOgmLh+D6gS
46
+ Cc7TfLuFrD+WDBatBd5jZ+SoHccVrLR/4L8jeodo5FPW05A+9gnKXEXsTxY4LOUC
47
+ 9bS4e1kCgYAqVXZh63JsMwoaxCYmQ66eJojKa47VNrOeIZDZvd2BPVf30glBOT41
48
+ gBoDG3WMPZoQj9pb7uMcrnvs4APj2FIhMU8U15LcPAj59cD6S6rWnAxO8NFK7HQG
49
+ 4Jxg3JNNf8ErQoCHb1B3oVdXJkmbJkARoDpBKmTCgKtP8ADYLmVPQw==
50
+ -----END RSA PRIVATE KEY-----
51
+ _end_of_pem_
52
+
53
+ TEST_KEY_DSA256 = OpenSSL::PKey::DSA.new <<-_end_of_pem_
54
+ -----BEGIN DSA PRIVATE KEY-----
55
+ MIH3AgEAAkEAhk2libbY2a8y2Pt21+YPYGZeW6wzaW2yfj5oiClXro9XMR7XWLkE
56
+ 9B7XxLNFCS2gmCCdMsMW1HulaHtLFQmB2wIVAM43JZrcgpu6ajZ01VkLc93gu/Ed
57
+ AkAOhujZrrKV5CzBKutKLb0GVyVWmdC7InoNSMZEeGU72rT96IjM59YzoqmD0pGM
58
+ 3I1o4cGqg1D1DfM1rQlnN1eSAkBq6xXfEDwJ1mLNxF6q8Zm/ugFYWR5xcX/3wFiT
59
+ b4+EjHP/DbNh9Vm5wcfnDBJ1zKvrMEf2xqngYdrV/3CiGJeKAhRvL57QvJZcQGvn
60
+ ISNX5cMzFHRW3Q==
61
+ -----END DSA PRIVATE KEY-----
62
+ _end_of_pem_
63
+
64
+ TEST_KEY_DSA512 = OpenSSL::PKey::DSA.new <<-_end_of_pem_
65
+ -----BEGIN DSA PRIVATE KEY-----
66
+ MIH4AgEAAkEA5lB4GvEwjrsMlGDqGsxrbqeFRh6o9OWt6FgTYiEEHaOYhkIxv0Ok
67
+ RZPDNwOG997mDjBnvDJ1i56OmS3MbTnovwIVAJgub/aDrSDB4DZGH7UyarcaGy6D
68
+ AkB9HdFw/3td8K4l1FZHv7TCZeJ3ZLb7dF3TWoGUP003RCqoji3/lHdKoVdTQNuR
69
+ S/m6DlCwhjRjiQ/lBRgCLCcaAkEAjN891JBjzpMj4bWgsACmMggFf57DS0Ti+5++
70
+ Q1VB8qkJN7rA7/2HrCR3gTsWNb1YhAsnFsoeRscC+LxXoXi9OAIUBG98h4tilg6S
71
+ 55jreJD3Se3slps=
72
+ -----END DSA PRIVATE KEY-----
73
+ _end_of_pem_
74
+
75
+ module_function
76
+
77
+ def issue_cert(dn, key, serial, not_before, not_after, extensions,
78
+ issuer, issuer_key, digest)
79
+ cert = OpenSSL::X509::Certificate.new
80
+ issuer = cert unless issuer
81
+ issuer_key = key unless issuer_key
82
+ cert.version = 2
83
+ cert.serial = serial
84
+ cert.subject = dn
85
+ cert.issuer = issuer.subject
86
+ cert.public_key = key.public_key
87
+ cert.not_before = not_before
88
+ cert.not_after = not_after
89
+ ef = OpenSSL::X509::ExtensionFactory.new
90
+ ef.subject_certificate = cert
91
+ ef.issuer_certificate = issuer
92
+ extensions.each{|oid, value, critical|
93
+ cert.add_extension(ef.create_extension(oid, value, critical))
94
+ }
95
+ cert.sign(issuer_key, digest)
96
+ cert
97
+ end
98
+
99
+ def issue_crl(revoke_info, serial, lastup, nextup, extensions,
100
+ issuer, issuer_key, digest)
101
+ crl = OpenSSL::X509::CRL.new
102
+ crl.issuer = issuer.subject
103
+ crl.version = 1
104
+ crl.last_update = lastup
105
+ crl.next_update = nextup
106
+ revoke_info.each{|serial, time, reason_code|
107
+ revoked = OpenSSL::X509::Revoked.new
108
+ revoked.serial = serial
109
+ revoked.time = time
110
+ enum = OpenSSL::ASN1::Enumerated(reason_code)
111
+ ext = OpenSSL::X509::Extension.new("CRLReason", enum)
112
+ revoked.add_extension(ext)
113
+ crl.add_revoked(revoked)
114
+ }
115
+ ef = OpenSSL::X509::ExtensionFactory.new
116
+ ef.issuer_certificate = issuer
117
+ ef.crl = crl
118
+ crlnum = OpenSSL::ASN1::Integer(serial)
119
+ crl.add_extension(OpenSSL::X509::Extension.new("crlNumber", crlnum))
120
+ extensions.each{|oid, value, critical|
121
+ crl.add_extension(ef.create_extension(oid, value, critical))
122
+ }
123
+ crl.sign(issuer_key, digest)
124
+ crl
125
+ end
126
+
127
+ def get_subject_key_id(cert)
128
+ asn1_cert = OpenSSL::ASN1.decode(cert)
129
+ tbscert = asn1_cert.value[0]
130
+ pkinfo = tbscert.value[6]
131
+ publickey = pkinfo.value[1]
132
+ pkvalue = publickey.value
133
+ OpenSSL::Digest::SHA1.hexdigest(pkvalue).scan(/../).join(":").upcase
134
+ end
135
+ end
@@ -0,0 +1,21 @@
1
+
2
+ require 'java' if RUBY_PLATFORM =~ /java/
3
+ begin
4
+ require 'openssl/test_asn1'
5
+ require 'openssl/test_cipher'
6
+ require 'openssl/test_digest'
7
+ require 'openssl/test_hmac'
8
+ require 'openssl/test_ns_spki'
9
+ # require 'openssl/test_pair'
10
+ require 'openssl/test_pkey_rsa'
11
+ # require 'openssl/test_ssl' # won't work, since kill and pid is used.
12
+ require 'openssl/test_x509cert'
13
+ require 'openssl/test_x509crl'
14
+ require 'openssl/test_x509name'
15
+ require 'openssl/test_x509ext'
16
+ require 'openssl/test_x509req'
17
+ require 'openssl/test_x509store'
18
+ rescue Exception => e
19
+ $stderr.puts "Had exception: #{e.inspect}"
20
+ $stderr.puts(*(e.backtrace))
21
+ end
data/test/ut_eof.rb ADDED
@@ -0,0 +1,128 @@
1
+ require 'test/unit'
2
+
3
+ module TestEOF
4
+ def test_eof_0
5
+ open_file("") {|f|
6
+ assert_equal("", f.read(0))
7
+ assert_equal("", f.read(0))
8
+ assert_equal("", f.read)
9
+ assert_nil(f.read(0))
10
+ assert_nil(f.read(0))
11
+ }
12
+ open_file("") {|f|
13
+ assert_nil(f.read(1))
14
+ assert_equal("", f.read)
15
+ assert_nil(f.read(1))
16
+ }
17
+ open_file("") {|f|
18
+ s = "x"
19
+ assert_equal("", f.read(nil, s))
20
+ assert_equal("", s)
21
+ }
22
+ open_file("") {|f|
23
+ s = "x"
24
+ assert_nil(f.read(10, s))
25
+ assert_equal("", s)
26
+ }
27
+ end
28
+
29
+ def test_eof_0_rw
30
+ return unless respond_to? :open_file_rw
31
+ open_file_rw("") {|f|
32
+ assert_equal("", f.read)
33
+ assert_equal("", f.read)
34
+ assert_equal(0, f.syswrite(""))
35
+ assert_equal("", f.read)
36
+ }
37
+ end
38
+
39
+ def test_eof_1
40
+ open_file("a") {|f|
41
+ assert_equal("", f.read(0))
42
+ assert_equal("a", f.read(1))
43
+ assert_equal("" , f.read(0))
44
+ assert_equal("" , f.read(0))
45
+ assert_equal("", f.read)
46
+ assert_nil(f.read(0))
47
+ assert_nil(f.read(0))
48
+ }
49
+ open_file("a") {|f|
50
+ assert_equal("a", f.read(1))
51
+ assert_nil(f.read(1))
52
+ }
53
+ open_file("a") {|f|
54
+ assert_equal("a", f.read(2))
55
+ assert_nil(f.read(1))
56
+ assert_equal("", f.read)
57
+ assert_nil(f.read(1))
58
+ }
59
+ open_file("a") {|f|
60
+ assert_equal("a", f.read)
61
+ assert_nil(f.read(1))
62
+ assert_equal("", f.read)
63
+ assert_nil(f.read(1))
64
+ }
65
+ open_file("a") {|f|
66
+ assert_equal("a", f.read(2))
67
+ assert_equal("", f.read)
68
+ assert_equal("", f.read)
69
+ }
70
+ open_file("a") {|f|
71
+ assert_equal("a", f.read)
72
+ assert_nil(f.read(0))
73
+ }
74
+ open_file("a") {|f|
75
+ s = "x"
76
+ assert_equal("a", f.read(nil, s))
77
+ assert_equal("a", s)
78
+ }
79
+ open_file("a") {|f|
80
+ s = "x"
81
+ assert_equal("a", f.read(10, s))
82
+ assert_equal("a", s)
83
+ }
84
+ end
85
+
86
+ def test_eof_2
87
+ open_file("") {|f|
88
+ assert_equal("", f.read)
89
+ assert(f.eof?)
90
+ }
91
+ end
92
+
93
+ def test_eof_3
94
+ open_file("") {|f|
95
+ assert(f.eof?)
96
+ }
97
+ end
98
+
99
+ module Seek
100
+ def open_file_seek(content, pos)
101
+ open_file(content) do |f|
102
+ f.seek(pos)
103
+ yield f
104
+ end
105
+ end
106
+
107
+ def test_eof_0_seek
108
+ open_file_seek("", 10) {|f|
109
+ assert_equal(10, f.pos)
110
+ assert_equal("", f.read(0))
111
+ assert_equal("", f.read)
112
+ assert_nil(f.read(0))
113
+ assert_equal("", f.read)
114
+ }
115
+ end
116
+
117
+ def test_eof_1_seek
118
+ open_file_seek("a", 10) {|f|
119
+ assert_equal("", f.read)
120
+ assert_equal("", f.read)
121
+ }
122
+ open_file_seek("a", 1) {|f|
123
+ assert_equal("", f.read)
124
+ assert_equal("", f.read)
125
+ }
126
+ end
127
+ end
128
+ end
metadata CHANGED
@@ -1,49 +1,85 @@
1
- --- !ruby/object:Gem::Specification
2
- required_ruby_version: !ruby/object:Gem::Version::Requirement
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: jruby-openssl
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2007-12-15 00:00:00 -06:00
8
+ summary: OpenSSL add-on for JRuby
9
+ require_paths:
10
+ - lib
11
+ email: ola.bini@gmail.com
12
+ homepage: http://jruby-extras.rubyforge.org/jopenssl
13
+ rubyforge_project: jruby-extras
14
+ description: JRuby-OpenSSL is an add-on gem for JRuby that emulates the Ruby OpenSSL native library.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
3
20
  requirements:
4
- - - '>'
5
- - !ruby/object:Gem::Version
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
6
23
  version: 0.0.0
7
24
  version:
8
- email: ola.bini@gmail.com
25
+ platform: ruby
26
+ signing_key:
9
27
  cert_chain:
10
- summary: JRuby OpenSSL
11
28
  post_install_message:
12
- homepage: http://jruby-extras.rubyforge.org/
13
- extra_rdoc_files: []
14
- signing_key:
15
- name: jruby-openssl
16
- rdoc_options: []
17
- rubyforge_project:
18
- autorequire:
19
- executables: []
20
- description:
21
- default_executable:
29
+ authors:
30
+ - Ola Bini and JRuby contributors
22
31
  files:
32
+ - History.txt
33
+ - README.txt
34
+ - License.txt
35
+ - lib/jopenssl.jar
23
36
  - lib/bcmail-jdk14-135.jar
24
37
  - lib/bcprov-jdk14-135.jar
25
- - lib/jopenssl.jar
26
- - lib/openssl.rb
38
+ - lib/jopenssl
39
+ - lib/jopenssl/version.rb
40
+ - lib/openssl
27
41
  - lib/openssl/bn.rb
28
42
  - lib/openssl/buffering.rb
29
43
  - lib/openssl/cipher.rb
30
44
  - lib/openssl/digest.rb
45
+ - lib/openssl/dummy.rb
46
+ - lib/openssl/dummyssl.rb
31
47
  - lib/openssl/ssl.rb
32
48
  - lib/openssl/x509.rb
33
- specification_version: 1
49
+ - lib/openssl.rb
50
+ - test/openssl
51
+ - test/openssl/ssl_server.rb
52
+ - test/openssl/test_asn1.rb
53
+ - test/openssl/test_cipher.rb
54
+ - test/openssl/test_digest.rb
55
+ - test/openssl/test_hmac.rb
56
+ - test/openssl/test_ns_spki.rb
57
+ - test/openssl/test_pair.rb
58
+ - test/openssl/test_pkey_rsa.rb
59
+ - test/openssl/test_ssl.rb
60
+ - test/openssl/test_x509cert.rb
61
+ - test/openssl/test_x509crl.rb
62
+ - test/openssl/test_x509ext.rb
63
+ - test/openssl/test_x509name.rb
64
+ - test/openssl/test_x509req.rb
65
+ - test/openssl/test_x509store.rb
66
+ - test/openssl/utils.rb
67
+ - test/test_openssl.rb
68
+ - test/ut_eof.rb
69
+ test_files:
70
+ - test/test_openssl.rb
71
+ rdoc_options:
72
+ - --main
73
+ - README.txt
74
+ extra_rdoc_files:
75
+ - History.txt
76
+ - README.txt
77
+ - License.txt
78
+ executables: []
79
+
34
80
  extensions: []
35
- rubygems_version: 0.9.4
36
- requirements:
37
- - Java 1.5
38
- authors:
39
- - Ola Bini
40
- platform: ruby
41
- date: 2007-08-10 23:00:00 +00:00
42
- require_paths:
43
- - lib
44
- version: !ruby/object:Gem::Version
45
- version: 0.0.4
46
- test_files: []
47
- bindir: bin
81
+
82
+ requirements: []
83
+
48
84
  dependencies: []
49
- has_rdoc: false
85
+