Title: [1110] trunk/jopenssl: Fix JRUBY-1194.
- Revision
- 1110
- Author
- olabini
- Date
- 2008-08-12 11:54:11 -0400 (Tue, 12 Aug 2008)
Log Message
Fix JRUBY-1194. CBC should be the default, not EBC. Dummy Ola.
Modified Paths
Diff
Modified: trunk/jopenssl/src/java/org/jruby/ext/openssl/Cipher.java (1109 => 1110)
--- trunk/jopenssl/src/java/org/jruby/ext/openssl/Cipher.java 2008-08-12 15:28:58 UTC (rev 1109)
+++ trunk/jopenssl/src/java/org/jruby/ext/openssl/Cipher.java 2008-08-12 15:54:11 UTC (rev 1110)
@@ -143,7 +143,7 @@
if(split.length == 2) {
cryptoMode = split[1];
} else {
- cryptoMode = "ECB";
+ cryptoMode = "CBC";
}
}
@@ -393,7 +393,7 @@
} catch(Exception e) {}
if(args.length > 1 && !args[1].isNil()) {
- getRuntime().getWarnings().warn(ID.MISCELLANEOUS, "key derivation by " + getMetaClass().getRealClass().getName() + "#encrypt is deprecated; use " + getMetaClass().getRealClass().getName() + "::pkcs5_keyivgen instead");
+ getRuntime().getWarnings().warning(ID.MISCELLANEOUS, "key derivation by " + getMetaClass().getRealClass().getName() + "#encrypt is deprecated; use " + getMetaClass().getRealClass().getName() + "::pkcs5_keyivgen instead");
iv = args[1].convertToString().getBytes();
if(iv.length > this.ivLen) {
byte[] iv2 = new byte[this.ivLen];
Modified: trunk/jopenssl/test/test_integration.rb (1109 => 1110)
--- trunk/jopenssl/test/test_integration.rb 2008-08-12 15:28:58 UTC (rev 1109)
+++ trunk/jopenssl/test/test_integration.rb 2008-08-12 15:54:11 UTC (rev 1110)
@@ -40,4 +40,23 @@
assert s.get(uri.request_uri).length > 0
end
end
+
+ # JRUBY-1194
+ def test_des_encryption
+ iv = "IVIVIVIV"
+ key = "KEYKEYKE"
+ alg = "des"
+ str = "string abc foo bar baxz"
+
+ cipher = OpenSSL::Cipher::Cipher.new(alg)
+ cipher.encrypt(key, iv)
+ cipher.padding = 32
+ cipher.key = key
+ cipher.iv = iv
+
+ encrypted = cipher.update(str)
+ encrypted << cipher.final
+
+ assert_equal "\253\305\306\372;\374\235\302\357/\006\360\355XO\232\312S\356* #\227\217", encrypted
+ end
end
Modified: trunk/jopenssl/test/test_openssl.rb (1109 => 1110)
--- trunk/jopenssl/test/test_openssl.rb 2008-08-12 15:28:58 UTC (rev 1109)
+++ trunk/jopenssl/test/test_openssl.rb 2008-08-12 15:54:11 UTC (rev 1110)
@@ -30,3 +30,4 @@
protect_require 'openssl/test_x509store'
protect_require 'test_cipher'
protect_require 'test_java'
+protect_require 'test_integration'
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel