Skip to content

Commit 031f953

Browse files
committed
REVERT d32ed55 as it introduced a (more serious) encrypt/decrypt failure
1 parent e63aedd commit 031f953

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/main/java/org/jruby/ext/openssl/Cipher.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,12 +1088,12 @@ public IRubyObject update(final ThreadContext context, final IRubyObject arg) {
10881088
if ( out != null ) {
10891089
str = new ByteList(out, false);
10901090
if ( realIV != null ) setLastIVIfNeeded( encryptMode ? out : data );
1091+
1092+
processedDataBytes += data.length;
10911093
}
10921094
else {
10931095
str = new ByteList(ByteList.NULL_ARRAY);
10941096
}
1095-
1096-
processedDataBytes += data.length;
10971097
}
10981098
catch (Exception e) {
10991099
debugStackTrace( runtime, e );
@@ -1132,12 +1132,12 @@ public IRubyObject do_final(final ThreadContext context) {
11321132
str = new ByteList(ByteList.NULL_ARRAY);
11331133
}
11341134

1135-
if ( ! isStreamCipher() ) {
1136-
if ( str.length() > processedDataBytes ) {
1135+
//if ( ! isStreamCipher() ) {
1136+
//if ( str.length() > processedDataBytes && processedDataBytes > 0 ) {
11371137
// MRI compatibility only trailing bytes :
1138-
str.setRealSize(processedDataBytes);
1139-
}
1140-
}
1138+
//str.setRealSize(processedDataBytes);
1139+
//}
1140+
//}
11411141

11421142
if (realIV != null) {
11431143
realIV = lastIV;

src/test/ruby/test_cipher.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def test_encrypt_decrypt_des_ede3 # borrowed from OpenSSL suite
8282
c2.encrypt.pkcs5_keyivgen(key, iv)
8383
s1 = c1.update(data) + c1.final
8484
s2 = c2.update(data) + c2.final
85+
assert_equal "\xC5q\x99)\x81\xE6\xE7\x06", s1
8586
assert_equal(s1, s2, "encrypt")
8687

8788
c1.decrypt.pkcs5_keyivgen(key, iv)
@@ -185,8 +186,8 @@ def test_encrypt_aes_cfb_4_incompatibility
185186
expected = "f0@\x02" # from MRI
186187
actual = cipher.update(bytes)
187188
if jruby? # NOTE: ugly but this is as far as JCE gets us :
188-
#assert_equal expected, actual
189-
assert_equal expected, cipher.final
189+
##assert_equal expected, actual
190+
#assert_equal expected, cipher.final
190191
else
191192
assert_equal expected, actual
192193
assert_equal "", cipher.final
@@ -203,8 +204,8 @@ def test_encrypt_aes_cfb_16_incompatibility
203204
expected = "f0@\x02\xF6\xA8\xC2\rt\xCC\x83\x8F8e\x19R" # from MRI
204205
actual = cipher.update(bytes)
205206
if jruby? # NOTE: ugly but this is as far as JCE gets us :
206-
#assert_equal expected, actual
207-
assert_equal expected, cipher.final
207+
##assert_equal expected, actual
208+
#assert_equal expected, cipher.final
208209
else
209210
assert_equal expected, actual
210211
assert_equal "", cipher.final

0 commit comments

Comments
 (0)