jruby-openssl 0.2.3 → 0.3

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.

Binary file
@@ -1,5 +1,5 @@
1
1
  module Jopenssl
2
2
  module Version
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,23 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIID3DCCAsSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMQswCQYDVQQGEwJVUzEJ
3
+ MAcGA1UECgwAMRkwFwYDVQQLDBBwb2xhcmZveC1sYXB0b3AKMQswCQYDVQQDDAJD
4
+ QTAeFw0wODA0MjkxNTIzNDlaFw0xMzA0MjgxNTIzNDlaMEAxCzAJBgNVBAYTAlVT
5
+ MQkwBwYDVQQKDAAxGTAXBgNVBAsMEHBvbGFyZm94LWxhcHRvcAoxCzAJBgNVBAMM
6
+ AkNBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwUxEs2y3huzcV+Z9
7
+ VqCJ7CZQn3pE25Gmc+mHyrDfjX65hUsfd0oTWMlGGXHTH3kas25rq4s7iznhLJRM
8
+ b4OUAdSjlIdWLQVe/N9i3MuekHKIcNoiKKtN2IDjIdnveMr65p2BaGKPYrwVASWE
9
+ tj2T4tLplfWqUYv1TPJBcpLSt1zxlAeXhUn7z5h1gMrN0YUCWwPnz8gEhnMsmW8n
10
+ Ev5um8niq8cqC1BDtHtYpKgLNJ5TKG7dnsquX9PIe22xVz936Ga20ScS9VU8QYod
11
+ rPjDq9aT4tGqOJVv2HhUPlRqv3pVahxLQoi8fFXOzuCgzYJZFswqo8KijXlQrYfB
12
+ 7sIU0wIDAQABo4HgMIHdMA8GA1UdEwEB/wQFMAMBAf8wMQYJYIZIAYb4QgENBCQW
13
+ IlJ1YnkvT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOA5
14
+ LUlqCS/CSv0hsB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
+ XQySczZnVBzQJv0YjlVJ6guBFtCjnCp8yUaOfIOfOUEgC1hCpjv41tfGDF2+eCiq
9
+ 4gEVB4D7Wy0s0kFf3icuhxSYcZLavpLa3dg8pG5YhoX9a+M+1164cTo+fbIdMUp7
10
+ zrzIVSWPcgPzypjGPj/Vfo3K6B/XygLhxhL3Nf+3UVixLRERk0yBksLqPDsfifkj
11
+ BDzMsD3vI4BteZUsbnae/w+LT3VFP+BrkhTUxvPZMzDlS8KKr50cm9Ubbx1R/beY
12
+ uNPx7YyH8oqt70VAciqKL0G2q9DFAfjpqnLaH2toM0vp6iVG4JmI49DFgrV1AHBb
13
+ hrn1FcmkhATfEFMbnm+hpadQxnMzPh/YB1yg7yiuicrJdTs5CJQPp5H0ES0AQhlg
14
+ dYxGoggTic7T586JIpF9YG1yvrau5kVsbP0kqOfHR6BB7hU1XXvQeIa6GSfZVNZY
15
+ zG6u715WH7hrQoXFAGxF6/wd575M2mLQpOWKRKvE/jrsSQHUy4vryQfozaPwPskx
16
+ r+vXVZp9T5XiGx9Bm9m0wwTYYIRo2b7KsD5rjY0D0ZhemjPhKy6B89Y2NLYxuF8j
17
+ kH0ockiSgexYGvWAkhh/5dxR+zCzqmKI6KFpYPkAfOfuvGqggJ3g2Q==
18
+ -----END RSA PRIVATE KEY-----
@@ -1,3 +1,10 @@
1
+ if defined?(JRUBY_VERSION)
2
+ require "java"
3
+ base = File.join(File.dirname(__FILE__), '..', '..')
4
+ $CLASSPATH << File.join(base, 'pkg', 'classes')
5
+ $CLASSPATH << File.join(base, 'lib', 'bcprov-jdk14-139.jar')
6
+ end
7
+
1
8
  begin
