1 /**
2 * Engine for AES instructions
3 * 
4 * Copyright:
5 * (C) 2009 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.aes_isa_engine;
12 
13 import botan.constants;
14 static if (BOTAN_HAS_ENGINE_AES_ISA):
15 
16 import botan.engine.engine;
17 import botan.utils.cpuid;
18 static if (BOTAN_HAS_AES_NI) import botan.block.aes_ni;
19 
20 /**
21 * Engine for implementations that hook into CPU-specific
22 * AES implementations (eg AES-NI, VIA C7, or AMD Geode)
23 */
24 final class AESISAEngine : Engine
25 {
26 public:
27     string providerName() const { return "aes_isa"; }
28 
29     BlockCipher findBlockCipher(in SCANToken request,
30                                 AlgorithmFactory af) const
31     {
32         static if (BOTAN_HAS_AES_NI) {
33             if (CPUID.hasAesNi())
34             {
35                 if (request.algoName == "AES-128")
36                     return new AES128NI;
37                 if (request.algoName == "AES-192")
38                     return new AES192NI;
39                 if (request.algoName == "AES-256")
40                     return new AES256NI;
41             }
42         }
43         return null;
44     }
45 
46     HashFunction findHash(in SCANToken request, AlgorithmFactory af) const
47     { return null; }
48 
49     StreamCipher findStreamCipher(in SCANToken algo_spec, AlgorithmFactory af) const
50     { return null; }
51     
52     MessageAuthenticationCode findMac(in SCANToken algo_spec, AlgorithmFactory af) const
53     { return null; }
54     
55     PBKDF findPbkdf(in SCANToken algo_spec, AlgorithmFactory af) const
56     { return null; }
57     
58     
59     KeyedFilter getCipher(in string algo_spec, CipherDir dir, AlgorithmFactory af) const
60     { return null; }
61     
62     static if (BOTAN_HAS_PUBLIC_KEY_CRYPTO):
63 
64     ModularExponentiator modExp(const(BigInt)* n, PowerMod.UsageHints hints) const
65     { return null; }
66 
67     KeyAgreement getKeyAgreementOp(in PrivateKey key, RandomNumberGenerator rng) const
68     { return null; }
69     
70     Signature getSignatureOp(in PrivateKey key, RandomNumberGenerator rng) const
71     { return null; }
72     
73     Verification getVerifyOp(in PublicKey key, RandomNumberGenerator rng) const
74     { return null; }
75     
76     Encryption getEncryptionOp(in PublicKey key, RandomNumberGenerator rng) const
77     { return null; }
78     
79     Decryption getDecryptionOp(in PrivateKey key, RandomNumberGenerator rng) const
80     { return null; }
81 }