diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 14:23:56 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 14:23:56 +0700 |
commit | 9ae0b1807893ff07a7a0bb42c8e4957d7c9fedb5 (patch) | |
tree | 0445dc1ca8a17c02802ba347499b36ff7c5749ea /crypto | |
parent | Port extra test case from Java API (diff) | |
download | BouncyCastle.NET-ed25519-9ae0b1807893ff07a7a0bb42c8e4957d7c9fedb5.tar.xz |
More SIC changes for consistency with Java API
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/crypto/modes/SicBlockCipher.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/src/crypto/modes/SicBlockCipher.cs b/crypto/src/crypto/modes/SicBlockCipher.cs index 17f86ee10..239f99478 100644 --- a/crypto/src/crypto/modes/SicBlockCipher.cs +++ b/crypto/src/crypto/modes/SicBlockCipher.cs @@ -50,12 +50,14 @@ namespace Org.BouncyCastle.Crypto.Modes { ParametersWithIV ivParam = parameters as ParametersWithIV; if (ivParam == null) - throw new ArgumentException("CTR mode requires ParametersWithIV", "parameters"); + throw new ArgumentException("CTR/SIC mode requires ParametersWithIV", "parameters"); this.IV = Arrays.Clone(ivParam.GetIV()); + if (blockSize < IV.Length) + throw new ArgumentException("CTR/SIC mode requires IV no greater than: " + blockSize + " bytes."); if (blockSize - IV.Length > 8) - throw new ArgumentException("CTR mode requires IV of at least: " + (blockSize - 8) + " bytes."); + throw new ArgumentException("CTR/SIC mode requires IV of at least: " + (blockSize - 8) + " bytes."); Reset(); @@ -68,7 +70,7 @@ namespace Org.BouncyCastle.Crypto.Modes public virtual string AlgorithmName { - get { return cipher.AlgorithmName + "/CTR"; } + get { return cipher.AlgorithmName + "/SIC"; } } public virtual bool IsPartialBlockOkay @@ -109,7 +111,7 @@ namespace Org.BouncyCastle.Crypto.Modes public virtual void Reset() { Arrays.Fill(counter, (byte)0); - Array.Copy(IV, 0, counter, 0, System.Math.Min(IV.Length, counter.Length)); + Array.Copy(IV, 0, counter, 0, IV.Length); cipher.Reset(); } } |