diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-10 15:40:41 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-10 15:40:41 +0700 |
commit | 233a8fe2e4b53b5749d9b607a3e74a61d925baf8 (patch) | |
tree | cbe5026d8814934da1d06562183067429a1dab1a /crypto/test | |
parent | Fix test namespaces (diff) | |
download | BouncyCastle.NET-ed25519-233a8fe2e4b53b5749d9b607a3e74a61d925baf8.tar.xz |
AesEngine_X86 perf. opts.
- based on suggestions by https://github.com/benaadams - see https://github.com/bcgit/bc-csharp/pull/414
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/crypto/test/AesX86Test.cs | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/crypto/test/src/crypto/test/AesX86Test.cs b/crypto/test/src/crypto/test/AesX86Test.cs index 9ebc663bc..629963187 100644 --- a/crypto/test/src/crypto/test/AesX86Test.cs +++ b/crypto/test/src/crypto/test/AesX86Test.cs @@ -149,6 +149,150 @@ namespace Org.BouncyCastle.Crypto.Tests Assert.IsTrue(fourBlockOutput.SequenceEqual(singleBlockOutput)); } } + + [Test, Explicit] + public void BenchDecrypt128() + { + byte[] data = new byte[16]; + var engine = new AesEngine_X86(); + engine.Init(false, new KeyParameter(new byte[16])); + for (int i = 0; i < 1000000000; ++i) + { + engine.ProcessBlock(data, 0, data, 0); + } + } + + [Test, Explicit] + public void BenchDecrypt192() + { + byte[] data = new byte[16]; + var engine = new AesEngine_X86(); + engine.Init(false, new KeyParameter(new byte[24])); + for (int i = 0; i < 1000000000; ++i) + { + engine.ProcessBlock(data, 0, data, 0); + } + } + + [Test, Explicit] + public void BenchDecrypt256() + { + byte[] data = new byte[16]; + var engine = new AesEngine_X86(); + engine.Init(false, new KeyParameter(new byte[32])); + for (int i = 0; i < 1000000000; ++i) + { + engine.ProcessBlock(data, 0, data, 0); + } + } + + [Test, Explicit] + public void BenchEncrypt128() + { + byte[] data = new byte[16]; + var engine = new AesEngine_X86(); + engine.Init(true, new KeyParameter(new byte[16])); + for (int i = 0; i < 1000000000; ++i) + { + engine.ProcessBlock(data, 0, data, 0); + } + } + + [Test, Explicit] + public void BenchDecryptFour128() + { + byte[] data = new byte[64]; + var engine = new AesEngine_X86(); + engine.Init(false, new KeyParameter(new byte[16])); + for (int i = 0; i < 1000000000 / 4; ++i) + { + engine.ProcessFourBlocks(data, data); + } + } + + [Test, Explicit] + public void BenchDecryptFour192() + { + byte[] data = new byte[64]; + var engine = new AesEngine_X86(); + engine.Init(false, new KeyParameter(new byte[24])); + for (int i = 0; i < 1000000000 / 4; ++i) + { + engine.ProcessFourBlocks(data, data); + } + } + + [Test, Explicit] + public void BenchDecryptFour256() + { + byte[] data = new byte[64]; + var engine = new AesEngine_X86(); + engine.Init(false, new KeyParameter(new byte[32])); + for (int i = 0; i < 1000000000 / 4; ++i) + { + engine.ProcessFourBlocks(data, data); + } + } + + [Test, Explicit] + public void BenchEncrypt192() + { + byte[] data = new byte[16]; + var engine = new AesEngine_X86(); + engine.Init(true, new KeyParameter(new byte[24])); + for (int i = 0; i < 1000000000; ++i) + { + engine.ProcessBlock(data, 0, data, 0); + } + } + + [Test, Explicit] + public void BenchEncrypt256() + { + byte[] data = new byte[16]; + var engine = new AesEngine_X86(); + engine.Init(true, new KeyParameter(new byte[32])); + for (int i = 0; i < 1000000000; ++i) + { + engine.ProcessBlock(data, 0, data, 0); + } + } + + [Test, Explicit] + public void BenchEncryptFour128() + { + byte[] data = new byte[64]; + var engine = new AesEngine_X86(); + engine.Init(true, new KeyParameter(new byte[16])); + for (int i = 0; i < 1000000000 / 4; ++i) + { + engine.ProcessFourBlocks(data, data); + } + } + + [Test, Explicit] + public void BenchEncryptFour192() + { + byte[] data = new byte[64]; + var engine = new AesEngine_X86(); + engine.Init(true, new KeyParameter(new byte[24])); + for (int i = 0; i < 1000000000 / 4; ++i) + { + engine.ProcessFourBlocks(data, data); + } + } + + [Test, Explicit] + public void BenchEncryptFour256() + { + byte[] data = new byte[64]; + var engine = new AesEngine_X86(); + engine.Init(true, new KeyParameter(new byte[32])); + for (int i = 0; i < 1000000000 / 4; ++i) + { + engine.ProcessFourBlocks(data, data); + } + } } } #endif |