aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-08-29 11:53:06 -0400
committerJack Lloyd <[email protected]>2015-08-29 11:53:06 -0400
commit3103f299dfd9517a4ef3c40358c1a4cad38b7305 (patch)
treed3cb4309c78cfc0948315970ca3c827bc356c1ef /src/lib
parente4962bebbc687e93e47d35339b6a2242aefee51e (diff)
Reverse the algorithm priority ordering
Previously 0 was the highest priority and 255 was the lowest. But this is really quite confusing, instead treat 0 as lowest and 255 as highest so normal integer intuitions apply.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/base/algo_registry.h17
-rw-r--r--src/lib/block/aes_ni/aes_ni.cpp6
-rw-r--r--src/lib/block/aes_ssse3/aes_ssse3.cpp9
-rw-r--r--src/lib/block/idea_sse2/idea_sse2.cpp3
-rw-r--r--src/lib/block/noekeon_simd/noekeon_simd.cpp3
-rw-r--r--src/lib/block/serpent_simd/serp_simd.cpp3
-rw-r--r--src/lib/block/threefish_avx2/threefish_avx2.cpp3
-rw-r--r--src/lib/block/xtea_simd/xtea_simd.cpp3
-rw-r--r--src/lib/hash/sha1_sse2/sha1_sse2.cpp3
-rw-r--r--src/lib/vendor/openssl/info.txt2
-rw-r--r--src/lib/vendor/openssl/openssl.h9
-rw-r--r--src/lib/vendor/openssl/openssl_block.cpp7
-rw-r--r--src/lib/vendor/openssl/openssl_hash.cpp3
-rw-r--r--src/lib/vendor/openssl/openssl_rc4.cpp4
14 files changed, 50 insertions, 25 deletions
diff --git a/src/lib/base/algo_registry.h b/src/lib/base/algo_registry.h
index 918206577..498021194 100644
--- a/src/lib/base/algo_registry.h
+++ b/src/lib/base/algo_registry.h
@@ -152,7 +152,7 @@ class Algo_Registry
return r;
}
private:
- std::multimap<byte, std::string> m_prefs;
+ std::multimap<byte, std::string, std::greater<byte>> m_prefs;
std::unordered_map<std::string, maker_fn> m_maker_fns;
};
@@ -224,24 +224,27 @@ make_new_T_1X(const typename Algo_Registry<T>::Spec& spec)
namespace { Algo_Registry<T>::Add g_ ## type ## _reg(cond, name, maker, provider, pref); } \
BOTAN_FORCE_SEMICOLON
+#define BOTAN_DEFAULT_ALGORITHM_PRIO 100
+#define BOTAN_SIMD_ALGORITHM_PRIO 110
+
#define BOTAN_REGISTER_NAMED_T(T, name, type, maker) \
- BOTAN_REGISTER_TYPE(T, type, name, maker, "base", 128)
+ BOTAN_REGISTER_TYPE(T, type, name, maker, "base", BOTAN_DEFAULT_ALGORITHM_PRIO)
#define BOTAN_REGISTER_T(T, type, maker) \
- BOTAN_REGISTER_TYPE(T, type, #type, maker, "base", 128)
+ BOTAN_REGISTER_TYPE(T, type, #type, maker, "base", BOTAN_DEFAULT_ALGORITHM_PRIO)
#define BOTAN_REGISTER_T_NOARGS(T, type) \
- BOTAN_REGISTER_TYPE(T, type, #type, make_new_T<type>, "base", 128)
+ BOTAN_REGISTER_TYPE(T, type, #type, make_new_T<type>, "base", BOTAN_DEFAULT_ALGORITHM_PRIO)
#define BOTAN_REGISTER_T_1LEN(T, type, def) \
- BOTAN_REGISTER_TYPE(T, type, #type, (make_new_T_1len<type,def>), "base", 128)
+ BOTAN_REGISTER_TYPE(T, type, #type, (make_new_T_1len<type,def>), "base", BOTAN_DEFAULT_ALGORITHM_PRIO)
#define BOTAN_REGISTER_NAMED_T_NOARGS(T, type, name, provider) \
- BOTAN_REGISTER_TYPE(T, type, name, make_new_T<type>, provider, 128)
+ BOTAN_REGISTER_TYPE(T, type, name, make_new_T<type>, provider, BOTAN_DEFAULT_ALGORITHM_PRIO)
#define BOTAN_COND_REGISTER_NAMED_T_NOARGS(cond, T, type, name, provider, pref) \
BOTAN_REGISTER_TYPE_COND(cond, T, type, name, make_new_T<type>, provider, pref)
#define BOTAN_REGISTER_NAMED_T_2LEN(T, type, name, provider, len1, len2) \
- BOTAN_REGISTER_TYPE(T, type, name, (make_new_T_2len<type,len1,len2>), provider, 128)
+ BOTAN_REGISTER_TYPE(T, type, name, (make_new_T_2len<type,len1,len2>), provider, BOTAN_DEFAULT_ALGORITHM_PRIO)
// TODO move elsewhere:
#define BOTAN_REGISTER_TRANSFORM(name, maker) BOTAN_REGISTER_T(Transform, name, maker)
diff --git a/src/lib/block/aes_ni/aes_ni.cpp b/src/lib/block/aes_ni/aes_ni.cpp
index 20aa63c54..29e729da4 100644
--- a/src/lib/block/aes_ni/aes_ni.cpp
+++ b/src/lib/block/aes_ni/aes_ni.cpp
@@ -12,9 +12,9 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_128_NI, "AES-128", "aes_ni", 16);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_192_NI, "AES-192", "aes_ni", 16);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_256_NI, "AES-256", "aes_ni", 16);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_128_NI, "AES-128", "aes_ni", 200);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_192_NI, "AES-192", "aes_ni", 200);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_aes_ni(), AES_256_NI, "AES-256", "aes_ni", 200);
namespace {
diff --git a/src/lib/block/aes_ssse3/aes_ssse3.cpp b/src/lib/block/aes_ssse3/aes_ssse3.cpp
index f0d506b6e..50acd7668 100644
--- a/src/lib/block/aes_ssse3/aes_ssse3.cpp
+++ b/src/lib/block/aes_ssse3/aes_ssse3.cpp
@@ -17,9 +17,12 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_128_SSSE3, "AES-128", "ssse3", 64);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_192_SSSE3, "AES-192", "ssse3", 64);
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_256_SSSE3, "AES-256", "ssse3", 64);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_128_SSSE3, "AES-128",
+ "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_192_SSSE3, "AES-192",
+ "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_ssse3(), AES_256_SSSE3, "AES-256",
+ "ssse3", BOTAN_SIMD_ALGORITHM_PRIO);
namespace {
diff --git a/src/lib/block/idea_sse2/idea_sse2.cpp b/src/lib/block/idea_sse2/idea_sse2.cpp
index af7e2182d..8549d74d7 100644
--- a/src/lib/block/idea_sse2/idea_sse2.cpp
+++ b/src/lib/block/idea_sse2/idea_sse2.cpp
@@ -12,7 +12,8 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_sse2(), IDEA_SSE2, "IDEA", "sse2", 64);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_sse2(), IDEA_SSE2, "IDEA",
+ "sse2", BOTAN_SIMD_ALGORITHM_PRIO);
namespace {
diff --git a/src/lib/block/noekeon_simd/noekeon_simd.cpp b/src/lib/block/noekeon_simd/noekeon_simd.cpp
index a5d757d3c..a51c6bc8f 100644
--- a/src/lib/block/noekeon_simd/noekeon_simd.cpp
+++ b/src/lib/block/noekeon_simd/noekeon_simd.cpp
@@ -11,7 +11,8 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Noekeon_SIMD, "Noekeon", "simd32", 64);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Noekeon_SIMD, "Noekeon",
+ "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
/*
* Noekeon's Theta Operation
diff --git a/src/lib/block/serpent_simd/serp_simd.cpp b/src/lib/block/serpent_simd/serp_simd.cpp
index 7b957598f..56747dd16 100644
--- a/src/lib/block/serpent_simd/serp_simd.cpp
+++ b/src/lib/block/serpent_simd/serp_simd.cpp
@@ -12,7 +12,8 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Serpent_SIMD, "Serpent", "simd32", 64);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Serpent_SIMD, "Serpent",
+ "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
namespace {
diff --git a/src/lib/block/threefish_avx2/threefish_avx2.cpp b/src/lib/block/threefish_avx2/threefish_avx2.cpp
index e17146162..435c75dbf 100644
--- a/src/lib/block/threefish_avx2/threefish_avx2.cpp
+++ b/src/lib/block/threefish_avx2/threefish_avx2.cpp
@@ -12,7 +12,8 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_avx2(), Threefish_512_AVX2, "Threefish-512", "avx2", 64);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_avx2(), Threefish_512_AVX2, "Threefish-512",
+ "avx2", BOTAN_SIMD_ALGORITHM_PRIO);
namespace {
diff --git a/src/lib/block/xtea_simd/xtea_simd.cpp b/src/lib/block/xtea_simd/xtea_simd.cpp
index ffd2eb560..a9984ce23 100644
--- a/src/lib/block/xtea_simd/xtea_simd.cpp
+++ b/src/lib/block/xtea_simd/xtea_simd.cpp
@@ -11,7 +11,8 @@
namespace Botan {
-BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), XTEA_SIMD, "XTEA", "simd32", 64);
+BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), XTEA_SIMD, "XTEA",
+ "simd32", BOTAN_SIMD_ALGORITHM_PRIO);
namespace {
diff --git a/src/lib/hash/sha1_sse2/sha1_sse2.cpp b/src/lib/hash/sha1_sse2/sha1_sse2.cpp
index 1fc62d957..7cd457597 100644
--- a/src/lib/hash/sha1_sse2/sha1_sse2.cpp
+++ b/src/lib/hash/sha1_sse2/sha1_sse2.cpp
@@ -14,7 +14,8 @@
namespace Botan {
-BOTAN_REGISTER_HASH_NOARGS_IF(CPUID::has_sse2(), SHA_160_SSE2, "SHA-160", "sse2", 64);
+BOTAN_REGISTER_HASH_NOARGS_IF(CPUID::has_sse2(), SHA_160_SSE2, "SHA-160",
+ "sse2", BOTAN_SIMD_ALGORITHM_PRIO);
namespace SHA1_SSE2_F {
diff --git a/src/lib/vendor/openssl/info.txt b/src/lib/vendor/openssl/info.txt
index 0ca78a88e..1381e2019 100644
--- a/src/lib/vendor/openssl/info.txt
+++ b/src/lib/vendor/openssl/info.txt
@@ -1,3 +1,5 @@
+define OPENSSL 20150829
+
load_on vendor
<header:internal>
diff --git a/src/lib/vendor/openssl/openssl.h b/src/lib/vendor/openssl/openssl.h
index 1ffaed519..4fa37cc54 100644
--- a/src/lib/vendor/openssl/openssl.h
+++ b/src/lib/vendor/openssl/openssl.h
@@ -5,8 +5,8 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/
-#ifndef BOTAN_CALL_OPENSSL_H__
-#define BOTAN_CALL_OPENSSL_H__
+#ifndef BOTAN_OPENSSL_H__
+#define BOTAN_OPENSSL_H__
#include <botan/secmem.h>
#include <botan/exceptn.h>
@@ -23,6 +23,11 @@ class OpenSSL_Error : public Exception
Exception(what + " failed: " + ERR_error_string(ERR_get_error(), nullptr)) {}
};
+#define BOTAN_OPENSSL_BLOCK_PRIO 150
+#define BOTAN_OPENSSL_HASH_PRIO 150
+#define BOTAN_OPENSSL_RC4_PRIO 150
+
+
}
#endif
diff --git a/src/lib/vendor/openssl/openssl_block.cpp b/src/lib/vendor/openssl/openssl_block.cpp
index 4fd41112b..b74f184c7 100644
--- a/src/lib/vendor/openssl/openssl_block.cpp
+++ b/src/lib/vendor/openssl/openssl_block.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/internal/block_utils.h>
+#include <botan/internal/openssl.h>
#include <openssl/evp.h>
namespace Botan {
@@ -165,14 +166,16 @@ make_evp_block_maker_keylen(const EVP_CIPHER* cipher, const char* algo,
};
}
+#define BOTAN_OPENSSL_BLOCK_PRIO 150
+
#define BOTAN_REGISTER_OPENSSL_EVP_BLOCK(NAME, EVP) \
BOTAN_REGISTER_TYPE(BlockCipher, EVP_BlockCipher ## EVP, NAME, \
- make_evp_block_maker(EVP(), NAME), "openssl", 96);
+ make_evp_block_maker(EVP(), NAME), "openssl", BOTAN_OPENSSL_BLOCK_PRIO);
#define BOTAN_REGISTER_OPENSSL_EVP_BLOCK_KEYLEN(NAME, EVP, KMIN, KMAX, KMOD) \
BOTAN_REGISTER_TYPE(BlockCipher, OpenSSL_BlockCipher ## EVP, NAME, \
make_evp_block_maker_keylen(EVP(), NAME, KMIN, KMAX, KMOD), \
- "openssl", 96);
+ "openssl", BOTAN_OPENSSL_BLOCK_PRIO);
#if !defined(OPENSSL_NO_AES)
BOTAN_REGISTER_OPENSSL_EVP_BLOCK("AES-128", EVP_aes_128_ecb);
diff --git a/src/lib/vendor/openssl/openssl_hash.cpp b/src/lib/vendor/openssl/openssl_hash.cpp
index 6133e36a4..6e055c0e6 100644
--- a/src/lib/vendor/openssl/openssl_hash.cpp
+++ b/src/lib/vendor/openssl/openssl_hash.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/internal/hash_utils.h>
+#include <botan/internal/openssl.h>
#include <openssl/evp.h>
namespace Botan {
@@ -78,7 +79,7 @@ make_evp_hash_maker(const EVP_MD* md, const char* algo)
#define BOTAN_REGISTER_OPENSSL_EVP_HASH(NAME, EVP) \
BOTAN_REGISTER_TYPE(HashFunction, OpenSSL_HashFunction ## EVP, NAME, \
- make_evp_hash_maker(EVP(), NAME), "openssl", 32);
+ make_evp_hash_maker(EVP(), NAME), "openssl", BOTAN_OPENSSL_HASH_PRIO);
#if !defined(OPENSSL_NO_SHA)
BOTAN_REGISTER_OPENSSL_EVP_HASH("SHA-160", EVP_sha1);
diff --git a/src/lib/vendor/openssl/openssl_rc4.cpp b/src/lib/vendor/openssl/openssl_rc4.cpp
index 494b30974..ac30cd288 100644
--- a/src/lib/vendor/openssl/openssl_rc4.cpp
+++ b/src/lib/vendor/openssl/openssl_rc4.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/internal/stream_utils.h>
+#include <botan/internal/openssl.h>
#include <botan/parsing.h>
#include <openssl/rc4.h>
@@ -48,6 +49,7 @@ class OpenSSL_RC4 : public StreamCipher
}
-BOTAN_REGISTER_TYPE(StreamCipher, OpenSSL_RC4, "RC4", (make_new_T_1len<OpenSSL_RC4,0>), "openssl", 64);
+BOTAN_REGISTER_TYPE(StreamCipher, OpenSSL_RC4, "RC4", (make_new_T_1len<OpenSSL_RC4,0>),
+ "openssl", BOTAN_OPENSSL_RC4_PRIO);
}