diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-05-11 09:37:30 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-05-11 09:37:30 +0400 |
commit | 074506403ef3d21d5dd4a37f705cdbb28ba6075c (patch) | |
tree | b44ebc40e56848df09aeb1f5078a4782a3a611fb | |
parent | 02f669b3f094e0e57a20ca2beec249f0c390042c (diff) |
added support for 14 byte keys
-rw-r--r-- | src/main/java/org/bouncycastle/crypto/engines/DESedeEngine.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/org/bouncycastle/crypto/engines/DESedeEngine.java b/src/main/java/org/bouncycastle/crypto/engines/DESedeEngine.java index f6941e3c..69861d0a 100644 --- a/src/main/java/org/bouncycastle/crypto/engines/DESedeEngine.java +++ b/src/main/java/org/bouncycastle/crypto/engines/DESedeEngine.java @@ -47,9 +47,10 @@ public class DESedeEngine if (keyMaster.length != 24 && keyMaster.length != 16) { - // new style 3TDEA key without parity bits. + if (keyMaster.length == 21) { + // new style 3TDEA key without parity bits. byte[] tmp = new byte[24]; padKey(keyMaster, 0, tmp, 0); @@ -58,9 +59,19 @@ public class DESedeEngine keyMaster = tmp; } + else if (keyMaster.length == 14) + { + // new style 2TDEA key without parity bits. + byte[] tmp = new byte[16]; + + padKey(keyMaster, 0, tmp, 0); + padKey(keyMaster, 7, tmp, 8); + + keyMaster = tmp; + } else { - throw new IllegalArgumentException("key size must be 16, 21, or 24 bytes."); + throw new IllegalArgumentException("key size must be 14, 16, 21, or 24 bytes."); } } |