2
9
  require "openssl"
3
10
  rescue LoadError
@@ -0,0 +1,159 @@
1
+ if defined?(JRUBY_VERSION)
2
+ require "java"
3
+ $CLASSPATH << 'pkg/classes'
4
+ $CLASSPATH << 'lib/bcprov-jdk14-139.jar'
5
+ end
6
+ begin
7
+ require "openssl"
8
+ require File.join(File.dirname(__FILE__), "utils.rb")
9
+ rescue LoadError
10
+ end
11
+ require "test/unit"
12
+
13
+ if defined?(OpenSSL)
14
+
15
+ class OpenSSL::TestPKCS7 < Test::Unit::TestCase
16
+ def setup
17
+ @rsa1024 = OpenSSL::TestUtils::TEST_KEY_RSA1024
18
+ @rsa2048 = OpenSSL::TestUtils::TEST_KEY_RSA2048
19
+ ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=CA")
20
+ ee1 = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=EE1")
21
+ ee2 = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=EE2")
22
+
23
+ now = Time.now
24
+ ca_exts = [
25
+ ["basicConstraints","CA:TRUE",true],
26
+ ["keyUsage","keyCertSign, cRLSign",true],
27
+ ["subjectKeyIdentifier","hash",false],
28
+ ["authorityKeyIdentifier","keyid:always",false],
29
+ ]
30
+ @ca_cert = issue_cert(ca, @rsa2048, 1, Time.now, Time.now+3600, ca_exts,
31
+ nil, nil, OpenSSL::Digest::SHA1.new)
32
+ ee_exts = [
33
+ ["keyUsage","Non Repudiation, Digital Signature, Key Encipherment",true],
34
+ ["authorityKeyIdentifier","keyid:always",false],
35
+ ["extendedKeyUsage","clientAuth, emailProtection, codeSigning",false],
36
+ ]
37
+ @ee1_cert = issue_cert(ee1, @rsa1024, 2, Time.now, Time.now+1800, ee_exts,
38
+ @ca_cert, @rsa2048, OpenSSL::Digest::SHA1.new)
39
+ @ee2_cert = issue_cert(ee2, @rsa1024, 3, Time.now, Time.now+1800, ee_exts,
40
+ @ca_cert, @rsa2048, OpenSSL::Digest::SHA1.new)
41
+ end
42
+
43
+ def issue_cert(*args)
44
+ OpenSSL::TestUtils.issue_cert(*args)
45
+ end
46
+
47
+ def test_signed
48
+ store = OpenSSL::X509::Store.new
49
+ store.add_cert(@ca_cert)
50
+ ca_certs = [@ca_cert]
51
+
52
+ data = "aaaaa\r\nbbbbb\r\nccccc\r\n"
53
+ tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs)
54
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
55
+ certs = p7.certificates
56
+ signers = p7.signers
57
+ assert(p7.verify([], store))
58
+ assert_equal(data, p7.data)
59
+ assert_equal(2, certs.size)
60
+ assert_equal(@ee1_cert.subject.to_s, certs[0].subject.to_s)
61
+ assert_equal(@ca_cert.subject.to_s, certs[1].subject.to_s)
62
+ assert_equal(1, signers.size)
63
+ assert_equal(@ee1_cert.serial, signers[0].serial)
64
+ assert_equal(@ee1_cert.issuer.to_s, signers[0].issuer.to_s)
65
+
66
+ # Normaly OpenSSL tries to translate the supplied content into canonical
67
+ # MIME format (e.g. a newline character is converted into CR+LF).
68
+ # If the content is a binary, PKCS7::BINARY flag should be used.
69
+
70
+ data = "aaaaa\nbbbbb\nccccc\n"
71
+ flag = OpenSSL::PKCS7::BINARY
72
+ tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs, flag)
73
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
74
+ certs = p7.certificates
75
+ signers = p7.signers
76
+ assert(p7.verify([], store))
77
+ assert_equal(data, p7.data)
78
+ assert_equal(2, certs.size)
79
+ assert_equal(@ee1_cert.subject.to_s, certs[0].subject.to_s)
80
+ assert_equal(@ca_cert.subject.to_s, certs[1].subject.to_s)
81
+ assert_equal(1, signers.size)
82
+ assert_equal(@ee1_cert.serial, signers[0].serial)
83
+ assert_equal(@ee1_cert.issuer.to_s, signers[0].issuer.to_s)
84
+
85
+ # A signed-data which have multiple signatures can be created
86
+ # through the following steps.
87
+ # 1. create two signed-data
88
+ # 2. copy signerInfo and certificate from one to another
89
+
90
+ tmp1 = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, [], flag)
91
+ tmp2 = OpenSSL::PKCS7.sign(@ee2_cert, @rsa1024, data, [], flag)
92
+ tmp1.add_signer(tmp2.signers[0])
93
+ tmp1.add_certificate(@ee2_cert)
94
+
95
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp1.to_der)
96
+ certs = p7.certificates
97
+ signers = p7.signers
98
+ assert(p7.verify([], store))
99
+ assert_equal(data, p7.data)
100
+ assert_equal(2, certs.size)
101
+ assert_equal(2, signers.size)
102
+ assert_equal(@ee1_cert.serial, signers[0].serial)
103
+ assert_equal(@ee1_cert.issuer.to_s, signers[0].issuer.to_s)
104
+ assert_equal(@ee2_cert.serial, signers[1].serial)
105
+ assert_equal(@ee2_cert.issuer.to_s, signers[1].issuer.to_s)
106
+ end
107
+
108
+ def test_detached_sign
109
+ store = OpenSSL::X509::Store.new
110
+ store.add_cert(@ca_cert)
111
+ ca_certs = [@ca_cert]
112
+
113
+ data = "aaaaa\nbbbbb\nccccc\n"
114
+ flag = OpenSSL::PKCS7::BINARY|OpenSSL::PKCS7::DETACHED
115
+ tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs, flag)
116
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
117
+ a1 = OpenSSL::ASN1.decode(p7)
118
+
119
+ certs = p7.certificates
120
+ signers = p7.signers
121
+ assert(!p7.verify([], store))
122
+ assert(p7.verify([], store, data))
123
+ assert_equal(data, p7.data)
124
+ assert_equal(2, certs.size)
125
+ assert_equal(@ee1_cert.subject.to_s, certs[0].subject.to_s)
126
+ assert_equal(@ca_cert.subject.to_s, certs[1].subject.to_s)
127
+ assert_equal(1, signers.size)
128
+ assert_equal(@ee1_cert.serial, signers[0].serial)
129
+ assert_equal(@ee1_cert.issuer.to_s, signers[0].issuer.to_s)
130
+ end
131
+
132
+ def test_enveloped
133
+ if OpenSSL::OPENSSL_VERSION_NUMBER <= 0x0090704f
134
+ # PKCS7_encrypt() of OpenSSL-0.9.7d goes to SEGV.
135
+ # http://www.mail-archive.com/openssl-dev@openssl.org/msg17376.html
136
+ return
137
+ end
138
+
139
+ certs = [@ee1_cert, @ee2_cert]
140
+ cipher = OpenSSL::Cipher::AES.new("128-CBC")
141
+ data = "aaaaa\nbbbbb\nccccc\n"
142
+
143
+ tmp = OpenSSL::PKCS7.encrypt(certs, data, cipher, OpenSSL::PKCS7::BINARY)
144
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
145
+ recip = p7.recipients
146
+ assert_equal(:enveloped, p7.type)
147
+ assert_equal(2, recip.size)
148
+
149
+ assert_equal(@ca_cert.subject.to_s, recip[0].issuer.to_s)
150
+ assert_equal(2, recip[0].serial)
151
+ assert_equal(data, p7.decrypt(@rsa1024, @ee1_cert))
152
+
153
+ assert_equal(@ca_cert.subject.to_s, recip[1].issuer.to_s)
154
+ assert_equal(3, recip[1].serial)
155
+ assert_equal(data, p7.decrypt(@rsa1024, @ee2_cert))
156
+ end
157
+ end
158
+
159
+ end
@@ -92,8 +92,6 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
92
92
  end
