jruby-openssl 0.7.5.dev → 0.7.5

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 (93) hide show
  1. data/History.txt +44 -14
  2. data/Manifest.txt +135 -80
  3. data/Rakefile +14 -6
  4. data/lib/{openssl.rb → 1.8/openssl.rb} +2 -11
  5. data/lib/{openssl → 1.8/openssl}/bn.rb +2 -2
  6. data/lib/{openssl → 1.8/openssl}/buffering.rb +3 -1
  7. data/lib/{openssl → 1.8/openssl}/cipher.rb +0 -0
  8. data/lib/{openssl → 1.8/openssl}/config.rb +1 -1
  9. data/lib/{openssl → 1.8/openssl}/digest.rb +2 -2
  10. data/lib/{openssl → 1.8/openssl}/pkcs7.rb +0 -0
  11. data/lib/{openssl/ssl.rb → 1.8/openssl/ssl-internal.rb} +2 -2
  12. data/lib/1.8/openssl/ssl.rb +1 -0
  13. data/lib/{openssl/x509.rb → 1.8/openssl/x509-internal.rb} +8 -9
  14. data/lib/1.8/openssl/x509.rb +1 -0
  15. data/lib/1.9/openssl.rb +22 -0
  16. data/lib/1.9/openssl/bn.rb +35 -0
  17. data/lib/1.9/openssl/buffering.rb +448 -0
  18. data/lib/1.9/openssl/cipher.rb +65 -0
  19. data/lib/1.9/openssl/config.rb +313 -0
  20. data/lib/1.9/openssl/digest.rb +72 -0
  21. data/lib/1.9/openssl/ssl-internal.rb +177 -0
  22. data/lib/1.9/openssl/ssl.rb +2 -0
  23. data/lib/1.9/openssl/x509-internal.rb +158 -0
  24. data/lib/1.9/openssl/x509.rb +2 -0
  25. data/lib/{jopenssl.jar → shared/jopenssl.jar} +0 -0
  26. data/lib/{jopenssl → shared/jopenssl}/version.rb +1 -1
  27. data/lib/shared/openssl.rb +18 -0
  28. data/lib/{openssl → shared/openssl}/dummy.rb +0 -0
  29. data/lib/{openssl → shared/openssl}/dummyssl.rb +0 -0
  30. data/lib/shared/openssl/ssl.rb +1 -0
  31. data/lib/shared/openssl/x509.rb +1 -0
  32. data/test/{openssl → 1.8}/ssl_server.rb +0 -0
  33. data/test/{openssl → 1.8}/test_asn1.rb +15 -0
  34. data/test/{openssl → 1.8}/test_cipher.rb +0 -0
  35. data/test/{openssl → 1.8}/test_config.rb +0 -0
  36. data/test/{openssl → 1.8}/test_digest.rb +0 -0
  37. data/test/{openssl → 1.8}/test_ec.rb +0 -0
  38. data/test/{openssl → 1.8}/test_hmac.rb +0 -0
  39. data/test/{openssl → 1.8}/test_ns_spki.rb +0 -0
  40. data/test/{openssl → 1.8}/test_pair.rb +10 -2
  41. data/test/{openssl → 1.8}/test_pkcs7.rb +0 -0
  42. data/test/{openssl → 1.8}/test_pkey_rsa.rb +0 -0
  43. data/test/{openssl → 1.8}/test_ssl.rb +17 -20
  44. data/test/{openssl → 1.8}/test_x509cert.rb +0 -0
  45. data/test/{openssl → 1.8}/test_x509crl.rb +0 -0
  46. data/test/{openssl → 1.8}/test_x509ext.rb +0 -0
  47. data/test/{openssl → 1.8}/test_x509name.rb +0 -0
  48. data/test/{openssl → 1.8}/test_x509req.rb +0 -0
  49. data/test/{openssl → 1.8}/test_x509store.rb +0 -0
  50. data/test/{openssl → 1.8}/utils.rb +0 -0
  51. data/test/1.9/ssl_server.rb +81 -0
  52. data/test/1.9/test_asn1.rb +589 -0
  53. data/test/1.9/test_bn.rb +23 -0
  54. data/test/1.9/test_buffering.rb +88 -0
  55. data/test/1.9/test_cipher.rb +107 -0
  56. data/test/1.9/test_config.rb +288 -0
  57. data/test/1.9/test_digest.rb +118 -0
  58. data/test/1.9/test_engine.rb +15 -0
  59. data/test/1.9/test_hmac.rb +32 -0
  60. data/test/1.9/test_ns_spki.rb +50 -0
  61. data/test/1.9/test_ocsp.rb +47 -0
  62. data/test/1.9/test_pair.rb +257 -0
  63. data/test/1.9/test_pkcs12.rb +209 -0
  64. data/test/1.9/test_pkcs7.rb +151 -0
  65. data/test/1.9/test_pkey_dh.rb +72 -0
  66. data/test/1.9/test_pkey_dsa.rb +224 -0
  67. data/test/1.9/test_pkey_ec.rb +182 -0
  68. data/test/1.9/test_pkey_rsa.rb +244 -0
  69. data/test/1.9/test_ssl.rb +455 -0
  70. data/test/1.9/test_ssl_session.rb +327 -0
  71. data/test/1.9/test_x509cert.rb +217 -0
  72. data/test/1.9/test_x509crl.rb +221 -0
  73. data/test/1.9/test_x509ext.rb +69 -0
  74. data/test/1.9/test_x509name.rb +296 -0
  75. data/test/1.9/test_x509req.rb +150 -0
  76. data/test/1.9/test_x509store.rb +229 -0
  77. data/test/1.9/utils.rb +304 -0
  78. data/test/fixture/purpose/ca/ca_config.rb +1 -1
  79. data/test/fixture/purpose/ca/gen_cert.rb +128 -0
  80. data/test/fixture/purpose/ca/newcerts/4_cert.pem +19 -0
  81. data/test/fixture/purpose/ca/serial +1 -1
  82. data/test/fixture/purpose/sslserver_no_dsig_in_keyUsage.pem +19 -0
  83. data/test/ruby/envutil.rb +208 -0
  84. data/test/ruby/ut_eof.rb +128 -0
  85. data/test/test_java.rb +1 -1
  86. data/test/test_openssl.rb +1 -1
  87. data/test/test_pkcs7.rb +16 -0
  88. data/test/test_pkey_dsa.rb +180 -0
  89. data/test/test_pkey_rsa.rb +298 -0
  90. data/test/test_ssl.rb +1 -1
  91. data/test/test_x509store.rb +8 -0
  92. metadata +121 -75
  93. data/test/test_pkey.rb +0 -204
