diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-06-21 07:16:24 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-06-21 07:16:24 +0400 |
commit | 511c65cf61d57ebb7625ac263e13d17fafaf17e5 (patch) | |
tree | e95d5d68be28a8c4fb88cc8ce6503b298c5384d8 /core/src/main/java/org/bouncycastle/crypto | |
parent | 4aa2249d804f7046ede210ab2cd89df904b59581 (diff) |
Allow GCM tag lengths down to 32 bits
As requested by https://github.com/bcgit/bc-java/pull/69
Diffstat (limited to 'core/src/main/java/org/bouncycastle/crypto')
-rw-r--r-- | core/src/main/java/org/bouncycastle/crypto/modes/GCMBlockCipher.java | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/modes/GCMBlockCipher.java b/core/src/main/java/org/bouncycastle/crypto/modes/GCMBlockCipher.java index 4094dc59..5b0a220e 100644 --- a/core/src/main/java/org/bouncycastle/crypto/modes/GCMBlockCipher.java +++ b/core/src/main/java/org/bouncycastle/crypto/modes/GCMBlockCipher.java @@ -98,7 +98,7 @@ public class GCMBlockCipher initialAssociatedText = param.getAssociatedText(); int macSizeBits = param.getMacSize(); - if (macSizeBits < 96 || macSizeBits > 128 || macSizeBits % 8 != 0) + if (macSizeBits < 32 || macSizeBits > 128 || macSizeBits % 8 != 0) { throw new IllegalArgumentException("Invalid value for MAC size: " + macSizeBits); } @@ -128,9 +128,7 @@ public class GCMBlockCipher throw new IllegalArgumentException("IV must be at least 1 byte"); } - // TODO This should be configurable by init parameters - // (but must be 16 if nonce length not 12) (BLOCK_SIZE?) -// this.tagLength = 16; + // TODO Restrict macSize to 16 if nonce length not 12? // Cipher always used in forward mode // if keyParam is null we're reusing the last key. @@ -389,7 +387,6 @@ public class GCMBlockCipher gHASHBlock(S, X); - // TODO Fix this if tagLength becomes configurable // T = MSBt(GCTRk(J0,S)) byte[] tag = new byte[BLOCK_SIZE]; cipher.processBlock(J0, 0, tag, 0); |