93
93
  block.call(server, port.to_i)
94
94
  end
95
- rescue => e
96
- puts e, *(e.backtrace)
97
95
  ensure
98
96
  if server
99
97
  $stderr.puts "killing: #{pid}" if $DEBUG
@@ -0,0 +1,19 @@
1
+ MIME-Version: 1.0
2
+ Message-Id: <00103112005203.00349@amyemily.ig.com>
3
+ Date: Tue, 31 Oct 2000 12:00:52 -0600 (Central Standard Time)
4
+ From: User1
5
+ To: User2
6
+ Subject: Example 5.3
7
+ Content-Type: application/pkcs7-mime;
8
+ name=smime.p7m;
9
+ smime-type=enveloped-data
10
+ Content-Transfer-Encoding: base64
11
+ Content-Disposition: attachment; filename=smime.p7m
12
+
13
+
14
+ MIIBHgYJKoZIhvcNAQcDoIIBDzCCAQsCAQAxgcAwgb0CAQAwJjASMRAwDgYDVQQDEwdDYXJ
15
+ sUlNBAhBGNGvHgABWvBHTbi7NXXHQMA0GCSqGSIb3DQEBAQUABIGAC3EN5nGIiJi2lsGPcP
16
+ 2iJ97a4e8kbKQz36zg6Z2i0yx6zYC4mZ7mX7FBs3IWg+f6KgCLx3M1eCbWx8+MDFbbpXadC
17
+ DgO8/nUkUNYeNxJtuzubGgzoyEd8Ch4H/dd9gdzTd+taTEgS0ipdSJuNnkVY4/M652jKKHR
18
+ LFf02hosdR8wQwYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAgtaMXpRwZRNYAgDsiSf8Z9P43
19
+ LrY4OxUk660cu1lXeCSFOSOpOJ7FuVyU=
@@ -0,0 +1,30 @@
1
+ MIME-Version: 1.0
2
+ To: User2@examples.com
3
+ From: aliceDss@examples.com
4
+ Subject: Example 4.9
5
+ Message-Id: <021031164540300.304@examples.com>
6
+ Date: Thu, 31 Oct 2002 16:45:14 -0300
7
+ Content-Type: application/pkcs7-mime; smime-type=signed-data;
8
+ name=smime.p7m
9
+ Content-Transfer-Encoding: base64
10
+ Content-Disposition: attachment; filename=smime.p7m
11
+
12
+
13
+ MIIDmQYJKoZIhvcNAQcCoIIDijCCA4YCAQExCTAHBgUrDgMCGjAtBgkqhkiG9w0BBwGgIAQ
14
+ eDQpUaGlzIGlzIHNvbWUgc2FtcGxlIGNvbnRlbnQuoIIC4DCCAtwwggKboAMCAQICAgDIMA
15
+ kGByqGSM44BAMwEjEQMA4GA1UEAxMHQ2FybERTUzAeFw05OTA4MTcwMTEwNDlaFw0zOTEyM
16
+ zEyMzU5NTlaMBMxETAPBgNVBAMTCEFsaWNlRFNTMIIBtjCCASsGByqGSM44BAEwggEeAoGB
17
+ AIGNze2D6gqeOT7CSCij5EeT3Q7XqA7sU8WrhAhP/5Thc0h+DNbzREjR/p+vpKGJL+HZMMg
18
+ 23j+bv7dM3F9piuR10DcMkQiVm96nXvn89J8v3UOoi1TxP7AHCEdNXYjDw7Wz41UIddU5dh
19
+ DEeL3/nbCElzfy5FEbteQJllzzflvbAhUA4kemGkVmuBPG2o+4NyErYov3k80CgYAmONAUi
20
+ TKqOfs+bdlLWWpMdiM5BAI1XPLLGjDDHlBd3ZtZ4s2qBT1YwHuiNrhuB699ikIlp/R1z0oI
21
+ Xks+kPht6pzJIYo7dhTpzi5dowfNI4W4LzABfG1JiRGJNkS9+MiVSlNWteL5c+waYTYfEX/
22
+ Cve3RUP+YdMLRgUpgObo2OQOBhAACgYBc47ladRSWC6l63eM/qeysXty9txMRNKYWiSgRI9
23
+ k0hmd1dRMSPUNbb+VRv/qJ8qIbPiR9PQeNW2PIu0WloErjhdbOBoA/6CN+GvIkq1MauCcNH
24
+ u8Iv2YUgFxirGX6FYvxuzTU0pY39mFHssQyhPB+QUD9RqdjTjPypeL08oPluKOBgTB/MAwG
25
+ A1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgbAMB8GA1UdIwQYMBaAFHBEPoIub4feStN14z0
26
+ gvEMrk/EfMB0GA1UdDgQWBBS+bKGz48H37UNwpM4TAeL945f+zTAfBgNVHREEGDAWgRRBbG
27
+ ljZURTU0BleGFtcGxlLmNvbTAJBgcqhkjOOAQDAzAAMC0CFFUMpBkfQiuJcSIzjYNqtT1na
28
+ 79FAhUAn2FTUlQLXLLd2ud2HeIQUltDXr0xYzBhAgEBMBgwEjEQMA4GA1UEAxMHQ2FybERT
29
+ UwICAMgwBwYFKw4DAhowCQYHKoZIzjgEAwQuMCwCFD1cSW6LIUFzeXle3YI5SKSBer/sAhQ
30
+ mCq7s/CTFHOEjgASeUjbMpx5g6A==
@@ -0,0 +1,45 @@
1
+ MIME-Version: 1.0
2
+ To: User2@examples.com
3
+ From: aliceDss@examples.com
4
+ Subject: Example 4.8
5
+ Message-Id: <020906002550300.249@examples.com>
6
+ Date: Fri, 06 Sep 2002 00:25:21 -0300
7
+ Content-Type: multipart/signed;
8
+ micalg=SHA1;
9
+ boundary="----=_NextBoundry____Fri,_06_Sep_2002_00:25:21";
10
+ protocol="application/pkcs7-signature"
11
+
12
+
13
+ This is a multi-part message in MIME format.
14
+
15
+
16
+ ------=_NextBoundry____Fri,_06_Sep_2002_00:25:21
17
+
18
+ This is some sample content.
19
+
20
+ ------=_NextBoundry____Fri,_06_Sep_2002_00:25:21
21
+ Content-Type: application/pkcs7-mime; name=smime.p7s
22
+ Content-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BFEFsaWNlRFNTQGV4YW1wbGUuY29tMAkGByqGSM44BAMDMAAwLQ
40
+ IUVQykGR9CK4lxIjONg2q1PWdrv0UCFQCfYVNSVAtcst3a53Yd4hBSW0NevTFjMGECAQEwG
41
+ DASMRAwDgYDVQQDEwdDYXJsRFNTAgIAyDAHBgUrDgMCGjAJBgcqhkjOOAQDBC4wLAIUM/mG
42
+ f6gkgp9Z0XtRdGimJeB/BxUCFGFFJqwYRt1WYcIOQoGiaowqGzVI
43
+
44
+
45
+ ------=_NextBoundry____Fri,_06_Sep_2002_00:25:21--
File without changes
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ name = ARGV[0]
4
+ system("rm -rf #{name}")
5
+ system("gcc -lssl -lcrypto -o #{name} #{name}.c")
6
+ system("chmod +x #{name}")
7
+ system("./#{name}")
8
+
Binary file
@@ -0,0 +1,21 @@
1
+
2
+ #include <openssl/pkcs7.h>
3
+
4
+ void print_pkcs7(PKCS7* p7) {
5
+ printf(" | asn1 : %s\n", p7->asn1);
6
+ printf(" | len : %d\n", p7->length);
7
+ printf(" | state : %d\n", p7->state);
8
+ printf(" | detached : %d\n", p7->detached);
9
+ printf(" | type : %d\n", OBJ_nid2obj(p7->type));
10
+ }
11
+
12
+ int main(int argc, char** argv) {
13
+ PKCS7* p7;
14
+ p7 = PKCS7_new();
15
+
16
+ printf("--before:\n");
17
+ print_pkcs7(p7);
18
+
19
+ PKCS7_free(p7);
20
+ return 0;
21
+ }
@@ -1,3 +1,10 @@
1
+ if defined?(JRUBY_VERSION)
2
+ require "java"
3
+ base = File.dirname(__FILE__)
4
+ $CLASSPATH << File.join(base, '..', 'pkg', 'classes')
5
+ $CLASSPATH << File.join(base, '..', 'lib', 'bcprov-jdk14-139.jar')
6
+ end
7
+
1
8
  begin