@@ -3,7 +3,7 @@ require 'test/unit'
3
3
  require 'webrick/https'
4
4
  require 'net/https'
5
5
  require 'logger'
6
- require File.join(File.dirname(__FILE__), "openssl/utils.rb")
6
+ require File.join(File.dirname(__FILE__), (RUBY_VERSION >= '1.9.0' ? '1.9' : '1.8'), "utils.rb")
7
7
 
8
8
 
9
9
  class TestSSL < Test::Unit::TestCase
@@ -63,6 +63,14 @@ class TestX509Store < Test::Unit::TestCase
63
63
  assert_equal(true, @store.verify(cert))
64
64
  end
65
65
 
66
+ # keyUsage: no digitalSignature bit, keyEncipherment bit only.
67
+ def test_purpose_ssl_server_no_dsig_in_keyUsage
68
+ @store.add_file(path("fixture/purpose/cacert.pem"))
69
+ cert = OpenSSL::X509::Certificate.new(File.read(path("fixture/purpose/sslserver_no_dsig_in_keyUsage.pem")))
70
+ @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
71
+ assert_equal(true, @store.verify(cert))
72
+ end
73
+
66
74
  def test_add_file_multiple
67
75
  f = Tempfile.new("globalsign-root.pem")
68
76
  f << GLOBALSIGN_ROOT_CA
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-openssl
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 0.7.5.dev
4
+ prerelease:
5
+ version: 0.7.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ola Bini and JRuby contributors
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-31 00:00:00 +09:00
14
- default_executable:
13
+ date: 2012-01-23 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: bouncy-castle-java
@@ -41,103 +40,150 @@ files:
41
40
  - Manifest.txt
42
41
  - README.txt
43
42
  - License.txt
