diff options
author | lloyd <[email protected]> | 2009-11-05 17:17:09 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-05 17:17:09 +0000 |
commit | 1860807e4ed230f3aeea0831ec180e55d2f0eaa4 (patch) | |
tree | 26de4fd5ab0d94ef7700ea1c077b8e11ec523fbb | |
parent | b8658279904708d0690e473fb85942d5da23d2fc (diff) | |
parent | 56c3c044215f36fe00c9a8a2e06a84f969996cb7 (diff) |
propagate from branch 'net.randombit.botan' (head cead7027e70b68a8b4ae2e5bd8f290066e5ea22a)
to branch 'net.randombit.botan.c++0x' (head 9edbd485060131b695170f5243a100e06e3b0c71)
-rwxr-xr-x | configure.py | 5 | ||||
-rw-r--r-- | doc/log.txt | 5 | ||||
-rwxr-xr-x | doc/scripts/configure.pl | 2 | ||||
-rwxr-xr-x | doc/scripts/dist.sh | 10 | ||||
-rw-r--r-- | readme.txt | 2 | ||||
-rw-r--r-- | src/block/serpent_simd/serp_simd_sbox.h | 5 | ||||
-rw-r--r-- | src/hash/fork256/fork256.cpp | 6 | ||||
-rw-r--r-- | src/hash/gost_3411/gost_3411.cpp | 8 | ||||
-rw-r--r-- | src/hash/md4/md4.cpp | 55 | ||||
-rw-r--r-- | src/hash/sha1_amd64/sha1_amd64_imp.S | 10 | ||||
-rw-r--r-- | src/hash/sha2/sha2_64.cpp | 6 | ||||
-rw-r--r-- | src/hash/whirlpool/whrlpool.cpp | 6 | ||||
-rw-r--r-- | src/utils/simd_32/simd_32.h | 2 | ||||
-rw-r--r-- | src/utils/simd_32/simd_altivec.h | 6 | ||||
-rw-r--r-- | src/utils/simd_32/simd_scalar.h | 9 | ||||
-rw-r--r-- | src/utils/simd_32/simd_sse.h | 9 |
16 files changed, 84 insertions, 62 deletions
diff --git a/configure.py b/configure.py index be5cf7ad2..93192abdd 100755 --- a/configure.py +++ b/configure.py @@ -39,7 +39,7 @@ class BuildConfigurationInformation(object): version_minor = 9 version_patch = 2 version_so_patch = 2 - version_suffix = '-dev' + version_suffix = '' version_string = '%d.%d.%d%s' % ( version_major, version_minor, version_patch, version_suffix) @@ -463,6 +463,9 @@ class ArchInfo(object): logging.info('Assuming unaligned memory access works on this CPU') macros.append('TARGET_UNALIGNED_LOADSTOR_OK %d' % (unaligned_ok)) + if self.basename == 'amd64': + macros.append('TARGET_CPU_HAS_SSE2') + return macros class CompilerInfo(object): diff --git a/doc/log.txt b/doc/log.txt index c2728e8db..97e40db5e 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -1,5 +1,5 @@ -* 1.9.2-dev, ????-??-?? +* 1.9.2, 2009-11-03 - Add SIMD version of XTEA - Support both SSE2 and AltiVec SIMD for Serpent and XTEA - Optimizations for SHA-1 and SHA-2 @@ -29,10 +29,11 @@ - Add --no-autoload option to configure.py, for minimized builds - The previously used configure.pl script is no longer supported -* 1.8.8-dev, 2009-??-?? +* 1.8.8, 2009-11-03 - Alter Skein-512 to match the tweaked 1.2 specification - Fix use of inline asm for access to x86 bswap function - Allow building the library without AES enabled + - Add 'powerpc64' alias to ppc64 arch for Gentoo ebuild * 1.8.7, 2009-09-09 - Fix processing multiple messages in XTS mode diff --git a/doc/scripts/configure.pl b/doc/scripts/configure.pl index 9415d5a42..1ce01e2b4 100755 --- a/doc/scripts/configure.pl +++ b/doc/scripts/configure.pl @@ -13,7 +13,7 @@ use Sys::Hostname; my $MAJOR_VERSION = 1; my $MINOR_VERSION = 8; -my $PATCH_VERSION = 7; +my $PATCH_VERSION = 8; my $VERSION_SUFFIX = ''; diff --git a/doc/scripts/dist.sh b/doc/scripts/dist.sh index 2b03b1a71..152b7e89b 100755 --- a/doc/scripts/dist.sh +++ b/doc/scripts/dist.sh @@ -3,16 +3,10 @@ # This is probably only useful if run on my machine, which is not # exactly ideal -# Make that limitation explicit -if [ $(hostname -s) != 'chihiro' ]; then - echo "This script probably won't work on this machine without fixes" - exit 1 -fi - SELECTOR=h:net.randombit.botan KEY_ID=EFBADFBC -MTN_DB=$HOME/var/mtn/botan.mtn -WEB_DIR=/var/www/randombit.net/files/botan/v1.9 +MTN_DB=/storage/mtn/botan.mtn +WEB_DIR=$HOME/projects/www/files/botan/v1.9/ DIST_DIR=~/Botan-dist # You shouldn't have to change anything after this diff --git a/readme.txt b/readme.txt index 644c6a4a8..a192a1e1e 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -Botan 1.9.2-dev, ????-??-?? +Botan 1.9.2, 2009-11-03 Botan is a C++ class library for performing a wide variety of cryptographic operations. diff --git a/src/block/serpent_simd/serp_simd_sbox.h b/src/block/serpent_simd/serp_simd_sbox.h index 6e3da7359..fe70f0063 100644 --- a/src/block/serpent_simd/serp_simd_sbox.h +++ b/src/block/serpent_simd/serp_simd_sbox.h @@ -76,11 +76,10 @@ B4 ^= B0; \ B1 ^= B3; \ B1 ^= B4; \ - B4 = ~B4; \ B0 = B2; \ B2 = B1; \ B1 = B3; \ - B3 = B4; \ + B3 = ~B4; \ } while(0); #define SBoxE4(B0, B1, B2, B3) \ @@ -165,7 +164,7 @@ #define SBoxE7(B0, B1, B2, B3) \ do { \ - B2 = ~B2; \ + B2 = ~B2; \ SIMD_32 B4 = B3; \ B3 &= B0; \ B0 ^= B4; \ diff --git a/src/hash/fork256/fork256.cpp b/src/hash/fork256/fork256.cpp index 6718f9f97..bd85dfd7c 100644 --- a/src/hash/fork256/fork256.cpp +++ b/src/hash/fork256/fork256.cpp @@ -66,9 +66,7 @@ void FORK_256::compress_n(const byte input[], u32bit blocks) G1 = G2 = G3 = G4 = digest[6]; H1 = H2 = H3 = H4 = digest[7]; - for(u32bit j = 0; j != 16; ++j) - M[j] = load_be<u32bit>(input, j); - input += HASH_BLOCK_SIZE; + load_be(M.begin(), input, M.size()); step(A1, B1, C1, D1, E1, F1, G1, H1, M[ 0], M[ 1], DELTA[ 0], DELTA[ 1]); step(A2, B2, C2, D2, E2, F2, G2, H2, M[14], M[15], DELTA[15], DELTA[14]); @@ -118,6 +116,8 @@ void FORK_256::compress_n(const byte input[], u32bit blocks) digest[5] += (F1 + F2) ^ (F3 + F4); digest[6] += (G1 + G2) ^ (G3 + G4); digest[7] += (H1 + H2) ^ (H3 + H4); + + input += HASH_BLOCK_SIZE; } } diff --git a/src/hash/gost_3411/gost_3411.cpp b/src/hash/gost_3411/gost_3411.cpp index 90ef3e805..16b1311da 100644 --- a/src/hash/gost_3411/gost_3411.cpp +++ b/src/hash/gost_3411/gost_3411.cpp @@ -79,12 +79,8 @@ void GOST_34_11::compress_n(const byte input[], u32bit blocks) byte S[32] = { 0 }; u64bit U[4], V[4]; - - for(u32bit j = 0; j != 4; ++j) - { - U[j] = load_be<u64bit>(hash, j); - V[j] = load_be<u64bit>(input + 32*i, j); - } + load_be(U, hash, 4); + load_be(V, input + 32*i, 4); for(u32bit j = 0; j != 4; ++j) { diff --git a/src/hash/md4/md4.cpp b/src/hash/md4/md4.cpp index c50c73a8d..f573dae25 100644 --- a/src/hash/md4/md4.cpp +++ b/src/hash/md4/md4.cpp @@ -51,36 +51,41 @@ void MD4::compress_n(const byte input[], u32bit blocks) for(u32bit i = 0; i != blocks; ++i) { - //load_le(M.begin(), input, M.size()); - for(u32bit j = 0; j != 16; ++j) - M[j] = load_le<u32bit>(input, j); - input += HASH_BLOCK_SIZE; - - FF(A,B,C,D,M[ 0], 3); FF(D,A,B,C,M[ 1], 7); FF(C,D,A,B,M[ 2],11); - FF(B,C,D,A,M[ 3],19); FF(A,B,C,D,M[ 4], 3); FF(D,A,B,C,M[ 5], 7); - FF(C,D,A,B,M[ 6],11); FF(B,C,D,A,M[ 7],19); FF(A,B,C,D,M[ 8], 3); - FF(D,A,B,C,M[ 9], 7); FF(C,D,A,B,M[10],11); FF(B,C,D,A,M[11],19); - FF(A,B,C,D,M[12], 3); FF(D,A,B,C,M[13], 7); FF(C,D,A,B,M[14],11); - FF(B,C,D,A,M[15],19); - - GG(A,B,C,D,M[ 0], 3); GG(D,A,B,C,M[ 4], 5); GG(C,D,A,B,M[ 8], 9); - GG(B,C,D,A,M[12],13); GG(A,B,C,D,M[ 1], 3); GG(D,A,B,C,M[ 5], 5); - GG(C,D,A,B,M[ 9], 9); GG(B,C,D,A,M[13],13); GG(A,B,C,D,M[ 2], 3); - GG(D,A,B,C,M[ 6], 5); GG(C,D,A,B,M[10], 9); GG(B,C,D,A,M[14],13); - GG(A,B,C,D,M[ 3], 3); GG(D,A,B,C,M[ 7], 5); GG(C,D,A,B,M[11], 9); - GG(B,C,D,A,M[15],13); - - HH(A,B,C,D,M[ 0], 3); HH(D,A,B,C,M[ 8], 9); HH(C,D,A,B,M[ 4],11); - HH(B,C,D,A,M[12],15); HH(A,B,C,D,M[ 2], 3); HH(D,A,B,C,M[10], 9); - HH(C,D,A,B,M[ 6],11); HH(B,C,D,A,M[14],15); HH(A,B,C,D,M[ 1], 3); - HH(D,A,B,C,M[ 9], 9); HH(C,D,A,B,M[ 5],11); HH(B,C,D,A,M[13],15); - HH(A,B,C,D,M[ 3], 3); HH(D,A,B,C,M[11], 9); HH(C,D,A,B,M[ 7],11); - HH(B,C,D,A,M[15],15); + load_le(M.begin(), input, M.size()); + + FF(A,B,C,D,M[ 0], 3); FF(D,A,B,C,M[ 1], 7); + FF(C,D,A,B,M[ 2],11); FF(B,C,D,A,M[ 3],19); + FF(A,B,C,D,M[ 4], 3); FF(D,A,B,C,M[ 5], 7); + FF(C,D,A,B,M[ 6],11); FF(B,C,D,A,M[ 7],19); + FF(A,B,C,D,M[ 8], 3); FF(D,A,B,C,M[ 9], 7); + FF(C,D,A,B,M[10],11); FF(B,C,D,A,M[11],19); + FF(A,B,C,D,M[12], 3); FF(D,A,B,C,M[13], 7); + FF(C,D,A,B,M[14],11); FF(B,C,D,A,M[15],19); + + GG(A,B,C,D,M[ 0], 3); GG(D,A,B,C,M[ 4], 5); + GG(C,D,A,B,M[ 8], 9); GG(B,C,D,A,M[12],13); + GG(A,B,C,D,M[ 1], 3); GG(D,A,B,C,M[ 5], 5); + GG(C,D,A,B,M[ 9], 9); GG(B,C,D,A,M[13],13); + GG(A,B,C,D,M[ 2], 3); GG(D,A,B,C,M[ 6], 5); + GG(C,D,A,B,M[10], 9); GG(B,C,D,A,M[14],13); + GG(A,B,C,D,M[ 3], 3); GG(D,A,B,C,M[ 7], 5); + GG(C,D,A,B,M[11], 9); GG(B,C,D,A,M[15],13); + + HH(A,B,C,D,M[ 0], 3); HH(D,A,B,C,M[ 8], 9); + HH(C,D,A,B,M[ 4],11); HH(B,C,D,A,M[12],15); + HH(A,B,C,D,M[ 2], 3); HH(D,A,B,C,M[10], 9); + HH(C,D,A,B,M[ 6],11); HH(B,C,D,A,M[14],15); + HH(A,B,C,D,M[ 1], 3); HH(D,A,B,C,M[ 9], 9); + HH(C,D,A,B,M[ 5],11); HH(B,C,D,A,M[13],15); + HH(A,B,C,D,M[ 3], 3); HH(D,A,B,C,M[11], 9); + HH(C,D,A,B,M[ 7],11); HH(B,C,D,A,M[15],15); A = (digest[0] += A); B = (digest[1] += B); C = (digest[2] += C); D = (digest[3] += D); + + input += HASH_BLOCK_SIZE; } } diff --git a/src/hash/sha1_amd64/sha1_amd64_imp.S b/src/hash/sha1_amd64/sha1_amd64_imp.S index 34a8318ed..ba4d4d5ef 100644 --- a/src/hash/sha1_amd64/sha1_amd64_imp.S +++ b/src/hash/sha1_amd64/sha1_amd64_imp.S @@ -103,10 +103,16 @@ ALIGN; subq $320, W +/* +* Using negative values for SHA-1 constants > 2^31 to work around +* a bug in binutils not accepting large lea displacements. +* -0x70E44324 == 0x8F1BBCDC +* -0x359D3E2A == 0xCA62C1D6 +*/ #define MAGIC1 0x5A827999 #define MAGIC2 0x6ED9EBA1 -#define MAGIC3 0x8F1BBCDC -#define MAGIC4 0xCA62C1D6 +#define MAGIC3 -0x70E44324 +#define MAGIC4 -0x359D3E2A #define T %esi #define T2 %eax diff --git a/src/hash/sha2/sha2_64.cpp b/src/hash/sha2/sha2_64.cpp index e260d8338..3e7c0e228 100644 --- a/src/hash/sha2/sha2_64.cpp +++ b/src/hash/sha2/sha2_64.cpp @@ -55,9 +55,7 @@ void SHA_384_512_BASE::compress_n(const byte input[], u32bit blocks) for(u32bit i = 0; i != blocks; ++i) { - for(u32bit j = 0; j != 16; ++j) - W[j] = load_be<u64bit>(input, j); - input += HASH_BLOCK_SIZE; + load_be(W.begin(), input, 16); for(u32bit j = 16; j != 80; j += 8) { @@ -160,6 +158,8 @@ void SHA_384_512_BASE::compress_n(const byte input[], u32bit blocks) F = (digest[5] += F); G = (digest[6] += G); H = (digest[7] += H); + + input += HASH_BLOCK_SIZE; } } diff --git a/src/hash/whirlpool/whrlpool.cpp b/src/hash/whirlpool/whrlpool.cpp index b7a02a9b6..06755fe77 100644 --- a/src/hash/whirlpool/whrlpool.cpp +++ b/src/hash/whirlpool/whrlpool.cpp @@ -25,9 +25,7 @@ void Whirlpool::compress_n(const byte in[], u32bit blocks) for(u32bit i = 0; i != blocks; ++i) { - for(u32bit j = 0; j != 8; ++j) - M[j] = load_be<u64bit>(in, j); - in += HASH_BLOCK_SIZE; + load_be(M.begin(), in, M.size()); u64bit K0, K1, K2, K3, K4, K5, K6, K7; K0 = digest[0]; K1 = digest[1]; K2 = digest[2]; K3 = digest[3]; @@ -121,6 +119,8 @@ void Whirlpool::compress_n(const byte in[], u32bit blocks) digest[5] ^= B5 ^ M[5]; digest[6] ^= B6 ^ M[6]; digest[7] ^= B7 ^ M[7]; + + in += HASH_BLOCK_SIZE; } } diff --git a/src/utils/simd_32/simd_32.h b/src/utils/simd_32/simd_32.h index be426efd6..324db1a7d 100644 --- a/src/utils/simd_32/simd_32.h +++ b/src/utils/simd_32/simd_32.h @@ -10,8 +10,6 @@ #include <botan/types.h> -//#define BOTAN_TARGET_CPU_HAS_SSE2 - #if defined(BOTAN_TARGET_CPU_HAS_SSE2) #include <botan/simd_sse.h> diff --git a/src/utils/simd_32/simd_altivec.h b/src/utils/simd_32/simd_altivec.h index e1aa62002..c6dd8a289 100644 --- a/src/utils/simd_32/simd_altivec.h +++ b/src/utils/simd_32/simd_altivec.h @@ -168,6 +168,12 @@ class SIMD_Altivec return vec_nor(reg, reg); } + SIMD_Altivec andc(const SIMD_Altivec& other) + { + // AltiVec does arg1 & ~arg2 rather than SSE's ~arg1 & arg2 + return vec_andc(other.reg, reg); + } + SIMD_Altivec bswap() const { __vector unsigned char perm = vec_lvsl(0, (u32bit*)0); diff --git a/src/utils/simd_32/simd_scalar.h b/src/utils/simd_32/simd_scalar.h index 5fc20b462..398503d33 100644 --- a/src/utils/simd_32/simd_scalar.h +++ b/src/utils/simd_32/simd_scalar.h @@ -171,6 +171,15 @@ class SIMD_Scalar return SIMD_Scalar(~R0, ~R1, ~R2, ~R3); } + // (~reg) & other + SIMD_Scalar andc(const SIMD_Scalar& other) + { + return SIMD_Scalar(~R0 & other.R0, + ~R1 & other.R1, + ~R2 & other.R2, + ~R3 & other.R3); + } + SIMD_Scalar bswap() const { return SIMD_Scalar(reverse_bytes(R0), diff --git a/src/utils/simd_32/simd_sse.h b/src/utils/simd_32/simd_sse.h index c45d8032f..81d8afe75 100644 --- a/src/utils/simd_32/simd_sse.h +++ b/src/utils/simd_32/simd_sse.h @@ -117,8 +117,13 @@ class SIMD_SSE2 SIMD_SSE2 operator~() const { - static const __m128i all_ones = _mm_set1_epi32(0xFFFFFFFF); - return _mm_xor_si128(reg, all_ones); + return _mm_xor_si128(reg, _mm_set1_epi32(0xFFFFFFFF)); + } + + // (~reg) & other + SIMD_SSE2 andc(const SIMD_SSE2& other) + { + return _mm_andnot_si128(reg, other.reg); } SIMD_SSE2 bswap() const |