1 module dcrypt.main;
2 
3 import std.stdio;
4 import std.conv;
5 import dcrypt.streamcipher.streamcipher;
6 import dcrypt.encoders.hex;
7 import dcrypt.digest;
8 import dcrypt.digests.sha1;
9 import dcrypt.digests.sha2;
10 import dcrypt.digests.sha3;
11 import dcrypt.digests.blake;
12 
13 import dcrypt.keyderivation.pbkdf2;
14 
15 import dcrypt.blockcipher.blockcipher;
16 import dcrypt.blockcipher.aes;
17 import dcrypt.blockcipher.aesni;
18 import dcrypt.blockcipher.aesopenssl;
19 import dcrypt.blockcipher.rijndael;
20 import dcrypt.blockcipher.rc6;
21 import dcrypt.blockcipher.serpent;
22 import dcrypt.blockcipher.modes.cbc;
23 import dcrypt.blockcipher.modes.ctr;
24 
25 import dcrypt.aead.gcm.gcm;
26 import dcrypt.aead.poly1305_chacha;
27 
28 import dcrypt.benchmark.Benchmark;
29 import dcrypt.benchmark.DigestBenchmark;
30 import dcrypt.benchmark.BlockCipherBenchmark;
31 import dcrypt.benchmark.AEADCipherBenchmark;
32 
33 import dcrypt.random.random;
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 SHA3_224Digest;
57 		digests ~= new SHA3_256Digest;
58 		digests ~= new SHA3_384Digest;
59 		digests ~= new SHA3_512Digest;
60 		digests ~= new Blake224Digest;
61 		digests ~= new Blake256Digest;
62 		digests ~= new Blake384Digest;
63 		digests ~= new Blake512Digest;
64 		
65 		Benchmark.doBenchmark(len, digests);
66 		
67 		
68 		IBlockCipher[] ciphers;
69 		ciphers ~=	new AESEngine();
70 		ciphers ~=	new AESNIEngine();
71 		ciphers ~=	new AESOpenSSLEngine();
72 		ciphers ~=	new CBCBlockCipher!AES;
73 		ciphers ~=	new CTRBlockCipher!AES;
74 		ciphers ~=	new CBCBlockCipher!AESNI;
75 		ciphers ~=	new CTRBlockCipher!AESNI;
76 		ciphers ~=	new Rijndael128Engine;
77 		ciphers ~=	new Rijndael256Engine;
78 		ciphers ~=	new RC6Engine();
79 		ciphers ~=	new SerpentEngine();
80 		ciphers ~=	new CBCBlockCipher!Serpent; 
81 		ciphers ~=	new CTRBlockCipher!Serpent;
82 		
83 		Benchmark.doBenchmark(len, ciphers);
84 		
85 		IAEADEngine[] aeadCiphers = [
86 			new GCMEngine(new AESEngine()),
87 			new GCMEngine(new AESNIEngine()),
88 			new GCMEngine(new SerpentEngine())
89 		];
90 		
91 		Benchmark.doBenchmark(len, aeadCiphers);
92 
93 		Benchmark.doCurved25519Benchmark(1024);
94 		Benchmark.doEd25519Benchmark(1024);
95 		Benchmark.doSphincs256Benchmark(1);
96 				
97 	}
98 } else {
99 }