44
- - lib/jopenssl.jar
45
- - lib/openssl.rb
46
- - lib/openssl/dummy.rb
47
- - lib/openssl/dummyssl.rb
48
- - lib/openssl/config.rb
49
- - lib/openssl/cipher.rb
50
- - lib/openssl/ssl.rb
51
- - lib/openssl/bn.rb
52
- - lib/openssl/x509.rb
53
- - lib/openssl/digest.rb
54
- - lib/openssl/buffering.rb
55
- - lib/openssl/pkcs7.rb
56
- - lib/jopenssl/version.rb
57
- - test/test_imaps.rb
43
+ - lib/shared/jopenssl.jar
44
+ - lib/1.9/openssl.rb
45
+ - lib/1.9/openssl/bn.rb
46
+ - lib/1.9/openssl/x509-internal.rb
47
+ - lib/1.9/openssl/cipher.rb
48
+ - lib/1.9/openssl/digest.rb
49
+ - lib/1.9/openssl/ssl.rb
50
+ - lib/1.9/openssl/buffering.rb
51
+ - lib/1.9/openssl/ssl-internal.rb
52
+ - lib/1.9/openssl/x509.rb
53
+ - lib/1.9/openssl/config.rb
54
+ - lib/shared/openssl.rb
55
+ - lib/shared/openssl/dummyssl.rb
56
+ - lib/shared/openssl/ssl.rb
57
+ - lib/shared/openssl/x509.rb
58
+ - lib/shared/openssl/dummy.rb
59
+ - lib/shared/jopenssl/version.rb
60
+ - lib/1.8/openssl.rb
61
+ - lib/1.8/openssl/bn.rb
62
+ - lib/1.8/openssl/pkcs7.rb
63
+ - lib/1.8/openssl/x509-internal.rb
64
+ - lib/1.8/openssl/cipher.rb
65
+ - lib/1.8/openssl/digest.rb
66
+ - lib/1.8/openssl/ssl.rb
67
+ - lib/1.8/openssl/buffering.rb
68
+ - lib/1.8/openssl/ssl-internal.rb
69
+ - lib/1.8/openssl/x509.rb
70
+ - lib/1.8/openssl/config.rb
58
71
  - test/test_all.rb
72
+ - test/test_pkey_dsa.rb
59
73
  - test/test_integration.rb
60
- - test/ut_eof.rb
61
- - test/test_java.rb
74
+ - test/test_ssl.rb
75
+ - test/test_parse_certificate.rb
62
76
  - test/test_openssl.rb
63
- - test/test_pkey.rb
64
- - test/test_cipher.rb
65
77
  - test/cert_with_ec_pk.cer
66
- - test/test_pkcs7.rb
78
+ - test/ut_eof.rb
67
79
  - test/test_x509store.rb
80
+ - test/test_imaps.rb
68
81
  - test/test_certificate.rb
69
- - test/test_parse_certificate.rb
70
- - test/test_ssl.rb
71
- - test/openssl/test_x509name.rb
72
- - test/openssl/test_ns_spki.rb
73
- - test/openssl/test_x509cert.rb
74
- - test/openssl/ssl_server.rb
75
- - test/openssl/test_pair.rb
76
- - test/openssl/test_ec.rb
77
- - test/openssl/test_config.rb
78
- - test/openssl/utils.rb
79
- - test/openssl/test_x509req.rb
80
- - test/openssl/test_cipher.rb
81
- - test/openssl/test_digest.rb
82
- - test/openssl/test_x509ext.rb
83
- - test/openssl/test_asn1.rb
84
- - test/openssl/test_pkcs7.rb
85
- - test/openssl/test_x509store.rb
86
- - test/openssl/test_pkey_rsa.rb
87
- - test/openssl/test_ssl.rb
88
- - test/openssl/test_x509crl.rb
89
- - test/openssl/test_hmac.rb
90
- - test/ref/compile.rb
82
+ - test/test_pkcs7.rb
83
+ - test/test_cipher.rb
84
+ - test/test_pkey_rsa.rb
85
+ - test/test_java.rb
86
+ - test/1.9/test_ssl_session.rb
87
+ - test/1.9/test_engine.rb
88
+ - test/1.9/test_asn1.rb
89
+ - test/1.9/test_pkey_dh.rb
90
+ - test/1.9/test_pkey_dsa.rb
91
+ - test/1.9/test_ocsp.rb
92
+ - test/1.9/ssl_server.rb
93
+ - test/1.9/test_x509ext.rb
94
+ - test/1.9/utils.rb
95
+ - test/1.9/test_ssl.rb
96
+ - test/1.9/test_buffering.rb
97
+ - test/1.9/test_ns_spki.rb
98
+ - test/1.9/test_digest.rb
99
+ - test/1.9/test_pair.rb
100
+ - test/1.9/test_x509crl.rb
101
+ - test/1.9/test_x509store.rb
102
+ - test/1.9/test_bn.rb
103
+ - test/1.9/test_pkey_ec.rb
104
+ - test/1.9/test_pkcs7.rb
105
+ - test/1.9/test_pkcs12.rb
106
+ - test/1.9/test_cipher.rb
107
+ - test/1.9/test_pkey_rsa.rb
108
+ - test/1.9/test_x509req.rb
109
+ - test/1.9/test_x509name.rb
110
+ - test/1.9/test_hmac.rb
111
+ - test/1.9/test_x509cert.rb
112
+ - test/1.9/test_config.rb
91
113
  - test/ref/a.out
