diff options
author | lloyd <[email protected]> | 2009-12-21 13:51:05 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-12-21 13:51:05 +0000 |
commit | 75f32d61c6a78e4e63cfadd084730f20b5896493 (patch) | |
tree | 4a52d3009f012ec5761f1c1218e18efbe07eef0b /src | |
parent | f3f36611db8c3f6c67c818d454973a0165b0fcf2 (diff) |
Un-internal loadstor.h (and its header deps, rotate.h and
bswap.h); too many external apps rely on loadstor.h existing.
Define 64-bit generic bswap in terms of 32-bit bswap, since it's
not much slower if 32-bit is also generic, and much faster if
it's not. This may be quite helpful on 32-bit x86 in particular.
Change formulation of generic 32-bit bswap. It may be faster or
slower depending on the CPU, especially the latency and throuput
of rotate instructions, but should be faster on an ideally
superscalar processor with rotate instructions (ie, what I expect
future CPUs to look more like).
Diffstat (limited to 'src')
72 files changed, 132 insertions, 118 deletions
diff --git a/src/asn1/asn1_alt.cpp b/src/asn1/asn1_alt.cpp index 6e9adf47b..9fe159356 100644 --- a/src/asn1/asn1_alt.cpp +++ b/src/asn1/asn1_alt.cpp @@ -13,7 +13,7 @@ #include <botan/internal/stl_util.h> #include <botan/charset.h> #include <botan/parsing.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp index a61bbf00a..b34bf8ca2 100644 --- a/src/asn1/ber_dec.cpp +++ b/src/asn1/ber_dec.cpp @@ -7,7 +7,7 @@ #include <botan/ber_dec.h> #include <botan/bigint.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/asn1/der_enc.cpp b/src/asn1/der_enc.cpp index 37ba79802..3c318c291 100644 --- a/src/asn1/der_enc.cpp +++ b/src/asn1/der_enc.cpp @@ -8,7 +8,7 @@ #include <botan/der_enc.h> #include <botan/asn1_int.h> #include <botan/bigint.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/bit_ops.h> #include <botan/parsing.h> #include <algorithm> diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp index 69d3a40ec..b6060412e 100644 --- a/src/benchmark/benchmark.cpp +++ b/src/benchmark/benchmark.cpp @@ -14,6 +14,8 @@ #include <botan/time.h> #include <memory> +#include <iostream> + namespace Botan { namespace { @@ -26,15 +28,15 @@ std::pair<u64bit, u64bit> bench_buf_comp(BufferedComputation* buf_comp, const byte buf[], u32bit buf_len) { u64bit reps = 0; - - const u64bit start = get_nanoseconds_clock(); u64bit nanoseconds_used = 0; while(nanoseconds_used < nanoseconds_max) { + const u64bit start = get_nanoseconds_clock(); buf_comp->update(buf, buf_len); + nanoseconds_used += get_nanoseconds_clock() - start; + ++reps; - nanoseconds_used = get_nanoseconds_clock() - start; } return std::make_pair(reps * buf_len, nanoseconds_used); @@ -51,18 +53,17 @@ bench_block_cipher(BlockCipher* block_cipher, const u32bit in_blocks = buf_len / block_cipher->BLOCK_SIZE; u64bit reps = 0; - - const u64bit start = get_nanoseconds_clock(); u64bit nanoseconds_used = 0; block_cipher->set_key(buf, block_cipher->MAXIMUM_KEYLENGTH); while(nanoseconds_used < nanoseconds_max) { + const u64bit start = get_nanoseconds_clock(); block_cipher->encrypt_n(buf, buf, in_blocks); + nanoseconds_used += get_nanoseconds_clock() - start; ++reps; - nanoseconds_used = get_nanoseconds_clock() - start; } return std::make_pair(reps * in_blocks * block_cipher->BLOCK_SIZE, @@ -78,17 +79,17 @@ bench_stream_cipher(StreamCipher* stream_cipher, byte buf[], u32bit buf_len) { u64bit reps = 0; - - const u64bit start = get_nanoseconds_clock(); u64bit nanoseconds_used = 0; stream_cipher->set_key(buf, stream_cipher->MAXIMUM_KEYLENGTH); while(nanoseconds_used < nanoseconds_max) { + const u64bit start = get_nanoseconds_clock(); stream_cipher->cipher1(buf, buf_len); + nanoseconds_used += get_nanoseconds_clock() - start; + ++reps; - nanoseconds_used = get_nanoseconds_clock() - start; } return std::make_pair(reps * buf_len, nanoseconds_used); diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp index d972d921a..721c4ac75 100644 --- a/src/block/aes/aes.cpp +++ b/src/block/aes/aes.cpp @@ -6,7 +6,8 @@ */ #include <botan/aes.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/aes_intel/aes_intel.cpp b/src/block/aes_intel/aes_intel.cpp index 5ccf3fc5d..3d3683d7d 100644 --- a/src/block/aes_intel/aes_intel.cpp +++ b/src/block/aes_intel/aes_intel.cpp @@ -6,7 +6,7 @@ */ #include <botan/aes_intel.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <wmmintrin.h> namespace Botan { diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp index 6a00caa90..d0b182a84 100644 --- a/src/block/blowfish/blowfish.cpp +++ b/src/block/blowfish/blowfish.cpp @@ -6,7 +6,7 @@ */ #include <botan/blowfish.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/cast/cast128.cpp b/src/block/cast/cast128.cpp index 2d876d31e..887dcf994 100644 --- a/src/block/cast/cast128.cpp +++ b/src/block/cast/cast128.cpp @@ -6,8 +6,8 @@ */ #include <botan/cast128.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/cast/cast256.cpp b/src/block/cast/cast256.cpp index 832c170aa..7a4a4e805 100644 --- a/src/block/cast/cast256.cpp +++ b/src/block/cast/cast256.cpp @@ -6,8 +6,8 @@ */ #include <botan/cast256.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp index 3bc970735..bbe564827 100644 --- a/src/block/des/des.cpp +++ b/src/block/des/des.cpp @@ -6,7 +6,8 @@ */ #include <botan/des.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/gost_28147/gost_28147.cpp b/src/block/gost_28147/gost_28147.cpp index 8340b8ccc..2dfce0473 100644 --- a/src/block/gost_28147/gost_28147.cpp +++ b/src/block/gost_28147/gost_28147.cpp @@ -6,7 +6,8 @@ */ #include <botan/gost_28147.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/idea/idea.cpp b/src/block/idea/idea.cpp index 84c401475..fb5fe83f1 100644 --- a/src/block/idea/idea.cpp +++ b/src/block/idea/idea.cpp @@ -6,7 +6,7 @@ */ #include <botan/idea.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/kasumi/kasumi.cpp b/src/block/kasumi/kasumi.cpp index e22948293..dff6db13c 100644 --- a/src/block/kasumi/kasumi.cpp +++ b/src/block/kasumi/kasumi.cpp @@ -6,8 +6,8 @@ */ #include <botan/kasumi.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/mars/mars.cpp b/src/block/mars/mars.cpp index 526073cef..6b73ea054 100644 --- a/src/block/mars/mars.cpp +++ b/src/block/mars/mars.cpp @@ -6,8 +6,8 @@ */ #include <botan/mars.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/misty1/misty1.cpp b/src/block/misty1/misty1.cpp index fcd647a76..8a92824cc 100644 --- a/src/block/misty1/misty1.cpp +++ b/src/block/misty1/misty1.cpp @@ -6,7 +6,7 @@ */ #include <botan/misty1.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/parsing.h> namespace Botan { diff --git a/src/block/noekeon/noekeon.cpp b/src/block/noekeon/noekeon.cpp index 74a485773..0bfce1882 100644 --- a/src/block/noekeon/noekeon.cpp +++ b/src/block/noekeon/noekeon.cpp @@ -6,8 +6,8 @@ */ #include <botan/noekeon.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/rc2/rc2.cpp b/src/block/rc2/rc2.cpp index 7fd1ed80e..b5e4a7d50 100644 --- a/src/block/rc2/rc2.cpp +++ b/src/block/rc2/rc2.cpp @@ -6,8 +6,8 @@ */ #include <botan/rc2.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/rc5/rc5.cpp b/src/block/rc5/rc5.cpp index c0f555103..0bd596b10 100644 --- a/src/block/rc5/rc5.cpp +++ b/src/block/rc5/rc5.cpp @@ -6,8 +6,8 @@ */ #include <botan/rc5.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> #include <botan/parsing.h> #include <algorithm> diff --git a/src/block/rc6/rc6.cpp b/src/block/rc6/rc6.cpp index 5c2aba60a..8bda62259 100644 --- a/src/block/rc6/rc6.cpp +++ b/src/block/rc6/rc6.cpp @@ -6,8 +6,8 @@ */ #include <botan/rc6.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> #include <algorithm> namespace Botan { diff --git a/src/block/safer/safer_sk.cpp b/src/block/safer/safer_sk.cpp index 540efde79..eb5c22fc9 100644 --- a/src/block/safer/safer_sk.cpp +++ b/src/block/safer/safer_sk.cpp @@ -6,9 +6,9 @@ */ #include <botan/safer_sk.h> -#include <botan/internal/rotate.h> +#include <botan/rotate.h> #include <botan/parsing.h> -#include <botan/internal/rotate.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/seed/seed.cpp b/src/block/seed/seed.cpp index b674fce95..378be16e4 100644 --- a/src/block/seed/seed.cpp +++ b/src/block/seed/seed.cpp @@ -6,7 +6,7 @@ */ #include <botan/seed.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/serpent/serpent.cpp b/src/block/serpent/serpent.cpp index d08e0c384..e16afc89c 100644 --- a/src/block/serpent/serpent.cpp +++ b/src/block/serpent/serpent.cpp @@ -6,8 +6,8 @@ */ #include <botan/serpent.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/serpent_ia32/serp_ia32.cpp b/src/block/serpent_ia32/serp_ia32.cpp index 3b90f4950..721584b18 100644 --- a/src/block/serpent_ia32/serp_ia32.cpp +++ b/src/block/serpent_ia32/serp_ia32.cpp @@ -6,7 +6,7 @@ */ #include <botan/serp_ia32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/serpent_simd/serp_simd.cpp b/src/block/serpent_simd/serp_simd.cpp index 3a42db55f..0a535c9a0 100644 --- a/src/block/serpent_simd/serp_simd.cpp +++ b/src/block/serpent_simd/serp_simd.cpp @@ -8,7 +8,7 @@ #include <botan/serp_simd.h> #include <botan/internal/serp_simd_sbox.h> #include <botan/internal/simd_32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/skipjack/skipjack.cpp b/src/block/skipjack/skipjack.cpp index b1765d67a..b23d1e160 100644 --- a/src/block/skipjack/skipjack.cpp +++ b/src/block/skipjack/skipjack.cpp @@ -6,7 +6,7 @@ */ #include <botan/skipjack.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/square/square.cpp b/src/block/square/square.cpp index a64e2538e..892568655 100644 --- a/src/block/square/square.cpp +++ b/src/block/square/square.cpp @@ -6,8 +6,8 @@ */ #include <botan/square.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/tea/tea.cpp b/src/block/tea/tea.cpp index 617c9505a..de30858da 100644 --- a/src/block/tea/tea.cpp +++ b/src/block/tea/tea.cpp @@ -6,7 +6,7 @@ */ #include <botan/tea.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/twofish/twofish.cpp b/src/block/twofish/twofish.cpp index 1969b615b..3136837aa 100644 --- a/src/block/twofish/twofish.cpp +++ b/src/block/twofish/twofish.cpp @@ -6,8 +6,8 @@ */ #include <botan/twofish.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/block/xtea/xtea.cpp b/src/block/xtea/xtea.cpp index 2172d63b8..fc14c0a57 100644 --- a/src/block/xtea/xtea.cpp +++ b/src/block/xtea/xtea.cpp @@ -6,7 +6,7 @@ */ #include <botan/xtea.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/block/xtea_simd/xtea_simd.cpp b/src/block/xtea_simd/xtea_simd.cpp index a8d1fe810..264d4f949 100644 --- a/src/block/xtea_simd/xtea_simd.cpp +++ b/src/block/xtea_simd/xtea_simd.cpp @@ -6,7 +6,7 @@ */ #include <botan/xtea_simd.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/simd_32.h> namespace Botan { diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 37ff06f9d..9d7012a73 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -44,7 +44,7 @@ #define BOTAN_USE_GCC_INLINE_ASM 1 #endif -#ifndef BOTAN_USE_GCC_INLINE_ASM +#if !defined(BOTAN_USE_GCC_INLINE_ASM) #define BOTAN_USE_GCC_INLINE_ASM 0 #endif diff --git a/src/checksum/adler32/adler32.cpp b/src/checksum/adler32/adler32.cpp index 2af1f22ce..c66943b88 100644 --- a/src/checksum/adler32/adler32.cpp +++ b/src/checksum/adler32/adler32.cpp @@ -6,7 +6,7 @@ */ #include <botan/adler32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/checksum/crc24/crc24.cpp b/src/checksum/crc24/crc24.cpp index 6023ace73..e50b4d33e 100644 --- a/src/checksum/crc24/crc24.cpp +++ b/src/checksum/crc24/crc24.cpp @@ -6,7 +6,7 @@ */ #include <botan/crc24.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/checksum/crc32/crc32.cpp b/src/checksum/crc32/crc32.cpp index 1f118c023..42462096f 100644 --- a/src/checksum/crc32/crc32.cpp +++ b/src/checksum/crc32/crc32.cpp @@ -6,7 +6,7 @@ */ #include <botan/crc32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/constructs/aont/package.cpp b/src/constructs/aont/package.cpp index 23b020e8a..8d2d7257d 100644 --- a/src/constructs/aont/package.cpp +++ b/src/constructs/aont/package.cpp @@ -9,7 +9,7 @@ #include <botan/package.h> #include <botan/filters.h> #include <botan/ctr.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/constructs/cryptobox/cryptobox.cpp b/src/constructs/cryptobox/cryptobox.cpp index 1c7975a7d..ba7553c55 100644 --- a/src/constructs/cryptobox/cryptobox.cpp +++ b/src/constructs/cryptobox/cryptobox.cpp @@ -13,7 +13,7 @@ #include <botan/hmac.h> #include <botan/pbkdf2.h> #include <botan/pem.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/mem_ops.h> namespace Botan { diff --git a/src/constructs/fpe/fpe.cpp b/src/constructs/fpe/fpe.cpp index 17f9a1406..86e56625d 100644 --- a/src/constructs/fpe/fpe.cpp +++ b/src/constructs/fpe/fpe.cpp @@ -12,7 +12,7 @@ #include <botan/numthry.h> #include <botan/hmac.h> #include <botan/sha2_32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <stdexcept> namespace Botan { diff --git a/src/constructs/tss/tss.cpp b/src/constructs/tss/tss.cpp index d38741235..0782a27d1 100644 --- a/src/constructs/tss/tss.cpp +++ b/src/constructs/tss/tss.cpp @@ -6,7 +6,7 @@ */ #include <botan/tss.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/pipe.h> #include <botan/hex.h> #include <botan/sha2_32.h> diff --git a/src/hash/bmw/bmw_512.cpp b/src/hash/bmw/bmw_512.cpp index 61c20d769..5ccb09579 100644 --- a/src/hash/bmw/bmw_512.cpp +++ b/src/hash/bmw/bmw_512.cpp @@ -6,8 +6,8 @@ */ #include <botan/bmw_512.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/fork256/fork256.cpp b/src/hash/fork256/fork256.cpp index 6e6e44fb8..bd85dfd7c 100644 --- a/src/hash/fork256/fork256.cpp +++ b/src/hash/fork256/fork256.cpp @@ -6,8 +6,8 @@ */ #include <botan/fork256.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/gost_3411/gost_3411.cpp b/src/hash/gost_3411/gost_3411.cpp index 6de3c9d52..01d8a0d46 100644 --- a/src/hash/gost_3411/gost_3411.cpp +++ b/src/hash/gost_3411/gost_3411.cpp @@ -6,8 +6,8 @@ */ #include <botan/gost_3411.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> #include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/hash/has160/has160.cpp b/src/hash/has160/has160.cpp index 006e8f142..d245a0249 100644 --- a/src/hash/has160/has160.cpp +++ b/src/hash/has160/has160.cpp @@ -6,8 +6,8 @@ */ #include <botan/has160.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/md4/md4.cpp b/src/hash/md4/md4.cpp index 5713a17b2..f573dae25 100644 --- a/src/hash/md4/md4.cpp +++ b/src/hash/md4/md4.cpp @@ -6,8 +6,8 @@ */ #include <botan/md4.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/md4_ia32/md4_ia32.cpp b/src/hash/md4_ia32/md4_ia32.cpp index cdaffb62e..12fe71da4 100644 --- a/src/hash/md4_ia32/md4_ia32.cpp +++ b/src/hash/md4_ia32/md4_ia32.cpp @@ -6,7 +6,7 @@ */ #include <botan/md4_ia32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/hash/md5/md5.cpp b/src/hash/md5/md5.cpp index 4714603d3..8c1e5a8e1 100644 --- a/src/hash/md5/md5.cpp +++ b/src/hash/md5/md5.cpp @@ -6,8 +6,8 @@ */ #include <botan/md5.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/md5_ia32/md5_ia32.cpp b/src/hash/md5_ia32/md5_ia32.cpp index 5681a2763..443569b3b 100644 --- a/src/hash/md5_ia32/md5_ia32.cpp +++ b/src/hash/md5_ia32/md5_ia32.cpp @@ -6,7 +6,7 @@ */ #include <botan/md5_ia32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/hash/mdx_hash/mdx_hash.cpp b/src/hash/mdx_hash/mdx_hash.cpp index cc03d0319..28402c2c5 100644 --- a/src/hash/mdx_hash/mdx_hash.cpp +++ b/src/hash/mdx_hash/mdx_hash.cpp @@ -7,7 +7,7 @@ #include <botan/mdx_hash.h> #include <botan/exceptn.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/hash/rmd128/rmd128.cpp b/src/hash/rmd128/rmd128.cpp index f86addda4..51e416eb1 100644 --- a/src/hash/rmd128/rmd128.cpp +++ b/src/hash/rmd128/rmd128.cpp @@ -6,8 +6,8 @@ */ #include <botan/rmd128.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/rmd160/rmd160.cpp b/src/hash/rmd160/rmd160.cpp index e1d6a8dc5..5237f1e12 100644 --- a/src/hash/rmd160/rmd160.cpp +++ b/src/hash/rmd160/rmd160.cpp @@ -6,8 +6,8 @@ */ #include <botan/rmd160.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/sha1/sha160.cpp b/src/hash/sha1/sha160.cpp index 5666d8fa5..ff44593f6 100644 --- a/src/hash/sha1/sha160.cpp +++ b/src/hash/sha1/sha160.cpp @@ -6,8 +6,8 @@ */ #include <botan/sha160.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/sha1_ia32/sha1_ia32.cpp b/src/hash/sha1_ia32/sha1_ia32.cpp index a8f7f7b75..0fa0b6bf2 100644 --- a/src/hash/sha1_ia32/sha1_ia32.cpp +++ b/src/hash/sha1_ia32/sha1_ia32.cpp @@ -6,7 +6,7 @@ */ #include <botan/sha1_ia32.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/hash/sha1_sse2/sha1_sse2.cpp b/src/hash/sha1_sse2/sha1_sse2.cpp index 89ad7b003..9267689e7 100644 --- a/src/hash/sha1_sse2/sha1_sse2.cpp +++ b/src/hash/sha1_sse2/sha1_sse2.cpp @@ -9,7 +9,7 @@ */ #include <botan/sha1_sse2.h> -#include <botan/internal/rotate.h> +#include <botan/rotate.h> #include <emmintrin.h> namespace Botan { diff --git a/src/hash/sha2/sha2_32.cpp b/src/hash/sha2/sha2_32.cpp index d9d69e4a9..91375df04 100644 --- a/src/hash/sha2/sha2_32.cpp +++ b/src/hash/sha2/sha2_32.cpp @@ -7,8 +7,8 @@ */ #include <botan/sha2_32.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/sha2/sha2_64.cpp b/src/hash/sha2/sha2_64.cpp index 9815a6e19..3e7c0e228 100644 --- a/src/hash/sha2/sha2_64.cpp +++ b/src/hash/sha2/sha2_64.cpp @@ -6,8 +6,8 @@ */ #include <botan/sha2_64.h> -#include <botan/internal/loadstor.h> -#include <botan/internal/rotate.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> namespace Botan { diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp index 1d683c3cf..2c6aa121c 100644 --- a/src/hash/skein/skein_512.cpp +++ b/src/hash/skein/skein_512.cpp @@ -6,9 +6,10 @@ */ #include <botan/skein_512.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/parsing.h> #include <botan/exceptn.h> +#include <botan/rotate.h> #include <algorithm> namespace Botan { diff --git a/src/hash/tiger/tiger.cpp b/src/hash/tiger/tiger.cpp index 5a1d21847..4f4d4dc83 100644 --- a/src/hash/tiger/tiger.cpp +++ b/src/hash/tiger/tiger.cpp @@ -7,7 +7,7 @@ #include <botan/tiger.h> #include <botan/exceptn.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/parsing.h> namespace Botan { diff --git a/src/hash/whirlpool/whrlpool.cpp b/src/hash/whirlpool/whrlpool.cpp index c9d520776..06755fe77 100644 --- a/src/hash/whirlpool/whrlpool.cpp +++ b/src/hash/whirlpool/whrlpool.cpp @@ -6,7 +6,7 @@ */ #include <botan/whrlpool.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp index f8f178c80..167f64436 100644 --- a/src/kdf/kdf2/kdf2.cpp +++ b/src/kdf/kdf2/kdf2.cpp @@ -6,7 +6,7 @@ */ #include <botan/kdf2.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { diff --git a/src/kdf/mgf1/mgf1.cpp b/src/kdf/mgf1/mgf1.cpp index c61f583a7..a8c7e5fa3 100644 --- a/src/kdf/mgf1/mgf1.cpp +++ b/src/kdf/mgf1/mgf1.cpp @@ -6,7 +6,7 @@ */ #include <botan/mgf1.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/exceptn.h> #include <botan/internal/xor_buf.h> #include <algorithm> diff --git a/src/kdf/x942_prf/prf_x942.cpp b/src/kdf/x942_prf/prf_x942.cpp index 060fed700..d9ee09d20 100644 --- a/src/kdf/x942_prf/prf_x942.cpp +++ b/src/kdf/x942_prf/prf_x942.cpp @@ -9,7 +9,7 @@ #include <botan/der_enc.h> #include <botan/oids.h> #include <botan/sha160.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <algorithm> #include <memory> diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp index a11960aca..70bb11a83 100644 --- a/src/math/bigint/bigint.cpp +++ b/src/math/bigint/bigint.cpp @@ -7,7 +7,7 @@ #include <botan/bigint.h> #include <botan/internal/mp_core.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/parsing.h> #include <botan/internal/rounding.h> diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp index ef9ecba2b..995ec9259 100644 --- a/src/rng/hmac_rng/hmac_rng.cpp +++ b/src/rng/hmac_rng/hmac_rng.cpp @@ -6,7 +6,7 @@ */ #include <botan/hmac_rng.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/xor_buf.h> #include <botan/internal/stl_util.h> #include <algorithm> diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index 0b7f2921b..f6479b2dd 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -6,7 +6,7 @@ */ #include <botan/randpool.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/xor_buf.h> #include <botan/internal/stl_util.h> #include <algorithm> diff --git a/src/s2k/pbkdf2/pbkdf2.cpp b/src/s2k/pbkdf2/pbkdf2.cpp index 4fc1b8deb..6f790c06b 100644 --- a/src/s2k/pbkdf2/pbkdf2.cpp +++ b/src/s2k/pbkdf2/pbkdf2.cpp @@ -6,7 +6,7 @@ */ #include <botan/pbkdf2.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/stream/salsa20/salsa20.cpp b/src/stream/salsa20/salsa20.cpp index cc5d3a712..1b97f4421 100644 --- a/src/stream/salsa20/salsa20.cpp +++ b/src/stream/salsa20/salsa20.cpp @@ -6,8 +6,9 @@ */ #include <botan/salsa20.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> #include <botan/internal/xor_buf.h> -#include <botan/internal/loadstor.h> namespace Botan { diff --git a/src/stream/turing/turing.cpp b/src/stream/turing/turing.cpp index dec9190ab..159c262fd 100644 --- a/src/stream/turing/turing.cpp +++ b/src/stream/turing/turing.cpp @@ -6,7 +6,8 @@ */ #include <botan/turing.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> +#include <botan/rotate.h> #include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/stream/wid_wake/wid_wake.cpp b/src/stream/wid_wake/wid_wake.cpp index d52851aee..225ccf9a6 100644 --- a/src/stream/wid_wake/wid_wake.cpp +++ b/src/stream/wid_wake/wid_wake.cpp @@ -6,7 +6,7 @@ */ #include <botan/wid_wake.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/internal/xor_buf.h> namespace Botan { diff --git a/src/utils/bswap.h b/src/utils/bswap.h index 3294111a0..1a5349fd0 100644 --- a/src/utils/bswap.h +++ b/src/utils/bswap.h @@ -10,7 +10,7 @@ #define BOTAN_BYTE_SWAP_H__ #include <botan/types.h> -#include <botan/internal/rotate.h> +#include <botan/rotate.h> namespace Botan { @@ -24,35 +24,44 @@ inline u16bit reverse_bytes(u16bit input) inline u32bit reverse_bytes(u32bit input) { -#if BOTAN_USE_GCC_INLINE_ASM && \ - (defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64)) +#if BOTAN_USE_GCC_INLINE_ASM && (defined(BOTAN_TARGET_ARCH_IS_IA32) || \ + defined(BOTAN_TARGET_ARCH_IS_AMD64)) - /* GCC-style inline assembly for x86 or x86-64 */ + // GCC-style inline assembly for x86 or x86-64 asm("bswapl %0" : "=r" (input) : "0" (input)); return input; #elif defined(_MSC_VER) && defined(BOTAN_TARGET_ARCH_IS_IA32) - /* Visual C++ inline asm for 32-bit x86, by Yves Jerschow */ + // Visual C++ inline asm for 32-bit x86, by Yves Jerschow __asm mov eax, input; __asm bswap eax; #else - /* Generic implementation */ - input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); - return rotate_left(input, 16); + // Generic implementation + return (rotate_right(input, 8) & 0xFF00FF00) | + (rotate_left (input, 8) & 0x00FF00FF); #endif } inline u64bit reverse_bytes(u64bit input) { #if BOTAN_USE_GCC_INLINE_ASM && defined(BOTAN_TARGET_ARCH_IS_AMD64) + // GCC-style inline assembly for x86-64 asm("bswapq %0" : "=r" (input) : "0" (input)); return input; + #else - u32bit hi = ((input >> 40) & 0x00FF00FF) | ((input >> 24) & 0xFF00FF00); - u32bit lo = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); - hi = (hi << 16) | (hi >> 16); - lo = (lo << 16) | (lo >> 16); + /* Generic implementation. Defined in terms of 32-bit bswap so any + * optimizations in that version can help here (particularly + * useful for 32-bit x86). + */ + + u32bit hi = static_cast<u32bit>(input >> 32); + u32bit lo = static_cast<u32bit>(input); + + hi = reverse_bytes(hi); + lo = reverse_bytes(lo); + return (static_cast<u64bit>(lo) << 32) | hi; #endif } diff --git a/src/utils/cpuid.cpp b/src/utils/cpuid.cpp index a6f40f53c..2ba7f9b77 100644 --- a/src/utils/cpuid.cpp +++ b/src/utils/cpuid.cpp @@ -7,7 +7,7 @@ #include <botan/cpuid.h> #include <botan/types.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> #include <botan/mem_ops.h> #if defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64) diff --git a/src/utils/info.txt b/src/utils/info.txt index edeeb1cf9..93ece2e78 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -15,22 +15,22 @@ version.cpp <header:internal> bit_ops.h -bswap.h -loadstor.h mlock.h prefetch.h -rotate.h rounding.h stl_util.h xor_buf.h </header:internal> <header:public> +bswap.h charset.h cpuid.h exceptn.h +loadstor.h mem_ops.h parsing.h +rotate.h time.h types.h ui.h diff --git a/src/utils/loadstor.h b/src/utils/loadstor.h index fa2e36c1e..77a6e846c 100644 --- a/src/utils/loadstor.h +++ b/src/utils/loadstor.h @@ -10,9 +10,7 @@ #define BOTAN_LOAD_STORE_H__ #include <botan/types.h> -#include <botan/internal/bswap.h> -#include <botan/internal/rotate.h> -#include <botan/internal/prefetch.h> +#include <botan/bswap.h> #include <cstring> #if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK diff --git a/src/utils/parsing.cpp b/src/utils/parsing.cpp index 0ccd8a312..58a8e0b38 100644 --- a/src/utils/parsing.cpp +++ b/src/utils/parsing.cpp @@ -8,7 +8,7 @@ #include <botan/parsing.h> #include <botan/exceptn.h> #include <botan/charset.h> -#include <botan/internal/loadstor.h> +#include <botan/loadstor.h> namespace Botan { |