diff options
80 files changed, 213 insertions, 289 deletions
diff --git a/src/lib/asn1/ber_dec.cpp b/src/lib/asn1/ber_dec.cpp index 4267d79dc..80dfba3bb 100644 --- a/src/lib/asn1/ber_dec.cpp +++ b/src/lib/asn1/ber_dec.cpp @@ -8,7 +8,7 @@ #include <botan/ber_dec.h> #include <botan/bigint.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/asn1/der_enc.cpp b/src/lib/asn1/der_enc.cpp index f886e8ed3..f1bcf634e 100644 --- a/src/lib/asn1/der_enc.cpp +++ b/src/lib/asn1/der_enc.cpp @@ -8,7 +8,7 @@ #include <botan/der_enc.h> #include <botan/asn1_obj.h> #include <botan/bigint.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <botan/parsing.h> #include <botan/internal/bit_ops.h> #include <algorithm> diff --git a/src/lib/base/buf_comp.h b/src/lib/base/buf_comp.h index 30e30c71c..d0793b84b 100644 --- a/src/lib/base/buf_comp.h +++ b/src/lib/base/buf_comp.h @@ -9,7 +9,7 @@ #define BOTAN_BUFFERED_COMPUTATION_H__ #include <botan/secmem.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <string> namespace Botan { diff --git a/src/lib/base/symkey.cpp b/src/lib/base/symkey.cpp index 88642747b..2c98da051 100644 --- a/src/lib/base/symkey.cpp +++ b/src/lib/base/symkey.cpp @@ -6,7 +6,6 @@ */ #include <botan/symkey.h> -#include <botan/internal/xor_buf.h> #include <botan/rng.h> #include <botan/hex.h> #include <algorithm> diff --git a/src/lib/block/block_cipher.cpp b/src/lib/block/block_cipher.cpp index 60e6d0db2..e4d6c5817 100644 --- a/src/lib/block/block_cipher.cpp +++ b/src/lib/block/block_cipher.cpp @@ -7,7 +7,7 @@ #include <botan/block_cipher.h> #include <botan/cpuid.h> -#include <botan/internal/block_utils.h> +#include <botan/internal/algo_registry.h> #if defined(BOTAN_HAS_SIMD_32) #include <botan/internal/simd_32.h> @@ -162,6 +162,21 @@ std::vector<std::string> BlockCipher::providers(const std::string& algo_spec) return providers_of<BlockCipher>(BlockCipher::Spec(algo_spec)); } +#define BOTAN_REGISTER_BLOCK_CIPHER(name, maker) BOTAN_REGISTER_T(BlockCipher, name, maker) +#define BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(name) BOTAN_REGISTER_T_NOARGS(BlockCipher, name) + +#define BOTAN_REGISTER_BLOCK_CIPHER_1LEN(name, def) BOTAN_REGISTER_T_1LEN(BlockCipher, name, def) + +#define BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(type, name) \ + BOTAN_REGISTER_NAMED_T(BlockCipher, name, type, make_new_T<type>) +#define BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1LEN(type, name, def) \ + BOTAN_REGISTER_NAMED_T(BlockCipher, name, type, (make_new_T_1len<type,def>)) +#define BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1STR(type, name, def) \ + BOTAN_REGISTER_NAMED_T(BlockCipher, name, type, std::bind(make_new_T_1str<type>, std::placeholders::_1, def)) + +#define BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(cond, type, name, provider, pref) \ + BOTAN_COND_REGISTER_NAMED_T_NOARGS(cond, BlockCipher, type, name, provider, pref) + #if defined(BOTAN_HAS_AES) BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_128, "AES-128"); BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_192, "AES-192"); diff --git a/src/lib/block/block_utils.h b/src/lib/block/block_utils.h deleted file mode 100644 index c1eee27b1..000000000 --- a/src/lib/block/block_utils.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* Internal Block Cipher Utility Header -* (C) 2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_INTERNAL_BLOCK_CIPHER_UTILS_H__ -#define BOTAN_INTERNAL_BLOCK_CIPHER_UTILS_H__ - -#include <botan/block_cipher.h> -#include <botan/internal/algo_registry.h> - -namespace Botan { - -#define BOTAN_REGISTER_BLOCK_CIPHER(name, maker) BOTAN_REGISTER_T(BlockCipher, name, maker) -#define BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(name) BOTAN_REGISTER_T_NOARGS(BlockCipher, name) - -#define BOTAN_REGISTER_BLOCK_CIPHER_1LEN(name, def) BOTAN_REGISTER_T_1LEN(BlockCipher, name, def) - -#define BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(type, name) \ - BOTAN_REGISTER_NAMED_T(BlockCipher, name, type, make_new_T<type>) -#define BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1LEN(type, name, def) \ - BOTAN_REGISTER_NAMED_T(BlockCipher, name, type, (make_new_T_1len<type,def>)) -#define BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1STR(type, name, def) \ - BOTAN_REGISTER_NAMED_T(BlockCipher, name, type, std::bind(make_new_T_1str<type>, std::placeholders::_1, def)) - -#define BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(cond, type, name, provider, pref) \ - BOTAN_COND_REGISTER_NAMED_T_NOARGS(cond, BlockCipher, type, name, provider, pref) - -} - -#endif diff --git a/src/lib/block/des/desx.cpp b/src/lib/block/des/desx.cpp index 4ab568638..f6538748c 100644 --- a/src/lib/block/des/desx.cpp +++ b/src/lib/block/des/desx.cpp @@ -6,7 +6,6 @@ */ #include <botan/desx.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/block/info.txt b/src/lib/block/info.txt index e1aa52d85..30f7392ef 100644 --- a/src/lib/block/info.txt +++ b/src/lib/block/info.txt @@ -3,7 +3,3 @@ define BLOCK_CIPHER 20131128 <header:public> block_cipher.h </header:public> - -<header:internal> -block_utils.h -</header:internal> diff --git a/src/lib/block/lion/lion.cpp b/src/lib/block/lion/lion.cpp index 336828d89..bbd24a3c1 100644 --- a/src/lib/block/lion/lion.cpp +++ b/src/lib/block/lion/lion.cpp @@ -8,7 +8,6 @@ #include <botan/lion.h> #include <botan/lookup.h> #include <botan/parsing.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/hash/checksum/adler32/adler32.cpp b/src/lib/hash/checksum/adler32/adler32.cpp index aadc5d39f..f368b627c 100644 --- a/src/lib/hash/checksum/adler32/adler32.cpp +++ b/src/lib/hash/checksum/adler32/adler32.cpp @@ -5,8 +5,8 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/adler32.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/hash/checksum/crc24/crc24.cpp b/src/lib/hash/checksum/crc24/crc24.cpp index 054d23684..1484f643d 100644 --- a/src/lib/hash/checksum/crc24/crc24.cpp +++ b/src/lib/hash/checksum/crc24/crc24.cpp @@ -5,9 +5,8 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/crc24.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/hash/checksum/crc32/crc32.cpp b/src/lib/hash/checksum/crc32/crc32.cpp index ca9514c26..10d989cc6 100644 --- a/src/lib/hash/checksum/crc32/crc32.cpp +++ b/src/lib/hash/checksum/crc32/crc32.cpp @@ -5,8 +5,8 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/crc32.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/hash/comb4p/comb4p.cpp b/src/lib/hash/comb4p/comb4p.cpp index ef5f74a38..4222eaf54 100644 --- a/src/lib/hash/comb4p/comb4p.cpp +++ b/src/lib/hash/comb4p/comb4p.cpp @@ -6,7 +6,6 @@ */ #include <botan/comb4p.h> -#include <botan/internal/xor_buf.h> #include <stdexcept> namespace Botan { diff --git a/src/lib/hash/gost_3411/gost_3411.cpp b/src/lib/hash/gost_3411/gost_3411.cpp index fb1c39384..f8c9c0069 100644 --- a/src/lib/hash/gost_3411/gost_3411.cpp +++ b/src/lib/hash/gost_3411/gost_3411.cpp @@ -5,9 +5,7 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/gost_3411.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/hash/has160/has160.cpp b/src/lib/hash/has160/has160.cpp index dd4bc1428..6b12e10ad 100644 --- a/src/lib/hash/has160/has160.cpp +++ b/src/lib/hash/has160/has160.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/has160.h> namespace Botan { diff --git a/src/lib/hash/hash.cpp b/src/lib/hash/hash.cpp index f965cfde8..fe210705e 100644 --- a/src/lib/hash/hash.cpp +++ b/src/lib/hash/hash.cpp @@ -7,7 +7,7 @@ #include <botan/hash.h> #include <botan/cpuid.h> -#include <botan/internal/hash_utils.h> +#include <botan/internal/algo_registry.h> #if defined(BOTAN_HAS_ADLER32) #include <botan/adler32.h> @@ -106,6 +106,19 @@ HashFunction::HashFunction() {} HashFunction::~HashFunction() {} +#define BOTAN_REGISTER_HASH(name, maker) BOTAN_REGISTER_T(HashFunction, name, maker) +#define BOTAN_REGISTER_HASH_NOARGS(name) BOTAN_REGISTER_T_NOARGS(HashFunction, name) + +#define BOTAN_REGISTER_HASH_1LEN(name, def) BOTAN_REGISTER_T_1LEN(HashFunction, name, def) + +#define BOTAN_REGISTER_HASH_NAMED_NOARGS(type, name) \ + BOTAN_REGISTER_NAMED_T(HashFunction, name, type, make_new_T<type>) +#define BOTAN_REGISTER_HASH_NAMED_1LEN(type, name, def) \ + BOTAN_REGISTER_NAMED_T(HashFunction, name, type, (make_new_T_1len<type,def>)) + +#define BOTAN_REGISTER_HASH_NOARGS_IF(cond, type, name, provider, pref) \ + BOTAN_COND_REGISTER_NAMED_T_NOARGS(cond, HashFunction, type, name, provider, pref) + #if defined(BOTAN_HAS_ADLER32) BOTAN_REGISTER_HASH_NOARGS(Adler32); #endif diff --git a/src/lib/hash/hash_utils.h b/src/lib/hash/hash_utils.h deleted file mode 100644 index 3286b0087..000000000 --- a/src/lib/hash/hash_utils.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* Hash Utility Header -* (C) 2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_HASH_UTILS_H__ -#define BOTAN_HASH_UTILS_H__ - -#include <botan/hash.h> -#include <botan/internal/algo_registry.h> -#include <botan/loadstor.h> -#include <botan/rotate.h> - -namespace Botan { - -#define BOTAN_REGISTER_HASH(name, maker) BOTAN_REGISTER_T(HashFunction, name, maker) -#define BOTAN_REGISTER_HASH_NOARGS(name) BOTAN_REGISTER_T_NOARGS(HashFunction, name) - -#define BOTAN_REGISTER_HASH_1LEN(name, def) BOTAN_REGISTER_T_1LEN(HashFunction, name, def) - -#define BOTAN_REGISTER_HASH_NAMED_NOARGS(type, name) \ - BOTAN_REGISTER_NAMED_T(HashFunction, name, type, make_new_T<type>) -#define BOTAN_REGISTER_HASH_NAMED_1LEN(type, name, def) \ - BOTAN_REGISTER_NAMED_T(HashFunction, name, type, (make_new_T_1len<type,def>)) - -#define BOTAN_REGISTER_HASH_NOARGS_IF(cond, type, name, provider, pref) \ - BOTAN_COND_REGISTER_NAMED_T_NOARGS(cond, HashFunction, type, name, provider, pref) - -} - -#endif diff --git a/src/lib/hash/info.txt b/src/lib/hash/info.txt index 481b39b67..e71318b73 100644 --- a/src/lib/hash/info.txt +++ b/src/lib/hash/info.txt @@ -1,7 +1,3 @@ -<header:internal> -hash_utils.h -</header:internal> - <header:public> hash.h </header:public> diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp index 3cebe42da..39d0c822b 100644 --- a/src/lib/hash/keccak/keccak.cpp +++ b/src/lib/hash/keccak/keccak.cpp @@ -5,11 +5,9 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/keccak.h> #include <botan/parsing.h> #include <botan/exceptn.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/hash/md2/md2.cpp b/src/lib/hash/md2/md2.cpp index 8b8810941..8fe016962 100644 --- a/src/lib/hash/md2/md2.cpp +++ b/src/lib/hash/md2/md2.cpp @@ -5,9 +5,7 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/md2.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/hash/md4/md4.cpp b/src/lib/hash/md4/md4.cpp index f8cbb2b6b..6f4503ac0 100644 --- a/src/lib/hash/md4/md4.cpp +++ b/src/lib/hash/md4/md4.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/md4.h> namespace Botan { diff --git a/src/lib/hash/md5/md5.cpp b/src/lib/hash/md5/md5.cpp index 61d8aa980..89ca52419 100644 --- a/src/lib/hash/md5/md5.cpp +++ b/src/lib/hash/md5/md5.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/md5.h> namespace Botan { diff --git a/src/lib/hash/par_hash/par_hash.cpp b/src/lib/hash/par_hash/par_hash.cpp index 57140f0a8..5e970ab13 100644 --- a/src/lib/hash/par_hash/par_hash.cpp +++ b/src/lib/hash/par_hash/par_hash.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/par_hash.h> #include <botan/parsing.h> diff --git a/src/lib/hash/rmd128/rmd128.cpp b/src/lib/hash/rmd128/rmd128.cpp index 1f655199e..394bf2acf 100644 --- a/src/lib/hash/rmd128/rmd128.cpp +++ b/src/lib/hash/rmd128/rmd128.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/rmd128.h> namespace Botan { diff --git a/src/lib/hash/rmd160/rmd160.cpp b/src/lib/hash/rmd160/rmd160.cpp index c1b1032ae..56d063338 100644 --- a/src/lib/hash/rmd160/rmd160.cpp +++ b/src/lib/hash/rmd160/rmd160.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/rmd160.h> namespace Botan { diff --git a/src/lib/hash/sha1/sha160.cpp b/src/lib/hash/sha1/sha160.cpp index 04227c6bb..39d14f486 100644 --- a/src/lib/hash/sha1/sha160.cpp +++ b/src/lib/hash/sha1/sha160.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/sha160.h> namespace Botan { diff --git a/src/lib/hash/sha1_sse2/sha1_sse2.cpp b/src/lib/hash/sha1_sse2/sha1_sse2.cpp index fefea52af..2e0688185 100644 --- a/src/lib/hash/sha1_sse2/sha1_sse2.cpp +++ b/src/lib/hash/sha1_sse2/sha1_sse2.cpp @@ -7,7 +7,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/sha1_sse2.h> #include <botan/cpuid.h> #include <emmintrin.h> diff --git a/src/lib/hash/sha2_32/sha2_32.cpp b/src/lib/hash/sha2_32/sha2_32.cpp index a867e6dd0..5215164cf 100644 --- a/src/lib/hash/sha2_32/sha2_32.cpp +++ b/src/lib/hash/sha2_32/sha2_32.cpp @@ -6,7 +6,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/sha2_32.h> namespace Botan { diff --git a/src/lib/hash/sha2_64/sha2_64.cpp b/src/lib/hash/sha2_64/sha2_64.cpp index 98d16900b..d7c3f1325 100644 --- a/src/lib/hash/sha2_64/sha2_64.cpp +++ b/src/lib/hash/sha2_64/sha2_64.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/sha2_64.h> namespace Botan { diff --git a/src/lib/hash/skein/skein_512.cpp b/src/lib/hash/skein/skein_512.cpp index ce0e8353d..fe95dd7a5 100644 --- a/src/lib/hash/skein/skein_512.cpp +++ b/src/lib/hash/skein/skein_512.cpp @@ -5,11 +5,9 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/skein_512.h> #include <botan/parsing.h> #include <botan/exceptn.h> -#include <botan/internal/xor_buf.h> #include <algorithm> namespace Botan { diff --git a/src/lib/hash/tiger/tiger.cpp b/src/lib/hash/tiger/tiger.cpp index d724c3da8..79708a902 100644 --- a/src/lib/hash/tiger/tiger.cpp +++ b/src/lib/hash/tiger/tiger.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/tiger.h> #include <botan/exceptn.h> #include <botan/parsing.h> diff --git a/src/lib/hash/whirlpool/whirlpool.cpp b/src/lib/hash/whirlpool/whirlpool.cpp index edcc31d26..9bebdfa7c 100644 --- a/src/lib/hash/whirlpool/whirlpool.cpp +++ b/src/lib/hash/whirlpool/whirlpool.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/whrlpool.h> namespace Botan { diff --git a/src/lib/kdf/prf_tls/prf_tls.cpp b/src/lib/kdf/prf_tls/prf_tls.cpp index 08a2a0899..382f527ea 100644 --- a/src/lib/kdf/prf_tls/prf_tls.cpp +++ b/src/lib/kdf/prf_tls/prf_tls.cpp @@ -8,7 +8,6 @@ #include <botan/prf_tls.h> #include <botan/hmac.h> #include <botan/lookup.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/mac/cbc_mac/cbc_mac.cpp b/src/lib/mac/cbc_mac/cbc_mac.cpp index 70a7e4116..8133b9a6f 100644 --- a/src/lib/mac/cbc_mac/cbc_mac.cpp +++ b/src/lib/mac/cbc_mac/cbc_mac.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/mac_utils.h> #include <botan/cbc_mac.h> #include <botan/lookup.h> diff --git a/src/lib/mac/cmac/cmac.cpp b/src/lib/mac/cmac/cmac.cpp index f3f6c6296..0e42e3823 100644 --- a/src/lib/mac/cmac/cmac.cpp +++ b/src/lib/mac/cmac/cmac.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/mac_utils.h> #include <botan/cmac.h> #include <botan/lookup.h> diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp index 94f455c56..40da31887 100644 --- a/src/lib/mac/hmac/hmac.cpp +++ b/src/lib/mac/hmac/hmac.cpp @@ -6,7 +6,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/mac_utils.h> #include <botan/hmac.h> #include <botan/lookup.h> diff --git a/src/lib/mac/info.txt b/src/lib/mac/info.txt index 3faa16c11..ab7833857 100644 --- a/src/lib/mac/info.txt +++ b/src/lib/mac/info.txt @@ -3,7 +3,3 @@ define MAC 20150626 <header:public> mac.h </header:public> - -<header:internal> -mac_utils.h -</header:internal> diff --git a/src/lib/mac/mac.cpp b/src/lib/mac/mac.cpp index da94a1daf..8c1185c55 100644 --- a/src/lib/mac/mac.cpp +++ b/src/lib/mac/mac.cpp @@ -6,7 +6,7 @@ */ #include <botan/mac.h> -#include <botan/internal/mac_utils.h> +#include <botan/internal/algo_registry.h> #include <botan/mem_ops.h> #if defined(BOTAN_HAS_CBC_MAC) @@ -61,7 +61,6 @@ bool MessageAuthenticationCode::verify_mac(const byte mac[], size_t length) return same_mem(our_mac.data(), mac, length); } - #if defined(BOTAN_HAS_CBC_MAC) BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "CBC-MAC", CBC_MAC, CBC_MAC::make); #endif @@ -75,7 +74,7 @@ BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "HMAC", HMAC, HMAC::make); #endif #if defined(BOTAN_HAS_POLY1305) -BOTAN_REGISTER_MAC_NOARGS(Poly1305); +BOTAN_REGISTER_T_NOARGS(MessageAuthenticationCode, Poly1305); #endif #if defined(BOTAN_HAS_SIPHASH) @@ -83,7 +82,7 @@ BOTAN_REGISTER_NAMED_T_2LEN(MessageAuthenticationCode, SipHash, "SipHash", "base #endif #if defined(BOTAN_HAS_ANSI_X919_MAC) -BOTAN_REGISTER_MAC_NAMED_NOARGS(ANSI_X919_MAC, "X9.19-MAC"); +BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, "X9.19-MAC", ANSI_X919_MAC, make_new_T<ANSI_X919_MAC>); #endif } diff --git a/src/lib/mac/mac_utils.h b/src/lib/mac/mac_utils.h deleted file mode 100644 index 5b22da4a3..000000000 --- a/src/lib/mac/mac_utils.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* Authentication Code Utility Header -* (C) 2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_MAC_UTILS_H__ -#define BOTAN_MAC_UTILS_H__ - -#include <botan/internal/algo_registry.h> -#include <botan/internal/xor_buf.h> -#include <botan/loadstor.h> -#include <botan/rotate.h> -#include <algorithm> - -namespace Botan { - -#define BOTAN_REGISTER_MAC(name, maker) BOTAN_REGISTER_T(MessageAuthenticationCode, name, maker) -#define BOTAN_REGISTER_MAC_NOARGS(name) BOTAN_REGISTER_T_NOARGS(MessageAuthenticationCode, name) - -#define BOTAN_REGISTER_MAC_1LEN(name, def) BOTAN_REGISTER_T_1LEN(MessageAuthenticationCode, name, def) - -#define BOTAN_REGISTER_MAC_NAMED_NOARGS(type, name) \ - BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, name, type, make_new_T<type>) - -#define BOTAN_REGISTER_MAC_NAMED_1LEN(type, name, def) \ - BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, name, type, (make_new_T_1len<type,def>)) -#define BOTAN_REGISTER_MAC_NAMED_1STR(type, name, def) \ - BOTAN_REGISTER_NAMED_T(MessageAuthenticationCode, name, type, \ - std::bind(make_new_T_1str<type>, std::placeholders::_1, def)); - -} - -#endif diff --git a/src/lib/mac/poly1305/poly1305.cpp b/src/lib/mac/poly1305/poly1305.cpp index 1a072c6b4..0a62808f6 100644 --- a/src/lib/mac/poly1305/poly1305.cpp +++ b/src/lib/mac/poly1305/poly1305.cpp @@ -8,7 +8,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/mac_utils.h> #include <botan/poly1305.h> #include <botan/loadstor.h> #include <botan/mul128.h> diff --git a/src/lib/mac/siphash/siphash.cpp b/src/lib/mac/siphash/siphash.cpp index 689d03c13..4a9ffe8ea 100644 --- a/src/lib/mac/siphash/siphash.cpp +++ b/src/lib/mac/siphash/siphash.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/mac_utils.h> #include <botan/siphash.h> namespace Botan { diff --git a/src/lib/mac/x919_mac/x919_mac.cpp b/src/lib/mac/x919_mac/x919_mac.cpp index a58b07248..2e1fa374f 100644 --- a/src/lib/mac/x919_mac/x919_mac.cpp +++ b/src/lib/mac/x919_mac/x919_mac.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/mac_utils.h> #include <botan/x919_mac.h> #include <botan/lookup.h> diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp index 0a068c53e..2acfabb99 100644 --- a/src/lib/math/bigint/bigint.cpp +++ b/src/lib/math/bigint/bigint.cpp @@ -7,7 +7,7 @@ #include <botan/bigint.h> #include <botan/internal/mp_core.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <botan/parsing.h> #include <botan/internal/rounding.h> #include <botan/internal/bit_ops.h> diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h index e3200ca9d..2963ba35d 100644 --- a/src/lib/math/bigint/bigint.h +++ b/src/lib/math/bigint/bigint.h @@ -12,7 +12,7 @@ #include <botan/rng.h> #include <botan/secmem.h> #include <botan/mp_types.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <iosfwd> namespace Botan { diff --git a/src/lib/misc/aont/package.cpp b/src/lib/misc/aont/package.cpp index 125b3842e..a3be898d8 100644 --- a/src/lib/misc/aont/package.cpp +++ b/src/lib/misc/aont/package.cpp @@ -9,8 +9,7 @@ #include <botan/package.h> #include <botan/filters.h> #include <botan/ctr.h> -#include <botan/get_byte.h> -#include <botan/internal/xor_buf.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/misc/cryptobox/cryptobox.cpp b/src/lib/misc/cryptobox/cryptobox.cpp index d7e7bb72b..752561248 100644 --- a/src/lib/misc/cryptobox/cryptobox.cpp +++ b/src/lib/misc/cryptobox/cryptobox.cpp @@ -13,7 +13,7 @@ #include <botan/hmac.h> #include <botan/pbkdf2.h> #include <botan/pem.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <botan/mem_ops.h> namespace Botan { diff --git a/src/lib/misc/rfc3394/rfc3394.cpp b/src/lib/misc/rfc3394/rfc3394.cpp index a199cc599..3e1ed8b40 100644 --- a/src/lib/misc/rfc3394/rfc3394.cpp +++ b/src/lib/misc/rfc3394/rfc3394.cpp @@ -10,7 +10,6 @@ #include <botan/block_cipher.h> #include <botan/loadstor.h> #include <botan/exceptn.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/modes/mode_utils.h b/src/lib/modes/mode_utils.h index d8c185f7a..b93884206 100644 --- a/src/lib/modes/mode_utils.h +++ b/src/lib/modes/mode_utils.h @@ -13,7 +13,6 @@ #include <botan/lookup.h> #include <botan/block_cipher.h> #include <botan/loadstor.h> -#include <botan/internal/xor_buf.h> #include <botan/internal/rounding.h> #include <botan/internal/bit_ops.h> #include <algorithm> diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp index a5b7f011e..480b43d4b 100644 --- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp +++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp @@ -7,8 +7,7 @@ #include <botan/pbkdf2.h> #include <botan/lookup.h> -#include <botan/get_byte.h> -#include <botan/internal/xor_buf.h> +#include <botan/loadstor.h> #include <botan/internal/rounding.h> namespace Botan { diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp index 153ef8922..4804a8a81 100644 --- a/src/lib/pk_pad/eme.cpp +++ b/src/lib/pk_pad/eme.cpp @@ -6,7 +6,7 @@ */ #include <botan/eme.h> -#include <botan/internal/pad_utils.h> +#include <botan/internal/algo_registry.h> #if defined(BOTAN_HAS_EME_OAEP) #include <botan/oaep.h> @@ -22,6 +22,12 @@ namespace Botan { +#define BOTAN_REGISTER_EME(name, maker) BOTAN_REGISTER_T(EME, name, maker) +#define BOTAN_REGISTER_EME_NOARGS(name) BOTAN_REGISTER_T_NOARGS(EME, name) + +#define BOTAN_REGISTER_EME_NAMED_NOARGS(type, name) \ + BOTAN_REGISTER_NAMED_T(EME, name, type, make_new_T<type>) + #if defined(BOTAN_HAS_EME_OAEP) BOTAN_REGISTER_NAMED_T(EME, "OAEP", OAEP, OAEP::make); #endif diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp index 9682d9b6e..e20286a7d 100644 --- a/src/lib/pk_pad/emsa.cpp +++ b/src/lib/pk_pad/emsa.cpp @@ -5,7 +5,7 @@ */ #include <botan/emsa.h> -#include <botan/internal/pad_utils.h> +#include <botan/internal/algo_registry.h> #if defined(BOTAN_HAS_EMSA1) #include <botan/emsa1.h> @@ -45,6 +45,15 @@ EMSA* get_emsa(const std::string& algo_spec) throw Algorithm_Not_Found(algo_spec); } +#define BOTAN_REGISTER_EMSA_NAMED_NOARGS(type, name) \ + BOTAN_REGISTER_NAMED_T(EMSA, name, type, make_new_T<type>) + +#define BOTAN_REGISTER_EMSA(name, maker) BOTAN_REGISTER_T(EMSA, name, maker) +#define BOTAN_REGISTER_EMSA_NOARGS(name) BOTAN_REGISTER_T_NOARGS(EMSA, name) + +#define BOTAN_REGISTER_EMSA_1HASH(type, name) \ + BOTAN_REGISTER_NAMED_T(EMSA, name, type, (make_new_T_1X<type, HashFunction>)) + #if defined(BOTAN_HAS_EMSA1) BOTAN_REGISTER_EMSA_1HASH(EMSA1, "EMSA1"); #endif diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp index ecb7a6f29..5e8462d4f 100644 --- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp +++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/emsa_pkcs1.h> #include <botan/hash_id.h> #include <botan/lookup.h> diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp index 287acb233..4560bd3c3 100644 --- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp +++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/emsa_raw.h> namespace Botan { diff --git a/src/lib/pk_pad/info.txt b/src/lib/pk_pad/info.txt index cc3a3fb3b..8cb935faa 100644 --- a/src/lib/pk_pad/info.txt +++ b/src/lib/pk_pad/info.txt @@ -10,7 +10,3 @@ rng eme.h emsa.h </header:public> - -<header:internal> -pad_utils.h -</header:internal> diff --git a/src/lib/pk_pad/mgf1/mgf1.cpp b/src/lib/pk_pad/mgf1/mgf1.cpp index 950961f89..34bc4a9a9 100644 --- a/src/lib/pk_pad/mgf1/mgf1.cpp +++ b/src/lib/pk_pad/mgf1/mgf1.cpp @@ -7,7 +7,6 @@ #include <botan/mgf1.h> #include <botan/exceptn.h> -#include <botan/internal/xor_buf.h> #include <algorithm> namespace Botan { diff --git a/src/lib/pk_pad/pad_utils.h b/src/lib/pk_pad/pad_utils.h deleted file mode 100644 index ba2de65ea..000000000 --- a/src/lib/pk_pad/pad_utils.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Public Key Padding Utility Header -* (C) 2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_PK_PAD_UTILS_H__ -#define BOTAN_PK_PAD_UTILS_H__ - -#include <botan/internal/algo_registry.h> - -namespace Botan { - -#define BOTAN_REGISTER_EME(name, maker) BOTAN_REGISTER_T(EME, name, maker) -#define BOTAN_REGISTER_EME_NOARGS(name) BOTAN_REGISTER_T_NOARGS(EME, name) - -#define BOTAN_REGISTER_EME_NAMED_NOARGS(type, name) \ - BOTAN_REGISTER_NAMED_T(EME, name, type, make_new_T<type>) - -#define BOTAN_REGISTER_EMSA_1HASH_1LEN(type, name) \ - BOTAN_REGISTER_NAMED_T(EMSA, name, type, (make_new_T_1X_1len<type, HashFunction>)) - -#define BOTAN_REGISTER_EME_NAMED_1LEN(type, name, def) \ - BOTAN_REGISTER_NAMED_T(EME, name, type, (make_new_T_1len<type,def>)) -#define BOTAN_REGISTER_EME_NAMED_1STR(type, name, def) \ - BOTAN_REGISTER_NAMED_T(EME, name, type, \ - std::bind(make_new_T_1str<type>, std::placeholders::_1, def)); - -#define BOTAN_REGISTER_EMSA_NAMED_NOARGS(type, name) \ - BOTAN_REGISTER_NAMED_T(EMSA, name, type, make_new_T<type>) - -#define BOTAN_REGISTER_EMSA(name, maker) BOTAN_REGISTER_T(EMSA, name, maker) -#define BOTAN_REGISTER_EMSA_NOARGS(name) BOTAN_REGISTER_T_NOARGS(EMSA, name) - -#define BOTAN_REGISTER_EMSA_1HASH(type, name) \ - BOTAN_REGISTER_NAMED_T(EMSA, name, type, (make_new_T_1X<type, HashFunction>)) - -} - -#endif diff --git a/src/lib/pubkey/dlies/dlies.cpp b/src/lib/pubkey/dlies/dlies.cpp index 4b1a63f2c..708064d27 100644 --- a/src/lib/pubkey/dlies/dlies.cpp +++ b/src/lib/pubkey/dlies/dlies.cpp @@ -6,7 +6,6 @@ */ #include <botan/dlies.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/pubkey/mce/binary_matrix.cpp b/src/lib/pubkey/mce/binary_matrix.cpp index 12c842669..45c9aab13 100644 --- a/src/lib/pubkey/mce/binary_matrix.cpp +++ b/src/lib/pubkey/mce/binary_matrix.cpp @@ -10,7 +10,6 @@ */ #include <botan/internal/binary_matrix.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/pubkey/mce/mceliece.cpp b/src/lib/pubkey/mce/mceliece.cpp index 6bbe93ce3..08b3f13a3 100644 --- a/src/lib/pubkey/mce/mceliece.cpp +++ b/src/lib/pubkey/mce/mceliece.cpp @@ -16,7 +16,6 @@ #include <botan/code_based_util.h> #include <botan/goppa_code.h> #include <botan/internal/bit_ops.h> -#include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/lib/rng/hmac_rng/hmac_rng.cpp b/src/lib/rng/hmac_rng/hmac_rng.cpp index 36003385a..5456b3bac 100644 --- a/src/lib/rng/hmac_rng/hmac_rng.cpp +++ b/src/lib/rng/hmac_rng/hmac_rng.cpp @@ -6,9 +6,7 @@ */ #include <botan/hmac_rng.h> -#include <botan/get_byte.h> #include <botan/entropy_src.h> -#include <botan/internal/xor_buf.h> #include <algorithm> #include <chrono> diff --git a/src/lib/rng/x931_rng/x931_rng.cpp b/src/lib/rng/x931_rng/x931_rng.cpp index 976e324c3..d531cf4a9 100644 --- a/src/lib/rng/x931_rng/x931_rng.cpp +++ b/src/lib/rng/x931_rng/x931_rng.cpp @@ -6,7 +6,6 @@ */ #include <botan/x931_rng.h> -#include <botan/internal/xor_buf.h> #include <algorithm> namespace Botan { diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp index 9aa3c2a73..0a32c720b 100644 --- a/src/lib/stream/chacha/chacha.cpp +++ b/src/lib/stream/chacha/chacha.cpp @@ -5,8 +5,8 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/stream_utils.h> #include <botan/chacha.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp index e6d4b9d3e..3b573448b 100644 --- a/src/lib/stream/ctr/ctr.cpp +++ b/src/lib/stream/ctr/ctr.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/stream_utils.h> #include <botan/ctr.h> #include <botan/lookup.h> diff --git a/src/lib/stream/info.txt b/src/lib/stream/info.txt index 8dc30936d..59b5d577a 100644 --- a/src/lib/stream/info.txt +++ b/src/lib/stream/info.txt @@ -3,7 +3,3 @@ define STREAM_CIPHER 20131128 <header:public> stream_cipher.h </header:public> - -<header:internal> -stream_utils.h -</header:internal> diff --git a/src/lib/stream/ofb/ofb.cpp b/src/lib/stream/ofb/ofb.cpp index 1979c676f..1e6615fc0 100644 --- a/src/lib/stream/ofb/ofb.cpp +++ b/src/lib/stream/ofb/ofb.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/stream_utils.h> #include <botan/ofb.h> #include <botan/lookup.h> diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp index 31fd2cca0..6146e2818 100644 --- a/src/lib/stream/rc4/rc4.cpp +++ b/src/lib/stream/rc4/rc4.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/stream_utils.h> #include <botan/rc4.h> namespace Botan { diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp index 141d9e51e..1d3fe3d28 100644 --- a/src/lib/stream/salsa20/salsa20.cpp +++ b/src/lib/stream/salsa20/salsa20.cpp @@ -5,8 +5,8 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/stream_utils.h> #include <botan/salsa20.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/stream/stream_cipher.cpp b/src/lib/stream/stream_cipher.cpp index 3b8d35bc7..91b68b38a 100644 --- a/src/lib/stream/stream_cipher.cpp +++ b/src/lib/stream/stream_cipher.cpp @@ -6,7 +6,7 @@ */ #include <botan/stream_cipher.h> -#include <botan/internal/stream_utils.h> +#include <botan/internal/algo_registry.h> #if defined(BOTAN_HAS_CHACHA) #include <botan/chacha.h> @@ -51,11 +51,11 @@ void StreamCipher::set_iv(const byte[], size_t iv_len) } #if defined(BOTAN_HAS_CHACHA) -BOTAN_REGISTER_STREAM_CIPHER_NOARGS(ChaCha); +BOTAN_REGISTER_T_NOARGS(StreamCipher, ChaCha); #endif #if defined(BOTAN_HAS_SALSA20) -BOTAN_REGISTER_STREAM_CIPHER_NOARGS(Salsa20); +BOTAN_REGISTER_T_NOARGS(StreamCipher, Salsa20); #endif #if defined(BOTAN_HAS_CTR_BE) diff --git a/src/lib/stream/stream_utils.h b/src/lib/stream/stream_utils.h deleted file mode 100644 index 8ba8d4b01..000000000 --- a/src/lib/stream/stream_utils.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* Stream Cipher Utility Header -* (C) 2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_STREAM_CIPHER_UTILS_H__ -#define BOTAN_STREAM_CIPHER_UTILS_H__ - -#include <botan/stream_cipher.h> -#include <botan/internal/algo_registry.h> -#include <botan/loadstor.h> -#include <botan/rotate.h> -#include <botan/internal/xor_buf.h> -#include <algorithm> - -namespace Botan { - -#define BOTAN_REGISTER_STREAM_CIPHER(name, maker) BOTAN_REGISTER_T(StreamCipher, name, maker) -#define BOTAN_REGISTER_STREAM_CIPHER_NOARGS(name) BOTAN_REGISTER_T_NOARGS(StreamCipher, name) - -#define BOTAN_REGISTER_STREAM_CIPHER_1LEN(name, def) BOTAN_REGISTER_T_1LEN(StreamCipher, name, def) - -#define BOTAN_REGISTER_STREAM_CIPHER_NAMED_NOARGS(type, name) BOTAN_REGISTER_NAMED_T(StreamCipher, name, type, make_new_T<type>) -#define BOTAN_REGISTER_STREAM_CIPHER_NAMED_1LEN(type, name, def) \ - BOTAN_REGISTER_NAMED_T(StreamCipher, name, type, (make_new_T_1len<type,def>)) - -} - -#endif diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp index 3ba02f039..53521c5da 100644 --- a/src/lib/tls/tls_record.cpp +++ b/src/lib/tls/tls_record.cpp @@ -12,7 +12,6 @@ #include <botan/internal/tls_seq_numbers.h> #include <botan/internal/tls_session_key.h> #include <botan/internal/rounding.h> -#include <botan/internal/xor_buf.h> #include <botan/lookup.h> #include <botan/rng.h> diff --git a/src/lib/tls/tls_version.h b/src/lib/tls/tls_version.h index a025b27ba..73968bb8c 100644 --- a/src/lib/tls/tls_version.h +++ b/src/lib/tls/tls_version.h @@ -8,7 +8,7 @@ #ifndef BOTAN_TLS_PROTOCOL_VERSION_H__ #define BOTAN_TLS_PROTOCOL_VERSION_H__ -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <string> namespace Botan { diff --git a/src/lib/utils/cpuid.cpp b/src/lib/utils/cpuid.cpp index 817bf4f52..218b6553c 100644 --- a/src/lib/utils/cpuid.cpp +++ b/src/lib/utils/cpuid.cpp @@ -7,7 +7,7 @@ #include <botan/cpuid.h> #include <botan/types.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <botan/mem_ops.h> #include <ostream> diff --git a/src/lib/utils/get_byte.h b/src/lib/utils/get_byte.h index 0846befbd..14f55b97b 100644 --- a/src/lib/utils/get_byte.h +++ b/src/lib/utils/get_byte.h @@ -12,18 +12,6 @@ namespace Botan { -/** -* Byte extraction -* @param byte_num which byte to extract, 0 == highest byte -* @param input the value to extract from -* @return byte byte_num of input -*/ -template<typename T> inline byte get_byte(size_t byte_num, T input) - { - return static_cast<byte>( - input >> ((sizeof(T)-1-(byte_num&(sizeof(T)-1))) << 3) - ); - } } diff --git a/src/lib/utils/info.txt b/src/lib/utils/info.txt index b8c7b85d2..7d3216b1c 100644 --- a/src/lib/utils/info.txt +++ b/src/lib/utils/info.txt @@ -1,4 +1,4 @@ -define UTIL_FUNCTIONS 20140123 +define UTIL_FUNCTIONS 20150919 load_on always @@ -10,7 +10,6 @@ charset.h cpuid.h database.h exceptn.h -get_byte.h loadstor.h mem_ops.h mul128.h @@ -29,5 +28,4 @@ rounding.h semaphore.h stl_util.h ta_utils.h -xor_buf.h </header:internal> diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h index d3871480c..53700fc86 100644 --- a/src/lib/utils/loadstor.h +++ b/src/lib/utils/loadstor.h @@ -11,7 +11,6 @@ #include <botan/types.h> #include <botan/bswap.h> -#include <botan/get_byte.h> #include <botan/mem_ops.h> #include <vector> @@ -40,6 +39,19 @@ namespace Botan { /** +* Byte extraction +* @param byte_num which byte to extract, 0 == highest byte +* @param input the value to extract from +* @return byte byte_num of input +*/ +template<typename T> inline byte get_byte(size_t byte_num, T input) + { + return static_cast<byte>( + input >> ((sizeof(T)-1-(byte_num&(sizeof(T)-1))) << 3) + ); + } + +/** * Make a u16bit from two bytes * @param i0 the first byte * @param i1 the second byte diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h index f9e39fa31..6ea7bdafe 100644 --- a/src/lib/utils/mem_ops.h +++ b/src/lib/utils/mem_ops.h @@ -10,6 +10,7 @@ #include <botan/types.h> #include <cstring> +#include <vector> namespace Botan { @@ -70,6 +71,132 @@ template<typename T> inline bool same_mem(const T* p1, const T* p2, size_t n) return difference == 0; } +/** +* XOR arrays. Postcondition out[i] = in[i] ^ out[i] forall i = 0...length +* @param out the input/output buffer +* @param in the read-only input buffer +* @param length the length of the buffers +*/ +template<typename T> +void xor_buf(T out[], const T in[], size_t length) + { + while(length >= 8) + { + out[0] ^= in[0]; out[1] ^= in[1]; + out[2] ^= in[2]; out[3] ^= in[3]; + out[4] ^= in[4]; out[5] ^= in[5]; + out[6] ^= in[6]; out[7] ^= in[7]; + + out += 8; in += 8; length -= 8; + } + + for(size_t i = 0; i != length; ++i) + out[i] ^= in[i]; + } + +/** +* XOR arrays. Postcondition out[i] = in[i] ^ in2[i] forall i = 0...length +* @param out the output buffer +* @param in the first input buffer +* @param in2 the second output buffer +* @param length the length of the three buffers +*/ +template<typename T> void xor_buf(T out[], + const T in[], + const T in2[], + size_t length) + { + while(length >= 8) + { + out[0] = in[0] ^ in2[0]; + out[1] = in[1] ^ in2[1]; + out[2] = in[2] ^ in2[2]; + out[3] = in[3] ^ in2[3]; + out[4] = in[4] ^ in2[4]; + out[5] = in[5] ^ in2[5]; + out[6] = in[6] ^ in2[6]; + out[7] = in[7] ^ in2[7]; + + in += 8; in2 += 8; out += 8; length -= 8; + } + + for(size_t i = 0; i != length; ++i) + out[i] = in[i] ^ in2[i]; + } + +#if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK + +template<> +inline void xor_buf<byte>(byte out[], const byte in[], size_t length) + { + while(length >= 8) + { + *reinterpret_cast<u64bit*>(out) ^= *reinterpret_cast<const u64bit*>(in); + out += 8; in += 8; length -= 8; + } + + for(size_t i = 0; i != length; ++i) + out[i] ^= in[i]; + } + +template<> +inline void xor_buf<byte>(byte out[], + const byte in[], + const byte in2[], + size_t length) + { + while(length >= 8) + { + *reinterpret_cast<u64bit*>(out) = + *reinterpret_cast<const u64bit*>(in) ^ + *reinterpret_cast<const u64bit*>(in2); + + in += 8; in2 += 8; out += 8; length -= 8; + } + + for(size_t i = 0; i != length; ++i) + out[i] = in[i] ^ in2[i]; + } + +#endif + +template<typename Alloc, typename Alloc2> +void xor_buf(std::vector<byte, Alloc>& out, + const std::vector<byte, Alloc2>& in, + size_t n) + { + xor_buf(out.data(), in.data(), n); + } + +template<typename Alloc> +void xor_buf(std::vector<byte, Alloc>& out, + const byte* in, + size_t n) + { + xor_buf(out.data(), in, n); + } + +template<typename Alloc, typename Alloc2> +void xor_buf(std::vector<byte, Alloc>& out, + const byte* in, + const std::vector<byte, Alloc2>& in2, + size_t n) + { + xor_buf(out.data(), in, in2.data(), n); + } + +template<typename T, typename Alloc, typename Alloc2> +std::vector<T, Alloc>& +operator^=(std::vector<T, Alloc>& out, + const std::vector<T, Alloc2>& in) + { + if(out.size() < in.size()) + out.resize(in.size()); + + xor_buf(out.data(), in.data(), in.size()); + return out; + } + } #endif diff --git a/src/lib/utils/parsing.cpp b/src/lib/utils/parsing.cpp index 4feea8d60..ea89c8e5f 100644 --- a/src/lib/utils/parsing.cpp +++ b/src/lib/utils/parsing.cpp @@ -9,7 +9,7 @@ #include <botan/parsing.h> #include <botan/exceptn.h> #include <botan/charset.h> -#include <botan/get_byte.h> +#include <botan/loadstor.h> #include <limits> #include <set> #include <stdexcept> diff --git a/src/lib/vendor/openssl/openssl_block.cpp b/src/lib/vendor/openssl/openssl_block.cpp index b74f184c7..701317ed8 100644 --- a/src/lib/vendor/openssl/openssl_block.cpp +++ b/src/lib/vendor/openssl/openssl_block.cpp @@ -1,11 +1,11 @@ /* -* OpenSSL Block Cipher +* Block Ciphers via OpenSSL * (C) 1999-2010,2015 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/block_utils.h> +#include <botan/block_cipher.h> #include <botan/internal/openssl.h> #include <openssl/evp.h> diff --git a/src/lib/vendor/openssl/openssl_hash.cpp b/src/lib/vendor/openssl/openssl_hash.cpp index 6e055c0e6..f517ae6af 100644 --- a/src/lib/vendor/openssl/openssl_hash.cpp +++ b/src/lib/vendor/openssl/openssl_hash.cpp @@ -5,7 +5,6 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/hash_utils.h> #include <botan/internal/openssl.h> #include <openssl/evp.h> diff --git a/src/lib/vendor/openssl/openssl_rc4.cpp b/src/lib/vendor/openssl/openssl_rc4.cpp index ac30cd288..5156ff6cc 100644 --- a/src/lib/vendor/openssl/openssl_rc4.cpp +++ b/src/lib/vendor/openssl/openssl_rc4.cpp @@ -5,7 +5,7 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/stream_utils.h> +#include <botan/internal/algo_registry.h> #include <botan/internal/openssl.h> #include <botan/parsing.h> #include <openssl/rc4.h> |