# # # delete "botan/zlib.cpp" # # delete "botan/zlib.h" # # patch "NEWS" # from [c57455d91816dc2796b876b98bb965f319e95e81] # to [af16495a1be882a92d9ba611b1d835c5008fbb86] # # patch "botan/arc4.h" # from [a21035287a093144517501237eec734af70b2c30] # to [b34d18dc97b94ec2c6e72ef8cce2a0c5343cb238] # # patch "botan/bit_ops.cpp" # from [3bb7a0fd68305ca2ff7a071798aa4419f783cf02] # to [02e8e44e8495eeb988e06842117c727c25cb598e] # # patch "botan/bit_ops.h" # from [ace888ad7c2755ca077461722e24cb1a422a2ed5] # to [1e10566eedb3f119a2c4a5a439e304937fc47cd1] # # patch "botan/build.h" # from [8947213695efb2f0fe60f24387f96ed74e3cd9cf] # to [fe0c6e45599564218d4f12bfd2b12817b10d121a] # # patch "botan/es_dev.cpp" # from [6ca08c9627c30792f3a9c40aea4e75ca4b483154] # to [2ceb34b950955cbd9f8409c9faa8bcb9a27f638e] # # patch "botan/license.txt" # from [902feeccfae30f0eb980e0f50b222cdd2c2df694] # to [ca0806b7b208cf2efa2c04e0e7a279f53ed0fe3f] # # patch "botan/loadstor.h" # from [69e5ff18c5bc8404baf1872a77b1b3d7da6ba879] # to [5f5d18b61da0991e38d47b45587b606a911a98eb] # # patch "botan/mp_asm.cpp" # from [84dd140ff3a56889afd6b026b0ee40e40120cd83] # to [a129b019f96aca15bb976f7cb2771e4e36a4e9d0] # # patch "botan/mp_asm.h" # from [43d835beafc05c9d0e39596ba54e73a53795e5b4] # to [7a7409f6968d6a14536282da58344ba68be90346] # # patch "botan/mp_asmi.h" # from [fb52f8210fae3cab3f224a25d9728222b2ce27f4] # to [1bae2fc346caecf9d6e50cd67a04835b1ebdf679] # # patch "botan/mp_misc.cpp" # from [1602f6ca6969f4c503be6f203b5442b2ae0c1c0a] # to [67eaa1482b7df8b8a6c872218640ecdacaea00d7] # # patch "botan/mp_mulop.cpp" # from [cfaafb643d3d5960509ca07f8370a044c291730d] # to [5af819039b577d423cb8a27e7d8dc5f377ab3ebb] # # patch "botan/sha160.cpp" # from [1e4669389c7963842f6a1da3e247f9b4ff0924d8] # to [0a979fa28db0ace4a2d3a8f5473ae21e0780d1b7] # ============================================================ --- NEWS c57455d91816dc2796b876b98bb965f319e95e81 +++ NEWS af16495a1be882a92d9ba611b1d835c5008fbb86 @@ -27,7 +27,7 @@ Internal - - Update Botan to 1.7.3. + - Update Botan to 1.7.4. Mon Feb 25 15:55:36 UTC 2008 ============================================================ --- botan/arc4.h a21035287a093144517501237eec734af70b2c30 +++ botan/arc4.h b34d18dc97b94ec2c6e72ef8cce2a0c5343cb238 @@ -1,6 +1,6 @@ /************************************************* * ARC4 Header File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #ifndef BOTAN_ARC4_H__ @@ -25,8 +25,10 @@ class ARC4 : public StreamCipher void cipher(const byte[], byte[], u32bit); void key(const byte[], u32bit); void generate(); + const u32bit SKIP; - SecureBuffer buffer; + + SecureBuffer buffer; SecureBuffer state; u32bit X, Y, position; }; ============================================================ --- botan/bit_ops.cpp 3bb7a0fd68305ca2ff7a071798aa4419f783cf02 +++ botan/bit_ops.cpp 02e8e44e8495eeb988e06842117c727c25cb598e @@ -1,6 +1,6 @@ /************************************************* * Bit/Word Operations Source File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #include @@ -9,69 +9,6 @@ namespace Botan { namespace Botan { /************************************************* -* Array XOR * -*************************************************/ -void xor_buf(byte data[], const byte mask[], u32bit length) - { - while(length >= 8) - { - data[0] ^= mask[0]; data[1] ^= mask[1]; - data[2] ^= mask[2]; data[3] ^= mask[3]; - data[4] ^= mask[4]; data[5] ^= mask[5]; - data[6] ^= mask[6]; data[7] ^= mask[7]; - data += 8; mask += 8; length -= 8; - } - for(u32bit j = 0; j != length; ++j) - data[j] ^= mask[j]; - } - -/************************************************* -* Array XOR * -*************************************************/ -void xor_buf(byte out[], const byte in[], const byte mask[], u32bit length) - { - while(length >= 8) - { - out[0] = in[0] ^ mask[0]; out[1] = in[1] ^ mask[1]; - out[2] = in[2] ^ mask[2]; out[3] = in[3] ^ mask[3]; - out[4] = in[4] ^ mask[4]; out[5] = in[5] ^ mask[5]; - out[6] = in[6] ^ mask[6]; out[7] = in[7] ^ mask[7]; - in += 8; out += 8; mask += 8; length -= 8; - } - for(u32bit j = 0; j != length; ++j) - out[j] = in[j] ^ mask[j]; - } - -/************************************************* -* Reverse bytes * -*************************************************/ -u16bit reverse_bytes(u16bit input) - { - return rotate_left(input, 8); - } - -/************************************************* -* Reverse bytes * -*************************************************/ -u32bit reverse_bytes(u32bit input) - { - input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); - return rotate_left(input, 16); - } - -/************************************************* -* Reverse bytes * -*************************************************/ -u64bit reverse_bytes(u64bit input) - { - input = ((input & 0xFF00FF00FF00FF00ull) >> 8) | - ((input & 0x00FF00FF00FF00FFull) << 8); - input = ((input & 0xFFFF0000FFFF0000ull) >> 16) | - ((input & 0x0000FFFF0000FFFFull) << 16); - return rotate_left(input, 32); - } - -/************************************************* * Return true iff arg is 2**n for some n > 0 * *************************************************/ bool power_of_2(u64bit arg) ============================================================ --- botan/bit_ops.h ace888ad7c2755ca077461722e24cb1a422a2ed5 +++ botan/bit_ops.h 1e10566eedb3f119a2c4a5a439e304937fc47cd1 @@ -1,6 +1,6 @@ /************************************************* * Bit/Word Operations Header File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #ifndef BOTAN_BIT_OPS_H__ @@ -24,19 +24,63 @@ template inline T rotate_rig } /************************************************* -* Byteswap * +* Byte Swapping Functions * *************************************************/ -u16bit reverse_bytes(u16bit); -u32bit reverse_bytes(u32bit); -u64bit reverse_bytes(u64bit); +inline u16bit reverse_bytes(u16bit input) + { + return rotate_left(input, 8); + } +inline u32bit reverse_bytes(u32bit input) + { + input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); + return rotate_left(input, 16); + } + +inline u64bit reverse_bytes(u64bit input) + { + 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); + return (static_cast(lo) << 32) | hi; + } + /************************************************* -* Array XOR * +* XOR Arrays * *************************************************/ -void xor_buf(byte[], const byte[], u32bit); -void xor_buf(byte[], const byte[], const byte[], u32bit); +inline void xor_buf(byte data[], const byte mask[], u32bit length) + { + while(length >= 8) + { + data[0] ^= mask[0]; data[1] ^= mask[1]; + data[2] ^= mask[2]; data[3] ^= mask[3]; + data[4] ^= mask[4]; data[5] ^= mask[5]; + data[6] ^= mask[6]; data[7] ^= mask[7]; + data += 8; mask += 8; length -= 8; + } + for(u32bit j = 0; j != length; ++j) + data[j] ^= mask[j]; + } /************************************************* +* XOR Arrays * +*************************************************/ +inline void xor_buf(byte out[], const byte in[], const byte mask[], u32bit length) + { + while(length >= 8) + { + out[0] = in[0] ^ mask[0]; out[1] = in[1] ^ mask[1]; + out[2] = in[2] ^ mask[2]; out[3] = in[3] ^ mask[3]; + out[4] = in[4] ^ mask[4]; out[5] = in[5] ^ mask[5]; + out[6] = in[6] ^ mask[6]; out[7] = in[7] ^ mask[7]; + in += 8; out += 8; mask += 8; length -= 8; + } + for(u32bit j = 0; j != length; ++j) + out[j] = in[j] ^ mask[j]; + } + +/************************************************* * Simple Bit Manipulation * *************************************************/ bool power_of_2(u64bit); ============================================================ --- botan/build.h 8947213695efb2f0fe60f24387f96ed74e3cd9cf +++ botan/build.h fe0c6e45599564218d4f12bfd2b12817b10d121a @@ -8,7 +8,7 @@ #define BOTAN_VERSION_MAJOR 1 #define BOTAN_VERSION_MINOR 7 -#define BOTAN_VERSION_PATCH 3 +#define BOTAN_VERSION_PATCH 4 #define BOTAN_MP_WORD_BITS 32 #define BOTAN_DEFAULT_BUFFER_SIZE 4096 ============================================================ --- botan/es_dev.cpp 6ca08c9627c30792f3a9c40aea4e75ca4b483154 +++ botan/es_dev.cpp 2ceb34b950955cbd9f8409c9faa8bcb9a27f638e @@ -1,6 +1,6 @@ /************************************************* * Device EntropySource Source File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #include @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace Botan { @@ -24,7 +24,7 @@ class Device_Reader typedef int fd_type; Device_Reader(fd_type device_fd) : fd(device_fd) {} - ~Device_Reader() { ::close(fd); } + ~Device_Reader() { if(fd > 0) { ::close(fd); } } u32bit get(byte out[], u32bit length); static fd_type open(const std::string& pathname); ============================================================ --- botan/license.txt 902feeccfae30f0eb980e0f50b222cdd2c2df694 +++ botan/license.txt ca0806b7b208cf2efa2c04e0e7a279f53ed0fe3f @@ -1,4 +1,4 @@ -Copyright (C) 1999-2007 The Botan Project. All rights reserved. +Copyright (C) 1999-2008 The Botan Project. All rights reserved. Redistribution and use in source and binary forms, for any use, with or without modification, is permitted provided that the following conditions are met: ============================================================ --- botan/loadstor.h 69e5ff18c5bc8404baf1872a77b1b3d7da6ba879 +++ botan/loadstor.h 5f5d18b61da0991e38d47b45587b606a911a98eb @@ -1,6 +1,6 @@ /************************************************* * Load/Store Operators Header File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #ifndef BOTAN_LOAD_STORE_H__ @@ -8,6 +8,30 @@ #include +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + +#include + +#if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN) + +#define BOTAN_ENDIAN_N2B(x) (x) +#define BOTAN_ENDIAN_B2N(x) (x) + +#define BOTAN_ENDIAN_N2L(x) reverse_bytes(x) +#define BOTAN_ENDIAN_L2N(x) reverse_bytes(x) + +#elif defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN) + +#define BOTAN_ENDIAN_N2L(x) (x) +#define BOTAN_ENDIAN_L2N(x) (x) + +#define BOTAN_ENDIAN_N2B(x) reverse_bytes(x) +#define BOTAN_ENDIAN_B2N(x) reverse_bytes(x) + +#endif + +#endif + namespace Botan { /************************************************* @@ -71,33 +95,71 @@ template<> } template<> +inline u16bit load_be(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2B(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u16bit); + return make_u16bit(in[0], in[1]); +#endif + } + +template<> +inline u16bit load_le(const byte in[], u32bit off) + { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2L(*(reinterpret_cast(in) + off)); +#else + in += off * sizeof(u16bit); + return make_u16bit(in[1], in[0]); +#endif + } + +template<> inline u32bit load_be(const byte in[], u32bit off) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2B(*(reinterpret_cast(in) + off)); +#else in += off * sizeof(u32bit); return make_u32bit(in[0], in[1], in[2], in[3]); +#endif } template<> inline u32bit load_le(const byte in[], u32bit off) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2L(*(reinterpret_cast(in) + off)); +#else in += off * sizeof(u32bit); return make_u32bit(in[3], in[2], in[1], in[0]); +#endif } template<> inline u64bit load_be(const byte in[], u32bit off) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2B(*(reinterpret_cast(in) + off)); +#else in += off * sizeof(u64bit); return make_u64bit(in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]); +#endif } template<> inline u64bit load_le(const byte in[], u32bit off) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + return BOTAN_ENDIAN_N2L(*(reinterpret_cast(in) + off)); +#else in += off * sizeof(u64bit); return make_u64bit(in[7], in[6], in[5], in[4], in[3], in[2], in[1], in[0]); +#endif } /************************************************* @@ -105,34 +167,53 @@ inline void store_be(u16bit in, byte out *************************************************/ inline void store_be(u16bit in, byte out[2]) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_B2N(in); +#else out[0] = get_byte(0, in); out[1] = get_byte(1, in); +#endif } inline void store_le(u16bit in, byte out[2]) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_L2N(in); +#else out[0] = get_byte(1, in); out[1] = get_byte(0, in); +#endif } inline void store_be(u32bit in, byte out[4]) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_B2N(in); +#else out[0] = get_byte(0, in); out[1] = get_byte(1, in); out[2] = get_byte(2, in); out[3] = get_byte(3, in); +#endif } inline void store_le(u32bit in, byte out[4]) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_L2N(in); +#else out[0] = get_byte(3, in); out[1] = get_byte(2, in); out[2] = get_byte(1, in); out[3] = get_byte(0, in); +#endif } inline void store_be(u64bit in, byte out[8]) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_B2N(in); +#else out[0] = get_byte(0, in); out[1] = get_byte(1, in); out[2] = get_byte(2, in); @@ -141,10 +222,14 @@ inline void store_be(u64bit in, byte out out[5] = get_byte(5, in); out[6] = get_byte(6, in); out[7] = get_byte(7, in); +#endif } inline void store_le(u64bit in, byte out[8]) { +#if BOTAN_TARGET_UNALIGNED_LOADSTOR_OK + *reinterpret_cast(out) = BOTAN_ENDIAN_L2N(in); +#else out[0] = get_byte(7, in); out[1] = get_byte(6, in); out[2] = get_byte(5, in); @@ -153,6 +238,7 @@ inline void store_le(u64bit in, byte out out[5] = get_byte(2, in); out[6] = get_byte(1, in); out[7] = get_byte(0, in); +#endif } template ============================================================ --- botan/mp_asm.cpp 84dd140ff3a56889afd6b026b0ee40e40120cd83 +++ botan/mp_asm.cpp a129b019f96aca15bb976f7cb2771e4e36a4e9d0 @@ -1,6 +1,6 @@ /************************************************* * Lowest Level MPI Algorithms Source File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #include @@ -148,7 +148,7 @@ void bigint_linmul2(word x[], u32bit x_s carry = word8_linmul2(x + j, y, carry); for(u32bit j = blocks; j != x_size; ++j) - x[j] = word_madd2(x[j], y, carry, &carry); + x[j] = word_madd2(x[j], y, &carry); x[x_size] = carry; } @@ -166,7 +166,7 @@ void bigint_linmul3(word z[], const word carry = word8_linmul3(z + j, x + j, y, carry); for(u32bit j = blocks; j != x_size; ++j) - z[j] = word_madd2(x[j], y, carry, &carry); + z[j] = word_madd2(x[j], y, &carry); z[x_size] = carry; } ============================================================ --- botan/mp_asm.h 43d835beafc05c9d0e39596ba54e73a53795e5b4 +++ botan/mp_asm.h 7a7409f6968d6a14536282da58344ba68be90346 @@ -1,6 +1,6 @@ /************************************************* * Lowest Level MPI Algorithms Header File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #ifndef BOTAN_MP_ASM_H__ @@ -27,20 +27,20 @@ extern "C" { /************************************************* * Word Multiply/Add * *************************************************/ -inline word word_madd2(word a, word b, word c, word* carry) +inline word word_madd2(word a, word b, word* c) { - dword z = (dword)a * b + c; - *carry = (word)(z >> BOTAN_MP_WORD_BITS); + dword z = (dword)a * b + *c; + *c = (word)(z >> BOTAN_MP_WORD_BITS); return (word)z; } /************************************************* * Word Multiply/Add * *************************************************/ -inline word word_madd3(word a, word b, word c, word d, word* carry) +inline word word_madd3(word a, word b, word c, word* d) { - dword z = (dword)a * b + c + d; - *carry = (word)(z >> BOTAN_MP_WORD_BITS); + dword z = (dword)a * b + c + *d; + *d = (word)(z >> BOTAN_MP_WORD_BITS); return (word)z; } ============================================================ --- botan/mp_asmi.h fb52f8210fae3cab3f224a25d9728222b2ce27f4 +++ botan/mp_asmi.h 1bae2fc346caecf9d6e50cd67a04835b1ebdf679 @@ -1,6 +1,6 @@ /************************************************* * Lowest Level MPI Algorithms Header File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #ifndef BOTAN_MP_ASM_INTERNAL_H__ @@ -107,14 +107,14 @@ inline word word8_linmul2(word x[4], wor *************************************************/ inline word word8_linmul2(word x[4], word y, word carry) { - x[0] = word_madd2(x[0], y, carry, &carry); - x[1] = word_madd2(x[1], y, carry, &carry); - x[2] = word_madd2(x[2], y, carry, &carry); - x[3] = word_madd2(x[3], y, carry, &carry); - x[4] = word_madd2(x[4], y, carry, &carry); - x[5] = word_madd2(x[5], y, carry, &carry); - x[6] = word_madd2(x[6], y, carry, &carry); - x[7] = word_madd2(x[7], y, carry, &carry); + x[0] = word_madd2(x[0], y, &carry); + x[1] = word_madd2(x[1], y, &carry); + x[2] = word_madd2(x[2], y, &carry); + x[3] = word_madd2(x[3], y, &carry); + x[4] = word_madd2(x[4], y, &carry); + x[5] = word_madd2(x[5], y, &carry); + x[6] = word_madd2(x[6], y, &carry); + x[7] = word_madd2(x[7], y, &carry); return carry; } @@ -123,14 +123,14 @@ inline word word8_linmul3(word z[8], con *************************************************/ inline word word8_linmul3(word z[8], const word x[8], word y, word carry) { - z[0] = word_madd2(x[0], y, carry, &carry); - z[1] = word_madd2(x[1], y, carry, &carry); - z[2] = word_madd2(x[2], y, carry, &carry); - z[3] = word_madd2(x[3], y, carry, &carry); - z[4] = word_madd2(x[4], y, carry, &carry); - z[5] = word_madd2(x[5], y, carry, &carry); - z[6] = word_madd2(x[6], y, carry, &carry); - z[7] = word_madd2(x[7], y, carry, &carry); + z[0] = word_madd2(x[0], y, &carry); + z[1] = word_madd2(x[1], y, &carry); + z[2] = word_madd2(x[2], y, &carry); + z[3] = word_madd2(x[3], y, &carry); + z[4] = word_madd2(x[4], y, &carry); + z[5] = word_madd2(x[5], y, &carry); + z[6] = word_madd2(x[6], y, &carry); + z[7] = word_madd2(x[7], y, &carry); return carry; } @@ -139,14 +139,14 @@ inline word word8_madd3(word z[8], const *************************************************/ inline word word8_madd3(word z[8], const word x[8], word y, word carry) { - z[0] = word_madd3(x[0], y, z[0], carry, &carry); - z[1] = word_madd3(x[1], y, z[1], carry, &carry); - z[2] = word_madd3(x[2], y, z[2], carry, &carry); - z[3] = word_madd3(x[3], y, z[3], carry, &carry); - z[4] = word_madd3(x[4], y, z[4], carry, &carry); - z[5] = word_madd3(x[5], y, z[5], carry, &carry); - z[6] = word_madd3(x[6], y, z[6], carry, &carry); - z[7] = word_madd3(x[7], y, z[7], carry, &carry); + z[0] = word_madd3(x[0], y, z[0], &carry); + z[1] = word_madd3(x[1], y, z[1], &carry); + z[2] = word_madd3(x[2], y, z[2], &carry); + z[3] = word_madd3(x[3], y, z[3], &carry); + z[4] = word_madd3(x[4], y, z[4], &carry); + z[5] = word_madd3(x[5], y, z[5], &carry); + z[6] = word_madd3(x[6], y, z[6], &carry); + z[7] = word_madd3(x[7], y, z[7], &carry); return carry; } @@ -155,9 +155,10 @@ inline void word3_muladd(word* w2, word* *************************************************/ inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b) { - *w0 = word_madd2(a, b, *w0, &b); - *w1 += b; - *w2 += (*w1 < b) ? 1 : 0; + word carry = *w0; + *w0 = word_madd2(a, b, &carry); + *w1 += carry; + *w2 += (*w1 < carry) ? 1 : 0; } /************************************************* @@ -165,14 +166,16 @@ inline void word3_muladd_2(word* w2, wor *************************************************/ inline void word3_muladd_2(word* w2, word* w1, word* w0, word a, word b) { - a = word_madd2(a, b, 0, &b); + word carry = 0; + a = word_madd2(a, b, &carry); + b = carry; word top = (b >> (BOTAN_MP_WORD_BITS-1)); b <<= 1; b |= (a >> (BOTAN_MP_WORD_BITS-1)); a <<= 1; - word carry = 0; + carry = 0; *w0 = word_add(*w0, a, &carry); *w1 = word_add(*w1, b, &carry); *w2 = word_add(*w2, top, &carry); ============================================================ --- botan/mp_misc.cpp 1602f6ca6969f4c503be6f203b5442b2ae0c1c0a +++ botan/mp_misc.cpp 67eaa1482b7df8b8a6c872218640ecdacaea00d7 @@ -1,6 +1,6 @@ /************************************************* * MP Misc Functions Source File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #include @@ -17,8 +17,8 @@ u32bit bigint_divcore(word q, word y1, w word x1, word x2, word x3) { word y0 = 0; - y2 = word_madd2(q, y2, y0, &y0); - y1 = word_madd2(q, y1, y0, &y0); + y2 = word_madd2(q, y2, &y0); + y1 = word_madd2(q, y1, &y0); if(y0 > x1) return 1; if(y0 < x1) return 0; @@ -83,7 +83,7 @@ word bigint_modop(word n1, word n0, word { word z = bigint_divop(n1, n0, d); word dummy = 0; - z = word_madd2(z, d, dummy, &dummy); + z = word_madd2(z, d, &dummy); return (n0-z); } ============================================================ --- botan/mp_mulop.cpp cfaafb643d3d5960509ca07f8370a044c291730d +++ botan/mp_mulop.cpp 5af819039b577d423cb8a27e7d8dc5f377ab3ebb @@ -1,6 +1,6 @@ /************************************************* * Multiply/Add Algorithm Source File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #include @@ -24,7 +24,7 @@ word bigint_mul_add_words(word z[], cons carry = word8_madd3(z + j, x + j, y, carry); for(u32bit j = blocks; j != x_size; ++j) - z[j] = word_madd3(x[j], y, z[j], carry, &carry); + z[j] = word_madd3(x[j], y, z[j], &carry); return carry; } ============================================================ --- botan/sha160.cpp 1e4669389c7963842f6a1da3e247f9b4ff0924d8 +++ botan/sha160.cpp 0a979fa28db0ace4a2d3a8f5473ae21e0780d1b7 @@ -1,6 +1,6 @@ /************************************************* * SHA-160 Source File * -* (C) 1999-2007 The Botan Project * +* (C) 1999-2008 The Botan Project * *************************************************/ #include @@ -54,11 +54,22 @@ void SHA_160::hash(const byte input[]) *************************************************/ void SHA_160::hash(const byte input[]) { - for(u32bit j = 0; j != 16; ++j) - W[j] = load_be(input, j); - for(u32bit j = 16; j != 80; ++j) - W[j] = rotate_left((W[j-3] ^ W[j-8] ^ W[j-14] ^ W[j-16]), 1); + for(u32bit j = 0; j != 16; j += 4) + { + W[j ] = load_be(input, j); + W[j+1] = load_be(input, j+1); + W[j+2] = load_be(input, j+2); + W[j+3] = load_be(input, j+3); + } + for(u32bit j = 16; j != 80; j += 4) + { + W[j ] = rotate_left((W[j-3] ^ W[j-8] ^ W[j-14] ^ W[j-16]), 1); + W[j+1] = rotate_left((W[j-2] ^ W[j-7] ^ W[j-13] ^ W[j-15]), 1); + W[j+2] = rotate_left((W[j-1] ^ W[j-6] ^ W[j-12] ^ W[j-14]), 1); + W[j+3] = rotate_left((W[j ] ^ W[j-5] ^ W[j-11] ^ W[j-13]), 1); + } + u32bit A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4];