1 /**
2 * Assembly Implementation Engine
3 * 
4 * Copyright:
5 * (C) 1999-2010 Jack Lloyd
6 * (C) 2014-2015 Etienne Cimon
7 *
8 * License:
9 * Botan is released under the Simplified BSD License (see LICENSE.md)
10 */
11 module botan.engine.asm_engine;
12 
13 import botan.constants;
14 static if (BOTAN_HAS_ENGINE_ASSEMBLER):
15 
16 import botan.engine.engine;
17 
18 static if (BOTAN_HAS_SERPENT_X86_32)     import botan.block.serp_x86_32;
19 static if (BOTAN_HAS_MD4_X86_32)         import botan.hash.md4_x86_32;
20 static if (BOTAN_HAS_MD5_X86_32)         import botan.hash.md5_x86_32;
21 static if (BOTAN_HAS_SHA1_X86_64)        import botan.hash.sha1_x86_64;
22 static if (BOTAN_HAS_SHA1_X86_32)        import botan.hash.sha1_x86_32;
23 
24 /**
25 * Engine for x86-32 specific implementations
26 */
27 final class AssemblerEngine : Engine
28 {
29 public:
30     string providerName() const { return "asm"; }
31 
32     BlockCipher findBlockCipher(in SCANToken request,
33                                 AlgorithmFactory af) const
34     {
35         static if (BOTAN_HAS_SERPENT_X86_32) { 
36             if (request.algoName == "Serpent")
37             {
38                 
39                 return new Serpent_X86_32;
40             }
41         }
42         return null;
43     }
44 
45     HashFunction findHash(in SCANToken request,
46                           AlgorithmFactory af) const
47     {
48         static if (BOTAN_HAS_MD4_X86_32) {
49             if (request.algoName == "MD4")
50                 return new MD4_X86_32;
51         }
52         
53         static if (BOTAN_HAS_MD5_X86_32) {
54             if (request.algoName == "MD5")
55                 return new MD5_X86_32;
56         }
57         
58         if (request.algoName == "SHA-160")
59         {
60             static if (BOTAN_HAS_SHA1_X86_64)
61                 return new SHA160_X86_64;
62             else static if (BOTAN_HAS_SHA1_X86_32)
63                 return new SHA160_X86_32;
64         }
65         
66         return null;
67     }
68 
69     StreamCipher findStreamCipher(in SCANToken algo_spec, AlgorithmFactory af) const
70     { return null; }
71 
72     MessageAuthenticationCode findMac(in SCANToken algo_spec, AlgorithmFactory af) const
73     { return null; }
74 
75     PBKDF findPbkdf(in SCANToken algo_spec, AlgorithmFactory af) const
76     { return null; }
77 
78 
79     KeyedFilter getCipher(in string algo_spec, CipherDir dir, AlgorithmFactory af) const
80     { return null; }
81 
82     static if (BOTAN_HAS_PUBLIC_KEY_CRYPTO):
83 
84     ModularExponentiator modExp(const ref BigInt n, PowerMod.UsageHints hints) const
85     { return null; }
86 
87     KeyAgreement getKeyAgreementOp(in PrivateKey key, RandomNumberGenerator rng) const
88     { return null; }
89 
90     Signature getSignatureOp(in PrivateKey key, RandomNumberGenerator rng) const
91     { return null; }
92 
93     Verification getVerifyOp(in PublicKey key, RandomNumberGenerator rng) const
94     { return null; }
95 
96     Encryption getEncryptionOp(in PublicKey key, RandomNumberGenerator rng) const
97     { return null; }
98 
99     Decryption getDecryptionOp(in PrivateKey key, RandomNumberGenerator rng) const
100     { return null; }
101 }