92
114
  - test/ref/pkcs1
93
115
  - test/ref/pkcs1.c
94
- - test/fixture/cacert.pem
95
- - test/fixture/ca-bundle.crt
116
+ - test/ref/compile.rb
96
117
  - test/fixture/common.pem
97
118
  - test/fixture/key_then_cert.pem
119
+ - test/fixture/keypair.pem
120
+ - test/fixture/cacert.pem
98
121
  - test/fixture/verisign.pem
99
122
  - test/fixture/cert_localhost.pem
100
- - test/fixture/localhost_keypair.pem
101
- - test/fixture/verisign_c3.pem
102
123
  - test/fixture/selfcert.pem
103
- - test/fixture/ids_in_subject_rdn_set.pem
104
124
  - test/fixture/max.pem
105
- - test/fixture/keypair.pem
125
+ - test/fixture/localhost_keypair.pem
126
+ - test/fixture/ids_in_subject_rdn_set.pem
127
+ - test/fixture/ca-bundle.crt
128
+ - test/fixture/verisign_c3.pem
129
+ - test/fixture/ca_path/72fa7371.0
130
+ - test/fixture/ca_path/verisign.pem
131
+ - test/fixture/imaps/cacert.pem
132
+ - test/fixture/imaps/server.crt
133
+ - test/fixture/imaps/server.key
134
+ - test/fixture/purpose/sslserver_no_dsig_in_keyUsage.pem
106
135
  - test/fixture/purpose/cacert.pem
107
- - test/fixture/purpose/b70a5bc1.0
108
- - test/fixture/purpose/sslclient.pem
109
136
  - test/fixture/purpose/sslserver.pem
110
- - test/fixture/purpose/sslclient/sslclient.pem
111
- - test/fixture/purpose/sslclient/csr.pem
112
- - test/fixture/purpose/sslclient/keypair.pem
113
- - test/fixture/purpose/ca/cacert.pem
137
+ - test/fixture/purpose/sslclient.pem
138
+ - test/fixture/purpose/b70a5bc1.0
139
+ - test/fixture/purpose/ca/serial
140
+ - test/fixture/purpose/ca/gen_cert.rb
114
141
  - test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234
115
142
  - test/fixture/purpose/ca/ca_config.rb
116
- - test/fixture/purpose/ca/serial
117
- - test/fixture/purpose/ca/newcerts/2_cert.pem
118
- - test/fixture/purpose/ca/newcerts/3_cert.pem
143
+ - test/fixture/purpose/ca/cacert.pem
119
144
  - test/fixture/purpose/ca/private/cakeypair.pem
145
+ - test/fixture/purpose/ca/newcerts/4_cert.pem
146
+ - test/fixture/purpose/ca/newcerts/3_cert.pem
147
+ - test/fixture/purpose/ca/newcerts/2_cert.pem
148
+ - test/fixture/purpose/sslclient/csr.pem
149
+ - test/fixture/purpose/sslclient/keypair.pem
150
+ - test/fixture/purpose/sslclient/sslclient.pem
120
151
  - test/fixture/purpose/scripts/gen_cert.rb
121
152
  - test/fixture/purpose/scripts/init_ca.rb
122
153
  - test/fixture/purpose/scripts/gen_csr.rb
