aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/aes_isa_eng
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-11-06 15:48:58 +0000
committerlloyd <[email protected]>2009-11-06 15:48:58 +0000
commit89da502ff80a9c63038b8b02a5062e460dff4649 (patch)
tree336208ded07cf9adcf7144d5748109fa24ad026c /src/engine/aes_isa_eng
parent2fa888b0147a644de0df42fe0721eeb385810714 (diff)
Stub for AES class using Intel's AES-NI instructions and an engine for
providing it. Also stubs in the engine for VIA's AES instructions, but needs CPUID checking also.
Diffstat (limited to 'src/engine/aes_isa_eng')
-rw-r--r--src/engine/aes_isa_eng/aes_isa_engine.cpp56
-rw-r--r--src/engine/aes_isa_eng/aes_isa_engine.h26
-rw-r--r--src/engine/aes_isa_eng/info.txt3
3 files changed, 85 insertions, 0 deletions
diff --git a/src/engine/aes_isa_eng/aes_isa_engine.cpp b/src/engine/aes_isa_eng/aes_isa_engine.cpp
new file mode 100644
index 000000000..c74f8bddc
--- /dev/null
+++ b/src/engine/aes_isa_eng/aes_isa_engine.cpp
@@ -0,0 +1,56 @@
+/*
+* Engine for AES instructions
+* (C) 2009 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/aes_isa_engine.h>
+#include <botan/cpuid.h>
+
+#if defined(BOTAN_HAS_AES_INTEL)
+ #include <botan/aes_intel.h>
+#endif
+
+#if defined(BOTAN_HAS_AES_VIA)
+ #include <botan/aes_via.h>
+#endif
+
+namespace Botan {
+
+BlockCipher*
+AES_ISA_Engine::find_block_cipher(const SCAN_Name& request,
+ Algorithm_Factory&) const
+ {
+#if defined(BOTAN_HAS_AES_INTEL)
+ if(CPUID::has_intel_aes())
+ {
+ if(request.algo_name() == "AES")
+ return new AES_Intel;
+ if(request.algo_name() == "AES-128")
+ return new AES_Intel_128;
+ if(request.algo_name() == "AES-192")
+ return new AES_Intel_192;
+ if(request.algo_name() == "AES-256")
+ return new AES_Intel_256;
+ }
+#endif
+
+#if defined(BOTAN_HAS_AES_VIA)
+ if(CPUID::has_via_aes())
+ {
+ if(request.algo_name() == "AES")
+ return new AES_Via;
+ if(request.algo_name() == "AES-128")
+ return new AES_Via_128;
+ if(request.algo_name() == "AES-192")
+ return new AES_Via_192;
+ if(request.algo_name() == "AES-256")
+ return new AES_Via_256;
+ }
+#endif
+
+ return 0;
+ }
+
+}
diff --git a/src/engine/aes_isa_eng/aes_isa_engine.h b/src/engine/aes_isa_eng/aes_isa_engine.h
new file mode 100644
index 000000000..602a114a9
--- /dev/null
+++ b/src/engine/aes_isa_eng/aes_isa_engine.h
@@ -0,0 +1,26 @@
+/**
+* Engine for AES instructions
+* (C) 2009 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_AES_ISA_ENGINE_H__
+#define BOTAN_AES_ISA_ENGINE_H__
+
+#include <botan/engine.h>
+
+namespace Botan {
+
+class BOTAN_DLL AES_ISA_Engine : public Engine
+ {
+ public:
+ std::string provider_name() const { return "aes_isa"; }
+ private:
+ BlockCipher* find_block_cipher(const SCAN_Name&,
+ Algorithm_Factory&) const;
+ };
+
+}
+
+#endif
diff --git a/src/engine/aes_isa_eng/info.txt b/src/engine/aes_isa_eng/info.txt
new file mode 100644
index 000000000..c0695aaf3
--- /dev/null
+++ b/src/engine/aes_isa_eng/info.txt
@@ -0,0 +1,3 @@
+define ENGINE_AES_ISA
+
+load_on dep