jruby-openssl 0.8.0.pre3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/Manifest.txt +5 -124
  2. data/Rakefile +3 -3
  3. data/lib/shared/jopenssl.jar +0 -0
  4. data/lib/shared/jopenssl/version.rb +1 -1
  5. metadata +10 -116
  6. data/test/1.8/ssl_server.rb +0 -99
  7. data/test/1.8/test_asn1.rb +0 -212
  8. data/test/1.8/test_cipher.rb +0 -193
  9. data/test/1.8/test_config.rb +0 -290
  10. data/test/1.8/test_digest.rb +0 -88
  11. data/test/1.8/test_ec.rb +0 -128
  12. data/test/1.8/test_hmac.rb +0 -46
  13. data/test/1.8/test_ns_spki.rb +0 -59
  14. data/test/1.8/test_pair.rb +0 -149
  15. data/test/1.8/test_pkcs7.rb +0 -489
  16. data/test/1.8/test_pkey_rsa.rb +0 -49
  17. data/test/1.8/test_ssl.rb +0 -1032
  18. data/test/1.8/test_x509cert.rb +0 -277
  19. data/test/1.8/test_x509crl.rb +0 -253
  20. data/test/1.8/test_x509ext.rb +0 -99
  21. data/test/1.8/test_x509name.rb +0 -290
  22. data/test/1.8/test_x509req.rb +0 -195
  23. data/test/1.8/test_x509store.rb +0 -246
  24. data/test/1.8/utils.rb +0 -144
  25. data/test/1.9/ssl_server.rb +0 -81
  26. data/test/1.9/test_asn1.rb +0 -589
  27. data/test/1.9/test_bn.rb +0 -23
  28. data/test/1.9/test_buffering.rb +0 -88
  29. data/test/1.9/test_cipher.rb +0 -107
  30. data/test/1.9/test_config.rb +0 -288
  31. data/test/1.9/test_digest.rb +0 -118
  32. data/test/1.9/test_engine.rb +0 -15
  33. data/test/1.9/test_hmac.rb +0 -32
  34. data/test/1.9/test_ns_spki.rb +0 -50
  35. data/test/1.9/test_ocsp.rb +0 -47
  36. data/test/1.9/test_pair.rb +0 -257
  37. data/test/1.9/test_pkcs12.rb +0 -209
  38. data/test/1.9/test_pkcs7.rb +0 -156
  39. data/test/1.9/test_pkey_dh.rb +0 -72
  40. data/test/1.9/test_pkey_dsa.rb +0 -224
  41. data/test/1.9/test_pkey_ec.rb +0 -182
  42. data/test/1.9/test_pkey_rsa.rb +0 -244
  43. data/test/1.9/test_ssl.rb +0 -499
  44. data/test/1.9/test_ssl_session.rb +0 -327
  45. data/test/1.9/test_x509cert.rb +0 -217
  46. data/test/1.9/test_x509crl.rb +0 -221
  47. data/test/1.9/test_x509ext.rb +0 -69
  48. data/test/1.9/test_x509name.rb +0 -366
  49. data/test/1.9/test_x509req.rb +0 -150
  50. data/test/1.9/test_x509store.rb +0 -229
  51. data/test/1.9/utils.rb +0 -304
  52. data/test/cert_with_ec_pk.cer +0 -27
  53. data/test/fixture/ca-bundle.crt +0 -2794
  54. data/test/fixture/ca_path/72fa7371.0 +0 -19
  55. data/test/fixture/ca_path/verisign.pem +0 -19
  56. data/test/fixture/cacert.pem +0 -23
  57. data/test/fixture/cert_localhost.pem +0 -19
  58. data/test/fixture/common.pem +0 -48
  59. data/test/fixture/ids_in_subject_rdn_set.pem +0 -31
  60. data/test/fixture/imaps/cacert.pem +0 -60
  61. data/test/fixture/imaps/server.crt +0 -61
  62. data/test/fixture/imaps/server.key +0 -15
  63. data/test/fixture/key_then_cert.pem +0 -34
  64. data/test/fixture/keypair.pem +0 -27
  65. data/test/fixture/localhost_keypair.pem +0 -18
  66. data/test/fixture/max.pem +0 -29
  67. data/test/fixture/purpose/b70a5bc1.0 +0 -24
  68. data/test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234 +0 -0
  69. data/test/fixture/purpose/ca/ca_config.rb +0 -37
  70. data/test/fixture/purpose/ca/cacert.pem +0 -24
  71. data/test/fixture/purpose/ca/newcerts/2_cert.pem +0 -19
  72. data/test/fixture/purpose/ca/newcerts/3_cert.pem +0 -19
  73. data/test/fixture/purpose/ca/newcerts/4_cert.pem +0 -19
  74. data/test/fixture/purpose/ca/private/cakeypair.pem +0 -30
  75. data/test/fixture/purpose/ca/serial +0 -1
  76. data/test/fixture/purpose/cacert.pem +0 -24
  77. data/test/fixture/purpose/scripts/gen_cert.rb +0 -127
  78. data/test/fixture/purpose/scripts/gen_csr.rb +0 -50
  79. data/test/fixture/purpose/scripts/init_ca.rb +0 -66
  80. data/test/fixture/purpose/sslclient.pem +0 -19
  81. data/test/fixture/purpose/sslclient/csr.pem +0 -10
  82. data/test/fixture/purpose/sslclient/keypair.pem +0 -15
  83. data/test/fixture/purpose/sslclient/sslclient.pem +0 -19
  84. data/test/fixture/purpose/sslserver.pem +0 -19
  85. data/test/fixture/purpose/sslserver/csr.pem +0 -10
  86. data/test/fixture/purpose/sslserver/keypair.pem +0 -15
  87. data/test/fixture/purpose/sslserver/sslserver.pem +0 -19
  88. data/test/fixture/purpose/sslserver_no_dsig_in_keyUsage.pem +0 -19
  89. data/test/fixture/selfcert.pem +0 -23
  90. data/test/fixture/verisign.pem +0 -19
  91. data/test/fixture/verisign_c3.pem +0 -14
  92. data/test/ref/a.out +0 -0
  93. data/test/ref/compile.rb +0 -8
  94. data/test/ref/pkcs1 +0 -0
  95. data/test/ref/pkcs1.c +0 -21
  96. data/test/ruby/envutil.rb +0 -208
  97. data/test/ruby/ut_eof.rb +0 -128
  98. data/test/test_all.rb +0 -1
  99. data/test/test_certificate.rb +0 -132
  100. data/test/test_cipher.rb +0 -197
  101. data/test/test_imaps.rb +0 -107
  102. data/test/test_integration.rb +0 -144
  103. data/test/test_openssl.rb +0 -4
  104. data/test/test_parse_certificate.rb +0 -27
  105. data/test/test_pkcs7.rb +0 -56
  106. data/test/test_pkey_dsa.rb +0 -180
  107. data/test/test_pkey_rsa.rb +0 -329
  108. data/test/test_ssl.rb +0 -97
  109. data/test/test_x509store.rb +0 -168