123
- - test/fixture/purpose/sslserver/sslserver.pem
124
154
  - test/fixture/purpose/sslserver/csr.pem
125
155
  - test/fixture/purpose/sslserver/keypair.pem
126
- - test/fixture/imaps/cacert.pem
127
- - test/fixture/imaps/server.crt
128
- - test/fixture/imaps/server.key
129
- - test/fixture/ca_path/verisign.pem
130
- - test/fixture/ca_path/72fa7371.0
156
+ - test/fixture/purpose/sslserver/sslserver.pem
157
+ - test/ruby/ut_eof.rb
158
+ - test/ruby/envutil.rb
131
159
  - test/java/pkcs7_mime_enveloped.message
132
- - test/java/pkcs7_mime_signed.message
160
+ - test/java/test_java_attribute.rb
133
161
  - test/java/test_java_pkcs7.rb
134
- - test/java/test_java_bio.rb
135
- - test/java/pkcs7_multipart_signed.message
136
162
  - test/java/test_java_mime.rb
137
- - test/java/test_java_attribute.rb
163
+ - test/java/pkcs7_mime_signed.message
138
164
  - test/java/test_java_smime.rb
165
+ - test/java/pkcs7_multipart_signed.message
166
+ - test/java/test_java_bio.rb
167
+ - test/1.8/test_asn1.rb
168
+ - test/1.8/ssl_server.rb
169
+ - test/1.8/test_x509ext.rb
170
+ - test/1.8/utils.rb
171
+ - test/1.8/test_ssl.rb
172
+ - test/1.8/test_ec.rb
173
+ - test/1.8/test_ns_spki.rb
174
+ - test/1.8/test_digest.rb
175
+ - test/1.8/test_pair.rb
176
+ - test/1.8/test_x509crl.rb
177
+ - test/1.8/test_x509store.rb
178
+ - test/1.8/test_pkcs7.rb
179
+ - test/1.8/test_cipher.rb
180
+ - test/1.8/test_pkey_rsa.rb
181
+ - test/1.8/test_x509req.rb
182
+ - test/1.8/test_x509name.rb
183
+ - test/1.8/test_hmac.rb
184
+ - test/1.8/test_x509cert.rb
185
+ - test/1.8/test_config.rb
139
186
  - .gemtest
140
- has_rdoc: true
141
187
  homepage: http://jruby-extras.rubyforge.org/jruby-openssl
142
188
  licenses: []
143
189
 
@@ -146,7 +192,7 @@ rdoc_options:
146
192
  - --main
147
193
  - README.txt
148
194
  require_paths:
149
- - lib
195
+ - lib/shared
150
196
  required_ruby_version: !ruby/object:Gem::Requirement
151
197
  none: false
152
198
  requirements:
@@ -156,13 +202,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
202
  required_rubygems_version: !ruby/object:Gem::Requirement
157
203
  none: false
158
204
  requirements:
159
- - - ">"
205
+ - - ">="
160
206
  - !ruby/object:Gem::Version
161
- version: 1.3.1
207
+ version: "0"
162
208
  requirements: []
163
209
 
164
210
  rubyforge_project: jruby-extras
165
- rubygems_version: 1.5.1
211
+ rubygems_version: 1.8.13
166
212
  signing_key:
167
213
  specification_version: 3
168
214
  summary: OpenSSL add-on for JRuby
