diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-26 20:26:44 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-26 20:26:44 +0700 |
commit | 6f3de272501bd9153fdbc7b6c28a6de7c7dfbfae (patch) | |
tree | 40bc1f0d3b347511de311c08fe87179b52e4c3b3 /crypto/test | |
parent | Make class internal (diff) | |
download | BouncyCastle.NET-ed25519-6f3de272501bd9153fdbc7b6c28a6de7c7dfbfae.tar.xz |
When OCB is used with incrementing nonces, the cipher processing during initialization is only needed once every 64 inits.
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/crypto/test/OCBTest.cs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/crypto/test/src/crypto/test/OCBTest.cs b/crypto/test/src/crypto/test/OCBTest.cs index 051aa665a..284ae7fb3 100644 --- a/crypto/test/src/crypto/test/OCBTest.cs +++ b/crypto/test/src/crypto/test/OCBTest.cs @@ -14,7 +14,7 @@ namespace Org.BouncyCastle.Crypto.Tests { /** * Test vectors from the "work in progress" Internet-Draft <a - * href="http://tools.ietf.org/html/draft-irtf-cfrg-ocb-03">The OCB Authenticated-Encryption + * href="http://tools.ietf.org/html/draft-irtf-cfrg-ocb-05">The OCB Authenticated-Encryption * Algorithm</a> */ public class OcbTest @@ -90,6 +90,37 @@ namespace Org.BouncyCastle.Crypto.Tests RunLongerTestCase(128, 64, Hex.Decode("B7ECE9D381FE437F")); RunLongerTestCase(192, 64, Hex.Decode("DE0574C87FF06DF9")); RunLongerTestCase(256, 64, Hex.Decode("833E45FF7D332F7E")); + + DoTestExceptions(); + } + + private void DoTestExceptions() + { + OcbBlockCipher ocb = new OcbBlockCipher(new AesFastEngine(), new AesFastEngine()); + + try + { + ocb = new OcbBlockCipher(new DesEngine(), new DesEngine()); + Fail("incorrect block size not picked up"); + } + catch (ArgumentException e) + { + // expected + } + + try + { + ocb.Init(false, new KeyParameter(new byte[16])); + Fail("illegal argument not picked up"); + } + catch (ArgumentException e) + { + // expected + } + + // TODO + //AEADTestUtil.testReset(this, new OCBBlockCipher(new AESEngine(), new AESEngine()), new OCBBlockCipher(new AESEngine(), new AESEngine()), new AEADParameters(new KeyParameter(new byte[16]), 128, new byte[15])); + //AEADTestUtil.testTampering(this, ocb, new AEADParameters(new KeyParameter(new byte[16]), 128, new byte[15])); } private void RunTestCase(string testName, string[] testVector) |