1 module dcrypt.main; 2 3 import std.stdio; 4 import std.conv; 5 import dcrypt.crypto.engines.rc4; 6 import dcrypt.crypto.streamcipher; 7 import dcrypt.crypto.params.keyparameter; 8 import dcrypt.util.encoders.hex; 9 import dcrypt.crypto.digest; 10 import dcrypt.crypto.digests.sha1; 11 import dcrypt.crypto.digests.sha2; 12 import dcrypt.crypto.digests.sha2; 13 import dcrypt.crypto.digests.sha2; 14 import dcrypt.crypto.digests.keccak; 15 16 import dcrypt.crypto.generators.pkcs5s2; 17 18 import dcrypt.crypto.blockcipher; 19 import dcrypt.crypto.engines.aes; 20 import dcrypt.crypto.engines.aesni; 21 import dcrypt.crypto.engines.aesopenssl; 22 import dcrypt.crypto.engines.rijndael; 23 import dcrypt.crypto.engines.rc6; 24 import dcrypt.crypto.engines.serpent; 25 import dcrypt.crypto.modes.cbc; 26 import dcrypt.crypto.modes.ctr; 27 28 import dcrypt.crypto.modes.gcm.gcm; 29 30 import dcrypt.benchmark.Benchmark; 31 import dcrypt.benchmark.DigestBenchmark; 32 import dcrypt.benchmark.BlockCipherBenchmark; 33 import dcrypt.benchmark.AEADCipherBenchmark; 34 35 version (Benchmark) { 36 37 public void main(string[] args) { 38 benchmark(); 39 } 40 41 /// run various benchmarks 42 void benchmark() { 43 ulong len = 1<<18; 44 45 debug { 46 writeln("\n--- BENCHMARK (slow debug mode)---\n"); 47 } else { 48 writeln("\n--- BENCHMARK ---\n"); 49 } 50 51 Digest[] digests; 52 digests ~= new SHA1Digest(); 53 digests ~= new SHA256Digest(); 54 digests ~= new SHA384Digest(); 55 digests ~= new SHA512Digest(); 56 digests ~= new Keccak224Digest; 57 digests ~= new Keccak256Digest; 58 digests ~= new Keccak288Digest; 59 digests ~= new Keccak384Digest; 60 digests ~= new Keccak512Digest; 61 62 Benchmark.doBenchmark(len, digests); 63 64 65 BlockCipher[] ciphers; 66 ciphers ~= new AESEngine(); 67 ciphers ~= new AESNIEngine(); 68 ciphers ~= new AESOpenSSLEngine(); 69 ciphers ~= new CBCBlockCipher!AES; 70 ciphers ~= new CTRBlockCipher!AES; 71 ciphers ~= new CBCBlockCipher!AESNI; 72 ciphers ~= new CTRBlockCipher!AESNI; 73 ciphers ~= new Rijndael128Engine; 74 ciphers ~= new Rijndael256Engine; 75 ciphers ~= new RC6Engine(); 76 ciphers ~= new SerpentEngine(); 77 ciphers ~= new CBCBlockCipher!Serpent; 78 ciphers ~= new CTRBlockCipher!Serpent; 79 80 Benchmark.doBenchmark(len, ciphers); 81 82 AEADCipher[] aeadCiphers = [ 83 new GCMCipher(new AESEngine()), 84 new GCMCipher(new AESNIEngine()), 85 new GCMCipher(new SerpentEngine()) 86 ]; 87 Benchmark.doBenchmark(len, aeadCiphers); 88 89 Benchmark.doCurve25519Benchmark(256); 90 91 // PKCS5S2ParametersGenerator[] gen = [ 92 // new PKCS5S2ParametersGenerator(new SHA1Digest), 93 // new PKCS5S2ParametersGenerator(new SHA256Digest), 94 // new PKCS5S2ParametersGenerator(new SHA512Digest)]; 95 //Benchmark.doBenchmark(gen); 96 97 } 98 } else { 99 // public void main(string[] args) { 100 // } 101 }