@@ -1,204 +0,0 @@
1
- begin
2
- require "openssl"
3
- rescue LoadError
4
- end
5
-
6
- require "test/unit"
7
-
8
- class TestPKey < Test::Unit::TestCase
9
- def test_has_correct_methods
10
- pkey_methods = OpenSSL::PKey::PKey.instance_methods(false).sort - ["initialize"]
11
- assert_equal ["sign", "verify"], pkey_methods
12
-
13
- rsa_methods = OpenSSL::PKey::RSA.instance_methods(false).sort - ["initialize"]
14
- assert_equal ["d", "d=", "dmp1", "dmp1=", "dmq1", "dmq1=", "e", "e=", "export", "iqmp", "iqmp=", "n", "n=", "p", "p=", "params", "private?", "private_decrypt", "private_encrypt", "public?", "public_decrypt", "public_encrypt", "public_key", "q", "q=", "to_der", "to_pem", "to_s", "to_text"], rsa_methods
15
-
16
- assert_equal ["generate"], OpenSSL::PKey::RSA.methods(false)
17
-
18
- # dsa_methods = OpenSSL::PKey::DSA.instance_methods(false).sort - ["initialize"]
19
- # assert_equal ["export", "g", "g=", "p", "p=", "params", "priv_key", "priv_key=", "private?", "pub_key", "pub_key=", "public?", "public_key", "q", "q=", "syssign", "sysverify", "to_der", "to_pem", "to_s", "to_text"], dsa_methods
20
-
21
- # assert_equal ["generate"], OpenSSL::PKey::DSA.methods(false)
22
- end
23
-
24
- #iqmp == coefficient
25
- #e == public exponent
26
- #n == modulus
27
- #d == private exponent
28
- #p == prime1
29
- #q == prime2
30
- #dmq1 == exponent2
31
- #dmp1 == exponent1
32
-
33
- def test_can_generate_rsa_key
34
- OpenSSL::PKey::RSA.generate(512)
35
- end
36
-
37
- def test_can_generate_dsa_key
38
- OpenSSL::PKey::DSA.generate(512)
39
- end
40
-
41
- def test_malformed_rsa_handling
42
- pem = <<__EOP__
43
- -----BEGIN PUBLIC KEY-----
44
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtiU1/UMzIQ1On9OlZGoV
45
- S0yySFYWoXLH12nmP69fg9jwdRbQlb0rxLn7zATbwfqcvGpCcW+8SmdwW74elNrc
46
- wRtbKjJKfbJCsVfDssbbj6BF+Bcq3ihi8+CGNXFdJOYhZZ+5Adg2Qc9Qp3Ubw9wu
47
- /3Ai87+1aQxoZPMFwdX2BRiZvxch9dwHVyL8EuFGUOYId/8JQepHyZMbTqp/8wlA
48
- UAbMcPW+IKp3N0WMgred3CjXKHAqqM0Ira9RLSXdlO2uFV4OrM0ak8rnTN5w1DsI
49
- McjvVvOck0aIxfHEEmeadt3YMn4PCW33/j8geulZLvt0ci60/OWMSCcIqByITlvY
50
- DwIDAQAB
51
- -----END PUBLIC KEY-----
52
- __EOP__
53
- pkey = OpenSSL::PKey::RSA.new(pem)
54
- # jruby-openssl/0.6 raises NativeException
55
- assert_raise(OpenSSL::PKey::RSAError, 'JRUBY-4492') do
56
- pkey.public_decrypt("rah")
57
- end
58
- end
59
-
60
- # http://github.com/jruby/jruby-openssl/issues#issue/1
61
- def test_load_pkey_rsa
62
- pem = <<__EOP__
63
- -----BEGIN PRIVATE KEY-----
64
- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
65
- A7qVvdqxevEuUkW4K+2KdMXmnQbG9Aa7k7eBjK1S+0LYmVjPKlJGNXHDGuy5Fw/d
66
- 7rjVJ0BLB+ubPK8iA/Tw3hLQgXMRRGRXXCn8ikfuQfjUS1uZSatdLB81mydBETlJ
67
- hI6GH4twrbDJCR2Bwy/XWXgqgGRzAgMBAAECgYBYWVtleUzavkbrPjy0T5FMou8H
68
- X9u2AC2ry8vD/l7cqedtwMPp9k7TubgNFo+NGvKsl2ynyprOZR1xjQ7WgrgVB+mm
69
- uScOM/5HVceFuGRDhYTCObE+y1kxRloNYXnx3ei1zbeYLPCHdhxRYW7T0qcynNmw
70
- rn05/KO2RLjgQNalsQJBANeA3Q4Nugqy4QBUCEC09SqylT2K9FrrItqL2QKc9v0Z
71
- zO2uwllCbg0dwpVuYPYXYvikNHHg+aCWF+VXsb9rpPsCQQDWR9TT4ORdzoj+Nccn
72
- qkMsDmzt0EfNaAOwHOmVJ2RVBspPcxt5iN4HI7HNeG6U5YsFBb+/GZbgfBT3kpNG
73
- WPTpAkBI+gFhjfJvRw38n3g/+UeAkwMI2TJQS4n8+hid0uus3/zOjDySH3XHCUno
74
- cn1xOJAyZODBo47E+67R4jV1/gzbAkEAklJaspRPXP877NssM5nAZMU0/O/NGCZ+
75
- 3jPgDUno6WbJn5cqm8MqWhW1xGkImgRk+fkDBquiq4gPiT898jusgQJAd5Zrr6Q8
76
- AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54
77
- Lw03eHTNQghS0A==
78
- -----END PRIVATE KEY-----
79
- __EOP__
80
- assert_nothing_raised do
81
- pkey = OpenSSL::PKey::RSA.new(pem)
82
- pkey2 = OpenSSL::PKey::RSA.new(pkey.to_pem)
83
- assert_equal(pkey.n, pkey2.n)
84
- assert_equal(pkey.e, pkey2.e)
85
- assert_equal(pkey.d, pkey2.d)
86
- end
87
- end
88
-
89
- def test_load_pkey_rsa_enc
90
- # password is '1234'
91
- pem = <<__EOP__
92
- -----BEGIN ENCRYPTED PRIVATE KEY-----
93
- MIICoTAbBgkqhkiG9w0BBQMwDgQIfvehP6JEg2wCAggABIICgD7kzSr+xWgdAuzG
94
- cYNkCEWyKF6V0cJ58AKSoL4FQ59OQvQP/hMnSZEMiUpeGNRE6efC7O02RUjNarIk
95
- ciCYIBqd5EFG3OSypK5l777AbCChIkzZHbyE/pIbadr8ZX9C4pkwzPqS0Avzavxi
96
- 5s1WDX2GggJkBcQUijqG9QuOZcOvoYbojHPT4tdJq+J6s+0LFas9Jp3a6dYkxtgv
97
- u8Z6EFDZoLGOSVy/jCSMuZAnhoOxUCYqd9FFo2jryV7tQ/CaYAUApAQFTLgBA9qk
98
- 4WmyKRpwzIx6EG1pkqulvPXJCcTat9YwllEDVuQ2rKVwDepSl9O7X170Kx1sBecz
99
- mGcfqviU9xwP5mkXO/TLoTZExkHF08Y3d/PTMdxGEDZH37/yRqCIb3Uyqv/jLibM
100
- /s9fm52aWsfO1ndHEhciovlMJvGXq3+e+9gmq1w2TyNQahRc5fwfhwWKhPKfYDBk
101
- 7AtjPGfELDX61WZ5m+4Kb70BcGSAEgXCaBydVsMROy0B8jkYgtAnVBb4EMrGOsCG
102
- jmNeW9MRIhrhDcifdyq1DMNg7IONMF+5mDdQ3FhK6WzlFU+8cTN517qA8L3A3+ZX
103
- asiS+rx5/50InINknjuvVkmTGMzjl89nMNrZCjhx9sIDfXQ3ZKFmh1mvnXq/fLan
104
- CgXn/UtLoykrSlobgqIxZslhj3p01kMCgGe62S3kokYrDTQEc57rlKWWR3Xyjy/T
105
- LsecXAKEROj95IHSMMnT4jl+TJnbvGKQ2U9tOOB3W+OOOlDEFE59pQlcmQPAwdzr
106
- mzI4kupi3QRTFjOgvX29leII9sPtpr4dKMKVIRxKnvMZhUAkS/n3+Szfa6zKexLa
107
- 4CHVgDo=
108
- -----END ENCRYPTED PRIVATE KEY-----
109
- __EOP__
110
- assert_nothing_raised do
111
- pkey = OpenSSL::PKey::RSA.new(pem, '1234')
112
- pkey2 = OpenSSL::PKey::RSA.new(pkey.to_pem)
113
- assert_equal(pkey.n, pkey2.n)
114
- assert_equal(pkey.e, pkey2.e)
115
- assert_equal(pkey.d, pkey2.d)
116
- end
117
- end
118
-
119
- # jruby-openssl/0.6 causes NPE
120
- def test_generate_pkey_rsa_empty
121
- assert_nothing_raised do
122
- OpenSSL::PKey::RSA.new.to_pem
123
- end
124
- end
125
-
126
- def test_generate_pkey_rsa_length
127
- assert_nothing_raised do
128
- OpenSSL::PKey::RSA.new(512).to_pem
129
- end
130
- end
131
-
132
- def test_generate_pkey_rsa_to_text
133
- assert_match(
134
- /Private-Key: \(512 bit\)/,
135
- OpenSSL::PKey::RSA.new(512).to_text
136
- )
137
- end
138
-
139
- def test_load_pkey_rsa
140
- pkey = OpenSSL::PKey::RSA.new(512)
141
- assert_equal(pkey.to_pem, OpenSSL::PKey::RSA.new(pkey.to_pem).to_pem)
142
- end
143
-
144
- def test_load_pkey_rsa_public
145
- pkey = OpenSSL::PKey::RSA.new(512).public_key
146
- assert_equal(pkey.to_pem, OpenSSL::PKey::RSA.new(pkey.to_pem).to_pem)
147
- end
148
-
149
- def test_load_pkey_rsa_der
150
- pkey = OpenSSL::PKey::RSA.new(512)
151
- assert_equal(pkey.to_der, OpenSSL::PKey::RSA.new(pkey.to_der).to_der)
152
- end
153
-
154
- def test_load_pkey_rsa_public_der
155
- pkey = OpenSSL::PKey::RSA.new(512).public_key
156
- assert_equal(pkey.to_der, OpenSSL::PKey::RSA.new(pkey.to_der).to_der)
157
- end
158
-
159
- # jruby-openssl/0.6 causes NPE
160
- def test_generate_pkey_dsa_empty
161
- assert_nothing_raised do
162
- OpenSSL::PKey::DSA.new.to_pem
163
- end
164
- end
165
-
166
- # jruby-openssl/0.6 ignores fixnum arg => to_pem returned 65 bytes with 'MAA='
167
- def test_generate_pkey_dsa_length
168
- assert(OpenSSL::PKey::DSA.new(512).to_pem.size > 100)
169
- end
170
-
171
- # jruby-openssl/0.6 returns nil for DSA#to_text
172
- def test_generate_pkey_dsa_to_text
173
- assert_match(
174
- /Private-Key: \(512 bit\)/,
175
- OpenSSL::PKey::DSA.new(512).to_text
176
- )
177
- end
178
-
179
- def test_load_pkey_dsa
180
- pkey = OpenSSL::PKey::DSA.new(512)
181
- assert_equal(pkey.to_pem, OpenSSL::PKey::DSA.new(pkey.to_pem).to_pem)
182
- end
183
-
184
- def test_load_pkey_dsa_public
185
- pkey = OpenSSL::PKey::DSA.new(512).public_key
186
- assert_equal(pkey.to_pem, OpenSSL::PKey::DSA.new(pkey.to_pem).to_pem)
187
- end
188
-
189
- def test_load_pkey_dsa_der
190
- pkey = OpenSSL::PKey::DSA.new(512)
191
- assert_equal(pkey.to_der, OpenSSL::PKey::DSA.new(pkey.to_der).to_der)
192
- end
193
-
194
- def test_load_pkey_dsa_public_der
195
- pkey = OpenSSL::PKey::DSA.new(512).public_key
196
- assert_equal(pkey.to_der, OpenSSL::PKey::DSA.new(pkey.to_der).to_der)
197
- end
198
-
199
- def test_load_pkey_dsa_net_ssh
200
- blob = "0\201\367\002\001\000\002A\000\203\316/\037u\272&J\265\003l3\315d\324h\372{\t8\252#\331_\026\006\035\270\266\255\343\353Z\302\276\335\336\306\220\375\202L\244\244J\206>\346\b\315\211\302L\246x\247u\a\376\366\345\302\016#\002\025\000\244\274\302\221Og\275/\302+\356\346\360\024\373wI\2573\361\002@\027\215\270r*\f\213\350C\245\021:\350 \006\\\376\345\022`\210b\262\3643\023XLKS\320\370\002\276\347A\nU\204\276\324\256`=\026\240\330\306J\316V\213\024\e\030\215\355\006\037q\337\356ln\002@\017\257\034\f\260\333'S\271#\237\230E\321\312\027\021\226\331\251Vj\220\305\316\036\v\266+\000\230\270\177B\003?t\a\305]e\344\261\334\023\253\323\251\223M\2175)a(\004\"lI8\312\303\307\a\002\024_\aznW\345\343\203V\326\246ua\203\376\201o\350\302\002"
201
- pkey = OpenSSL::PKey::DSA.new(blob)
202
- assert_equal(blob, pkey.to_der)
203
- end
204
- end