@@ -1,88 +0,0 @@
1
- begin
2
- require "openssl"
3
- rescue LoadError
4
- end
5
- require "digest/md5"
6
- require "test/unit"
7
-
8
- if defined?(OpenSSL)
9
-
10
- class OpenSSL::TestDigest < Test::Unit::TestCase
11
- def setup
12
- @d1 = OpenSSL::Digest::Digest::new("MD5")
13
- @d2 = OpenSSL::Digest::MD5.new
14
- @md = Digest::MD5.new
15
- @data = "DATA"
16
- end
17
-
18
- def teardown
19
- @d1 = @d2 = @md = nil
20
- end
21
-
22
- def test_digest
23
- assert_equal(@md.digest, @d1.digest)
24
- assert_equal(@md.hexdigest, @d1.hexdigest)
25
- @d1 << @data
26
- @d2 << @data
27
- @md << @data
28
- assert_equal(@md.digest, @d1.digest)
29
- assert_equal(@md.hexdigest, @d1.hexdigest)
30
- assert_equal(@d1.digest, @d2.digest)
31
- assert_equal(@d1.hexdigest, @d2.hexdigest)
32
- assert_equal(@md.digest, OpenSSL::Digest::MD5.digest(@data))
33
- assert_equal(@md.hexdigest, OpenSSL::Digest::MD5.hexdigest(@data))
34
- end
35
-
36
- def test_eql
37
- assert(@d1 == @d2, "==")
38
- d = @d1.clone
39
- assert(d == @d1, "clone")
40
- end
41
-
42
- def test_info
43
- assert_equal("MD5", @d1.name, "name")
44
- assert_equal("MD5", @d2.name, "name")
45
- assert_equal(16, @d1.size, "size")
46
- end
47
-
48
- def test_dup
49
- @d1.update(@data)
50
- assert_equal(@d1.name, @d1.dup.name, "dup")
51
- assert_equal(@d1.name, @d1.clone.name, "clone")
52
- assert_equal(@d1.digest, @d1.clone.digest, "clone .digest")
53
- end
54
-
55
- def test_reset
56
- @d1.update(@data)
57
- dig1 = @d1.digest
58
- @d1.reset
59
- @d1.update(@data)
60
- dig2 = @d1.digest
61
- assert_equal(dig1, dig2, "reset")
62
- end
63
-
64
- if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000
65
- def encode16(str)
66
- str.unpack("H*").first
67
- end
68
-
69
- def test_098_features
70
- sha224_a = "abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5"
71
- sha256_a = "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb"
72
- sha384_a = "54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31"
73
- sha512_a = "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75"
74
-
75
- assert_equal(sha224_a, OpenSSL::Digest::SHA224.hexdigest("a"))
76
- assert_equal(sha256_a, OpenSSL::Digest::SHA256.hexdigest("a"))
77
- assert_equal(sha384_a, OpenSSL::Digest::SHA384.hexdigest("a"))
78
- assert_equal(sha512_a, OpenSSL::Digest::SHA512.hexdigest("a"))
79
-
80
- assert_equal(sha224_a, encode16(OpenSSL::Digest::SHA224.digest("a")))
81
- assert_equal(sha256_a, encode16(OpenSSL::Digest::SHA256.digest("a")))
82
- assert_equal(sha384_a, encode16(OpenSSL::Digest::SHA384.digest("a")))
83
- assert_equal(sha512_a, encode16(OpenSSL::Digest::SHA512.digest("a")))
84
- end
85
- end
86
- end
87
-
88
- end
@@ -1,128 +0,0 @@
1
- begin
2
- require "openssl"
3
- require File.join(File.dirname(__FILE__), "utils.rb")
4
- rescue LoadError
5
- end
6
- require "test/unit"
7
-
8
- if defined?(OpenSSL::PKey::EC)
9
-
10
- class OpenSSL::TestEC < Test::Unit::TestCase
11
- def setup
12
- @data1 = 'foo'
13
- @data2 = 'bar' * 1000 # data too long for DSA sig
14
-
15
- @group1 = OpenSSL::PKey::EC::Group.new('secp112r1')
16
- @group2 = OpenSSL::PKey::EC::Group.new('sect163k1')
17
-
18
- @key1 = OpenSSL::PKey::EC.new
19
- @key1.group = @group1
20
- @key1.generate_key
21
-
22
- @key2 = OpenSSL::PKey::EC.new(@group2.curve_name)
23
- @key2.generate_key
24
-
25
- @groups = [@group1, @group2]
26
- @keys = [@key1, @key2]
27
- end
28
-
29
- def compare_keys(k1, k2)
30
- assert_equal(k1.to_pem, k2.to_pem)
31
- end
32
-
33
- def test_curve_names
34
- @groups.each_with_index do |group, idx|
35
- key = @keys[idx]
36
- assert_equal(group.curve_name, key.group.curve_name)
37
- end
38
- end
39
-
40
- def test_check_key
41
- for key in @keys
42
- assert_equal(key.check_key, true)
43
- assert_equal(key.private_key?, true)
44
- assert_equal(key.public_key?, true)
45
- end
46
- end
47
-
48
- def test_encoding
49
- for group in @groups
50
- for meth in [:to_der, :to_pem]
51
- txt = group.send(meth)
52
- gr = OpenSSL::PKey::EC::Group.new(txt)
53
- assert_equal(txt, gr.send(meth))
54
-
55
- assert_equal(group.generator.to_bn, gr.generator.to_bn)
56
- assert_equal(group.cofactor, gr.cofactor)
57
- assert_equal(group.order, gr.order)
58
- assert_equal(group.seed, gr.seed)
59
- assert_equal(group.degree, gr.degree)
60
- end
61
- end
62
-
63
- for key in @keys
64
- group = key.group
65
-
66
- for meth in [:to_der, :to_pem]
67
- txt = key.send(meth)
68
- assert_equal(txt, OpenSSL::PKey::EC.new(txt).send(meth))
69
- end
70
-
71
- bn = key.public_key.to_bn
72
- assert_equal(bn, OpenSSL::PKey::EC::Point.new(group, bn).to_bn)
73
- end
74
- end
75
-
76
- def test_set_keys
77
- for key in @keys
78
- k = OpenSSL::PKey::EC.new
79
- k.group = key.group
80
- k.private_key = key.private_key
81
- k.public_key = key.public_key
82
-
83
- compare_keys(key, k)
84
- end
85
- end
86
-
87
- def test_dsa_sign_verify
88
- for key in @keys
89
- sig = key.dsa_sign_asn1(@data1)
90
- assert(key.dsa_verify_asn1(@data1, sig))
91
- end
92
- end
93
-
94
- def test_dsa_sign_asn1_FIPS186_3
95
- for key in @keys
96
- size = key.group.order.num_bits / 8 + 1
97
- dgst = (1..size).to_a.pack('C*')
98
- begin
99
- sig = key.dsa_sign_asn1(dgst)
100
- # dgst is auto-truncated according to FIPS186-3 after openssl-0.9.8m
101
- assert(key.dsa_verify_asn1(dgst + "garbage", sig))
102
- rescue OpenSSL::PKey::ECError => e
103
- # just an exception for longer dgst before openssl-0.9.8m
104
- assert_equal('ECDSA_sign: data too large for key size', e.message)
105
- # no need to do following tests
106
- return
107
- end
108
- end
109
- end
110
-
111
- def test_dh_compute_key
112
- for key in @keys
113
- k = OpenSSL::PKey::EC.new(key.group)
114
- k.generate_key
115
-
116
- puba = key.public_key
117
- pubb = k.public_key
118
- a = key.dh_compute_key(pubb)
119
- b = k.dh_compute_key(puba)
120
- assert_equal(a, b)
121
- end
122
- end
123
-
124
- # test Group: asn1_flag, point_conversion
125
-
126
- end
127
-
128
- end
@@ -1,46 +0,0 @@
1
- begin
2
- require "openssl"
3
- rescue LoadError
4
- end
5
- require "test/unit"
6
-
7
- class OpenSSL::TestHMAC < Test::Unit::TestCase
8
- def setup
9
- @digest = OpenSSL::Digest::MD5
10
- @key = "KEY"
11
- @data = "DATA"
12
- @h1 = OpenSSL::HMAC.new(@key, @digest.new)
13
- @h2 = OpenSSL::HMAC.new(@key, "MD5")
14
- end
15
-
16
- def teardown
17
- end
18
-
19
- def test_hmac
20
- @h1.update(@data)
21
- @h2.update(@data)
22
- assert_equal(@h1.digest, @h2.digest)
23
-
24
- assert_equal(OpenSSL::HMAC.digest(@digest.new, @key, @data), @h1.digest, "digest")
25
- assert_equal(OpenSSL::HMAC.hexdigest(@digest.new, @key, @data), @h1.hexdigest, "hexdigest")
26
-
27
- assert_equal(OpenSSL::HMAC.digest("MD5", @key, @data), @h2.digest, "digest")
28
- assert_equal(OpenSSL::HMAC.hexdigest("MD5", @key, @data), @h2.hexdigest, "hexdigest")
29
- end
30
-
31
- def test_dup
32
- @h1.update(@data)
33
- h = @h1.dup
34
- assert_equal(@h1.digest, h.digest, "dup digest")
35
- end
36
-
37
- def test_sha256
38
- digest256 = OpenSSL::Digest::Digest.new("sha256")
39
- assert_equal(
40
- "\210\236-\3270\331Yq\265\177sE\266\231hXa\332\250\026\235O&c*\307\001\227~\260n\362",
41
- OpenSSL::HMAC.digest(digest256, 'blah', "blah"))
42
- assert_equal(
43
- "889e2dd730d95971b57f7345b699685861daa8169d4f26632ac701977eb06ef2",
44
- OpenSSL::HMAC.hexdigest(digest256, 'blah', "blah"))
45
- end
46
- end
@@ -1,59 +0,0 @@
1
- begin
2
- require "openssl"
3
- require File.join(File.dirname(__FILE__), "utils.rb")
4
- rescue LoadError
5
- end
6
- require "test/unit"
7
-
8
- if defined?(OpenSSL)
9
-
10
-
11
- class OpenSSL::TestNSSPI < Test::Unit::TestCase
12
- def setup
13
- # This request data is adopt from the specification of
14
- # "Netscape Extensions for User Key Generation".
15
- # -- http://wp.netscape.com/eng/security/comm4-keygen.html
16
- @b64 = "MIHFMHEwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAnX0TILJrOMUue+PtwBRE6XfV"
17
- @b64 << "WtKQbsshxk5ZhcUwcwyvcnIq9b82QhJdoACdD34rqfCAIND46fXKQUnb0mvKzQID"
18
- @b64 << "AQABFhFNb3ppbGxhSXNNeUZyaWVuZDANBgkqhkiG9w0BAQQFAANBAAKv2Eex2n/S"
19
- @b64 << "r/7iJNroWlSzSMtTiQTEB+ADWHGj9u1xrUrOilq/o2cuQxIfZcNZkYAkWP4DubqW"
20
- @b64 << "i0//rgBvmco="
21
- end
22
-
23
- def teardown
24
- end
25
-
26
- def test_build_data
27
- key1 = OpenSSL::TestUtils::TEST_KEY_RSA1024
28
- key2 = OpenSSL::TestUtils::TEST_KEY_RSA2048
29
- spki = OpenSSL::Netscape::SPKI.new
30
- spki.challenge = "RandomString"
31
- spki.public_key = key1.public_key
32
- spki.sign(key1, OpenSSL::Digest::SHA1.new)
33
- assert(spki.verify(spki.public_key))
34
- assert(spki.verify(key1.public_key))
35
- assert(!spki.verify(key2.public_key))
36
-
37
- der = spki.to_der
38
- spki = OpenSSL::Netscape::SPKI.new(der)
39
- assert_equal("RandomString", spki.challenge)
40
- assert_equal(key1.public_key.to_der, spki.public_key.to_der)
41
- assert(spki.verify(spki.public_key))
42
- end
43
-
44
- def test_decode_data
45
- spki = OpenSSL::Netscape::SPKI.new(@b64)
46
- assert_equal(@b64, spki.to_pem)
47
- assert_equal(@b64.unpack("m").first, spki.to_der)
48
- assert_equal("MozillaIsMyFriend", spki.challenge)
49
- assert_equal(OpenSSL::PKey::RSA, spki.public_key.class)
50
-
51
- spki = OpenSSL::Netscape::SPKI.new(@b64.unpack("m").first)
52
- assert_equal(@b64, spki.to_pem)
53
- assert_equal(@b64.unpack("m").first, spki.to_der)
54
- assert_equal("MozillaIsMyFriend", spki.challenge)
55
- assert_equal(OpenSSL::PKey::RSA, spki.public_key.class)
56
- end
57
- end
58
-
59
- end
@@ -1,149 +0,0 @@
1
- begin
2
- require "openssl"
3
- rescue LoadError
4
- end
5
- require 'test/unit'
6
-
7
- if defined?(OpenSSL)
8
-
9
- require 'socket'
10
- require File.join(File.dirname(__FILE__), "../ut_eof")
11
-
12
- module SSLPair
13
- def server
14
- host = "127.0.0.1"
15
- port = 0
16
- ctx = OpenSSL::SSL::SSLContext.new()
17
- ctx.ciphers = "ADH"
18
- tcps = TCPServer.new(host, port)
19
- ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
20
- return ssls
21
- end
22
-
23
- def client(port)
24
- host = "127.0.0.1"
25
- ctx = OpenSSL::SSL::SSLContext.new()
26
- ctx.ciphers = "ADH"
27
- s = TCPSocket.new(host, port)
28
- ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
29
- ssl.connect
30
- ssl.sync_close = true
31
- ssl
32
- end
33
-
34
- def ssl_pair
35
- ssls = server
36
- th = Thread.new {
37
- ns = ssls.accept
38
- ssls.close
39
- ns
40
- }
41
- port = ssls.to_io.addr[1]
42
- c = client(port)
43
- s = th.value
44
- if block_given?
45
- begin
46
- yield c, s
47
- ensure
48
- c.close unless c.closed?
49
- s.close unless s.closed?
50
- end
51
- else
52
- return c, s
53
- end
54
- end
55
- end
56
-
57
- class OpenSSL::TestEOF1 < Test::Unit::TestCase
58
- include TestEOF
59
- include SSLPair
60
-
61
- def open_file(content)
62
- s1, s2 = ssl_pair
63
- Thread.new { s2 << content; s2.close }
64
- yield s1
65
- end
66
- end
67
-
68
- class OpenSSL::TestEOF2 < Test::Unit::TestCase
69
- include TestEOF
70
- include SSLPair
71
-
72
- def open_file(content)
73
- s1, s2 = ssl_pair
74
- Thread.new { s1 << content; s1.close }
75
- yield s2
76
- end
77
- end
78
-
79
- class OpenSSL::TestPair < Test::Unit::TestCase
80
- include SSLPair
81
-
82
- def test_getc
83
- ssl_pair {|s1, s2|
84
- s1 << "a"
85
- assert_equal(?a, s2.getc)
86
- }
87
- end
88
-
89
- def test_readpartial
90
- ssl_pair {|s1, s2|
91
- s2.write "a\nbcd"
92
- assert_equal("a\n", s1.gets)
93
- read = s1.readpartial(10)
94
- assert_equal("bcd"[0, read.bytesize], read)
95
- s1.read(read.bytesize - 3) # drop unread bytes
96
-
97
- s2.write "efg"
98
- read = s1.readpartial(10)
99
- assert_equal("efg"[0, read.bytesize], read)
100
- rest = 3 - read.bytesize
101
- while rest > 0
102
- rest -= s1.readpartial(rest).size
103
- end
104
- s2.close
105
- assert_raise(EOFError) { s1.readpartial(10) }
106
- assert_raise(EOFError) { s1.readpartial(10) }
107
- assert_equal("", s1.readpartial(0))
108
- }
109
- end
110
-
111
- def test_readall
112
- ssl_pair {|s1, s2|
113
- s2.close
114
- assert_equal("", s1.read)
115
- }
116
- end
117
-
118
- def test_readline
119
- ssl_pair {|s1, s2|
120
- s2.close
121
- assert_raise(EOFError) { s1.readline }
122
- }
123
- end
124
-
125
- def test_puts_meta
126
- ssl_pair {|s1, s2|
127
- begin
128
- old = $/
129
- $/ = '*'
130
- s1.puts 'a'
131
- ensure
132
- $/ = old
133
- end
134
- s1.close
135
- assert_equal("a\n", s2.read)
136
- }
137
- end
138
-
139
- def test_puts_empty
140
- ssl_pair {|s1, s2|
141
- s1.puts
142
- s1.close
143
- assert_equal("\n", s2.read)
144
- }
145
- end
146
-
147
- end
148
-
149
- end