You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/06/21 10:13:48 UTC

commons-crypto git commit: CRYPTO-85 CryptoCipher ENCRYPT_MODE and DECRYPT_MODE are unnecessary and confusing

Repository: commons-crypto
Updated Branches:
  refs/heads/master 4a1c90234 -> 0acc3423a


CRYPTO-85 CryptoCipher ENCRYPT_MODE and DECRYPT_MODE are unnecessary and
confusing

JceCipher uses the javax.crypto.Cipher modes; no need to convert the
input

Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/0acc3423
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/0acc3423
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/0acc3423

Branch: refs/heads/master
Commit: 0acc3423a36fc2fefbe14ea4ab857e6af6291e63
Parents: 4a1c902
Author: Sebb <se...@apache.org>
Authored: Tue Jun 21 11:13:44 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Tue Jun 21 11:13:44 2016 +0100

----------------------------------------------------------------------
 src/main/java/org/apache/commons/crypto/cipher/JceCipher.java | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/0acc3423/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
index 2098b43..e39ef0a 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
@@ -88,11 +88,8 @@ public class JceCipher implements CryptoCipher {
         Utils.checkNotNull(key);
         Utils.checkNotNull(params);
 
-        int cipherMode = Cipher.DECRYPT_MODE;
-        if (mode == Cipher.ENCRYPT_MODE) {
-            cipherMode = Cipher.ENCRYPT_MODE;
-        }
-        cipher.init(cipherMode, key, params);
+        // Jce uses the javax.crypto.Cipher modes; no need to convert the input
+        cipher.init(mode, key, params);
     }
 
     /**