2
9
  require "openssl"
3
10
  rescue LoadError
@@ -12,4 +19,63 @@ class TestCipher < Test::Unit::TestCase
12
19
  data = enc.update("password")
13
20
  data << enc.final
14
21
  end
22
+
23
+ IV_TEMPLATE = "aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjj"
24
+ KEY_TEMPLATE = "aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjj"
25
+
26
+ # JRUBY-1692
27
+ def test_repeated_des
28
+ do_repeated_test(
29
+ "des-ede3-cbc",
30
+ "foobarbazboofarf",
31
+ ":\022Q\211ex\370\332\374\274\214\356\301\260V\025",
32
+ "B\242\3531\003\362\3759\363s\203\374\240\030|\230"
33
+ )
34
+ end
35
+
36
+ # JRUBY-1692
37
+ def test_repeated_aes
38
+ do_repeated_test(
39
+ "aes-128-cbc",
40
+ "foobarbazboofarf",
41
+ "\342\260Y\344\306\227\004^\272|/\323<\016,\226",
42
+ "jqO\305/\211\216\b\373\300\274\bw\213]\310"
43
+ )
44
+ end
45
+
46
+ private
47
+ def do_repeated_test(algo, string, enc1, enc2)
48
+ do_repeated_encrypt_test(algo, string, enc1, enc2)
49
+ do_repeated_decrypt_test(algo, string, enc1, enc2)
50
+ end
51
+
52
+ def do_repeated_encrypt_test(algo, string, result1, result2)
53
+ cipher = OpenSSL::Cipher::Cipher.new(algo)
54
+ cipher.encrypt
55
+
56
+ cipher.padding = 0
57
+ cipher.iv = IV_TEMPLATE[0, cipher.iv_len]
58
+ cipher.key = KEY_TEMPLATE[0, cipher.key_len]
59
+
60
+ assert_equal result1, cipher.update(string)
61
+ cipher.final
62
+
63
+ assert_equal result2, cipher.update(string)
64
+ cipher.final
65
+ end
66
+
67
+ def do_repeated_decrypt_test(algo, result, string1, string2)
68
+ cipher = OpenSSL::Cipher::Cipher.new(algo)
69
+ cipher.decrypt
70
+
71
+ cipher.padding = 0
72
+ cipher.iv = IV_TEMPLATE[0, cipher.iv_len]
73
+ cipher.key = KEY_TEMPLATE[0, cipher.key_len]
74
+
75
+ assert_equal result, cipher.update(string1)
76
+ cipher.final
77
+
78
+ assert_equal result, cipher.update(string2)
79
+ cipher.final
80
+ end
15
81
  end