From f51841ba5237952dda3e76df643d3ae13bed3df5 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 11 Aug 2009 02:31:17 +0000 Subject: Change the BlockCipher interface to support multi-block encryption and decryption. Currently only used for counter mode. Doesn't offer much advantage as-is (though might help slightly, in terms of cache effects), but allows for SIMD implementations to process multiple blocks in parallel when possible. Particularly thinking here of Serpent; TEA/XTEA also seem promising in this sense, as is Threefish once that is implemented as a standalone block cipher. --- src/block/aes/aes.cpp | 266 ++++++++++++++++++----------------- src/block/aes/aes.h | 6 +- src/block/block_cipher.h | 20 +-- src/block/blowfish/blowfish.cpp | 70 +++++---- src/block/blowfish/blowfish.h | 6 +- src/block/cast/cast128.cpp | 100 +++++++------ src/block/cast/cast128.h | 4 +- src/block/cast/cast256.cpp | 140 +++++++++--------- src/block/cast/cast256.h | 4 +- src/block/des/des.cpp | 144 +++++++++++-------- src/block/des/des.h | 8 +- src/block/des/desx.cpp | 28 ++-- src/block/des/desx.h | 4 +- src/block/gost_28147/gost_28147.cpp | 67 +++++---- src/block/gost_28147/gost_28147.h | 4 +- src/block/idea/idea.cpp | 132 +++++++++-------- src/block/idea/idea.h | 4 +- src/block/kasumi/kasumi.cpp | 110 ++++++++------- src/block/kasumi/kasumi.h | 4 +- src/block/lion/lion.cpp | 56 +++++--- src/block/lion/lion.h | 4 +- src/block/lubyrack/lubyrack.cpp | 104 ++++++++------ src/block/lubyrack/lubyrack.h | 4 +- src/block/mars/mars.cpp | 138 +++++++++--------- src/block/mars/mars.h | 4 +- src/block/misty1/misty1.cpp | 130 +++++++++-------- src/block/misty1/misty1.h | 4 +- src/block/noekeon/noekeon.cpp | 92 ++++++------ src/block/noekeon/noekeon.h | 4 +- src/block/rc2/rc2.cpp | 104 ++++++++------ src/block/rc2/rc2.h | 4 +- src/block/rc5/rc5.cpp | 72 ++++++---- src/block/rc5/rc5.h | 4 +- src/block/rc6/rc6.cpp | 140 +++++++++--------- src/block/rc6/rc6.h | 4 +- src/block/safer/safer_sk.cpp | 97 ++++++++----- src/block/safer/safer_sk.h | 4 +- src/block/seed/seed.cpp | 116 ++++++++------- src/block/seed/seed.h | 4 +- src/block/serpent/serpent.cpp | 172 +++++++++++----------- src/block/serpent/serpent.h | 4 +- src/block/serpent_ia32/serp_ia32.cpp | 18 ++- src/block/serpent_ia32/serp_ia32.h | 4 +- src/block/skipjack/skipjack.cpp | 68 +++++---- src/block/skipjack/skipjack.h | 4 +- src/block/square/square.cpp | 192 ++++++++++++++----------- src/block/square/square.h | 4 +- src/block/tea/tea.cpp | 52 ++++--- src/block/tea/tea.h | 4 +- src/block/twofish/twofish.cpp | 156 ++++++++++---------- src/block/twofish/twofish.h | 4 +- src/block/xtea/xtea.cpp | 44 +++--- src/block/xtea/xtea.h | 4 +- src/modes/ctr/ctr.cpp | 104 +++++++++++--- src/modes/ctr/ctr.h | 17 ++- 55 files changed, 1740 insertions(+), 1321 deletions(-) (limited to 'src') diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp index 9072b507b..34698ae7f 100644 --- a/src/block/aes/aes.cpp +++ b/src/block/aes/aes.cpp @@ -1,6 +1,6 @@ /** * AES -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -13,163 +13,175 @@ namespace Botan { /** * AES Encryption */ -void AES::enc(const byte in[], byte out[]) const +void AES::encrypt_n(const byte in[], byte out[], u32bit blocks) const { const u32bit* TE0 = TE; const u32bit* TE1 = TE + 256; const u32bit* TE2 = TE + 512; const u32bit* TE3 = TE + 768; - u32bit T0 = load_be(in, 0) ^ EK[0]; - u32bit T1 = load_be(in, 1) ^ EK[1]; - u32bit T2 = load_be(in, 2) ^ EK[2]; - u32bit T3 = load_be(in, 3) ^ EK[3]; - - u32bit B0, B1, B2, B3; - B0 = TE0[get_byte(0, T0)] ^ TE1[get_byte(1, T1)] ^ - TE2[get_byte(2, T2)] ^ TE3[get_byte(3, T3)] ^ EK[4]; - B1 = TE0[get_byte(0, T1)] ^ TE1[get_byte(1, T2)] ^ - TE2[get_byte(2, T3)] ^ TE3[get_byte(3, T0)] ^ EK[5]; - B2 = TE0[get_byte(0, T2)] ^ TE1[get_byte(1, T3)] ^ - TE2[get_byte(2, T0)] ^ TE3[get_byte(3, T1)] ^ EK[6]; - B3 = TE0[get_byte(0, T3)] ^ TE1[get_byte(1, T0)] ^ - TE2[get_byte(2, T1)] ^ TE3[get_byte(3, T2)] ^ EK[7]; - - for(u32bit j = 2; j != ROUNDS; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - const u32bit K0 = EK[4*j]; - const u32bit K1 = EK[4*j+1]; - const u32bit K2 = EK[4*j+2]; - const u32bit K3 = EK[4*j+3]; - - T0 = TE0[get_byte(0, B0)] ^ TE1[get_byte(1, B1)] ^ - TE2[get_byte(2, B2)] ^ TE3[get_byte(3, B3)] ^ K0; - T1 = TE0[get_byte(0, B1)] ^ TE1[get_byte(1, B2)] ^ - TE2[get_byte(2, B3)] ^ TE3[get_byte(3, B0)] ^ K1; - T2 = TE0[get_byte(0, B2)] ^ TE1[get_byte(1, B3)] ^ - TE2[get_byte(2, B0)] ^ TE3[get_byte(3, B1)] ^ K2; - T3 = TE0[get_byte(0, B3)] ^ TE1[get_byte(1, B0)] ^ - TE2[get_byte(2, B1)] ^ TE3[get_byte(3, B2)] ^ K3; - - const u32bit K4 = EK[4*(j+1)+0]; - const u32bit K5 = EK[4*(j+1)+1]; - const u32bit K6 = EK[4*(j+1)+2]; - const u32bit K7 = EK[4*(j+1)+3]; + u32bit T0 = load_be(in, 0) ^ EK[0]; + u32bit T1 = load_be(in, 1) ^ EK[1]; + u32bit T2 = load_be(in, 2) ^ EK[2]; + u32bit T3 = load_be(in, 3) ^ EK[3]; + u32bit B0, B1, B2, B3; B0 = TE0[get_byte(0, T0)] ^ TE1[get_byte(1, T1)] ^ - TE2[get_byte(2, T2)] ^ TE3[get_byte(3, T3)] ^ K4; + TE2[get_byte(2, T2)] ^ TE3[get_byte(3, T3)] ^ EK[4]; B1 = TE0[get_byte(0, T1)] ^ TE1[get_byte(1, T2)] ^ - TE2[get_byte(2, T3)] ^ TE3[get_byte(3, T0)] ^ K5; + TE2[get_byte(2, T3)] ^ TE3[get_byte(3, T0)] ^ EK[5]; B2 = TE0[get_byte(0, T2)] ^ TE1[get_byte(1, T3)] ^ - TE2[get_byte(2, T0)] ^ TE3[get_byte(3, T1)] ^ K6; + TE2[get_byte(2, T0)] ^ TE3[get_byte(3, T1)] ^ EK[6]; B3 = TE0[get_byte(0, T3)] ^ TE1[get_byte(1, T0)] ^ - TE2[get_byte(2, T1)] ^ TE3[get_byte(3, T2)] ^ K7; - } + TE2[get_byte(2, T1)] ^ TE3[get_byte(3, T2)] ^ EK[7]; + + for(u32bit j = 2; j != ROUNDS; j += 2) + { + const u32bit K0 = EK[4*j]; + const u32bit K1 = EK[4*j+1]; + const u32bit K2 = EK[4*j+2]; + const u32bit K3 = EK[4*j+3]; + + T0 = TE0[get_byte(0, B0)] ^ TE1[get_byte(1, B1)] ^ + TE2[get_byte(2, B2)] ^ TE3[get_byte(3, B3)] ^ K0; + T1 = TE0[get_byte(0, B1)] ^ TE1[get_byte(1, B2)] ^ + TE2[get_byte(2, B3)] ^ TE3[get_byte(3, B0)] ^ K1; + T2 = TE0[get_byte(0, B2)] ^ TE1[get_byte(1, B3)] ^ + TE2[get_byte(2, B0)] ^ TE3[get_byte(3, B1)] ^ K2; + T3 = TE0[get_byte(0, B3)] ^ TE1[get_byte(1, B0)] ^ + TE2[get_byte(2, B1)] ^ TE3[get_byte(3, B2)] ^ K3; + + const u32bit K4 = EK[4*(j+1)+0]; + const u32bit K5 = EK[4*(j+1)+1]; + const u32bit K6 = EK[4*(j+1)+2]; + const u32bit K7 = EK[4*(j+1)+3]; - /* - Joseph Bonneau and Ilya Mironov's paper - - Cache-Collision Timing Attacks Against AES describes an attack - that can recover AES keys with as few as 213 samples. - - """In addition to OpenSSL v. 0.9.8.(a), which was used in our - experiments, the AES implementations of Crypto++ 5.2.1 and - LibTomCrypt 1.09 use the original Rijndael C implementation with - very few changes and are highly vulnerable. The AES implementations - in libgcrypt v. 1.2.2 and Botan v. 1.4.2 are also vulnerable, but - use a smaller byte-wide final table which lessens the effectiveness - of the attacks.""" - */ - out[ 0] = SE[get_byte(0, B0)] ^ ME[0]; - out[ 1] = SE[get_byte(1, B1)] ^ ME[1]; - out[ 2] = SE[get_byte(2, B2)] ^ ME[2]; - out[ 3] = SE[get_byte(3, B3)] ^ ME[3]; - out[ 4] = SE[get_byte(0, B1)] ^ ME[4]; - out[ 5] = SE[get_byte(1, B2)] ^ ME[5]; - out[ 6] = SE[get_byte(2, B3)] ^ ME[6]; - out[ 7] = SE[get_byte(3, B0)] ^ ME[7]; - out[ 8] = SE[get_byte(0, B2)] ^ ME[8]; - out[ 9] = SE[get_byte(1, B3)] ^ ME[9]; - out[10] = SE[get_byte(2, B0)] ^ ME[10]; - out[11] = SE[get_byte(3, B1)] ^ ME[11]; - out[12] = SE[get_byte(0, B3)] ^ ME[12]; - out[13] = SE[get_byte(1, B0)] ^ ME[13]; - out[14] = SE[get_byte(2, B1)] ^ ME[14]; - out[15] = SE[get_byte(3, B2)] ^ ME[15]; + B0 = TE0[get_byte(0, T0)] ^ TE1[get_byte(1, T1)] ^ + TE2[get_byte(2, T2)] ^ TE3[get_byte(3, T3)] ^ K4; + B1 = TE0[get_byte(0, T1)] ^ TE1[get_byte(1, T2)] ^ + TE2[get_byte(2, T3)] ^ TE3[get_byte(3, T0)] ^ K5; + B2 = TE0[get_byte(0, T2)] ^ TE1[get_byte(1, T3)] ^ + TE2[get_byte(2, T0)] ^ TE3[get_byte(3, T1)] ^ K6; + B3 = TE0[get_byte(0, T3)] ^ TE1[get_byte(1, T0)] ^ + TE2[get_byte(2, T1)] ^ TE3[get_byte(3, T2)] ^ K7; + } + + /* + Joseph Bonneau and Ilya Mironov's paper + + Cache-Collision Timing Attacks Against AES describes an attack + that can recover AES keys with as few as 213 samples. + + """In addition to OpenSSL v. 0.9.8.(a), which was used in our + experiments, the AES implementations of Crypto++ 5.2.1 and + LibTomCrypt 1.09 use the original Rijndael C implementation with + very few changes and are highly vulnerable. The AES implementations + in libgcrypt v. 1.2.2 and Botan v. 1.4.2 are also vulnerable, but + use a smaller byte-wide final table which lessens the effectiveness + of the attacks.""" + */ + out[ 0] = SE[get_byte(0, B0)] ^ ME[0]; + out[ 1] = SE[get_byte(1, B1)] ^ ME[1]; + out[ 2] = SE[get_byte(2, B2)] ^ ME[2]; + out[ 3] = SE[get_byte(3, B3)] ^ ME[3]; + out[ 4] = SE[get_byte(0, B1)] ^ ME[4]; + out[ 5] = SE[get_byte(1, B2)] ^ ME[5]; + out[ 6] = SE[get_byte(2, B3)] ^ ME[6]; + out[ 7] = SE[get_byte(3, B0)] ^ ME[7]; + out[ 8] = SE[get_byte(0, B2)] ^ ME[8]; + out[ 9] = SE[get_byte(1, B3)] ^ ME[9]; + out[10] = SE[get_byte(2, B0)] ^ ME[10]; + out[11] = SE[get_byte(3, B1)] ^ ME[11]; + out[12] = SE[get_byte(0, B3)] ^ ME[12]; + out[13] = SE[get_byte(1, B0)] ^ ME[13]; + out[14] = SE[get_byte(2, B1)] ^ ME[14]; + out[15] = SE[get_byte(3, B2)] ^ ME[15]; + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /** * AES Decryption */ -void AES::dec(const byte in[], byte out[]) const +void AES::decrypt_n(const byte in[], byte out[], u32bit blocks) const { const u32bit* TD0 = TD; const u32bit* TD1 = TD + 256; const u32bit* TD2 = TD + 512; const u32bit* TD3 = TD + 768; - u32bit T0 = load_be(in, 0) ^ DK[0]; - u32bit T1 = load_be(in, 1) ^ DK[1]; - u32bit T2 = load_be(in, 2) ^ DK[2]; - u32bit T3 = load_be(in, 3) ^ DK[3]; - - u32bit B0, B1, B2, B3; - B0 = TD0[get_byte(0, T0)] ^ TD1[get_byte(1, T3)] ^ - TD2[get_byte(2, T2)] ^ TD3[get_byte(3, T1)] ^ DK[4]; - B1 = TD0[get_byte(0, T1)] ^ TD1[get_byte(1, T0)] ^ - TD2[get_byte(2, T3)] ^ TD3[get_byte(3, T2)] ^ DK[5]; - B2 = TD0[get_byte(0, T2)] ^ TD1[get_byte(1, T1)] ^ - TD2[get_byte(2, T0)] ^ TD3[get_byte(3, T3)] ^ DK[6]; - B3 = TD0[get_byte(0, T3)] ^ TD1[get_byte(1, T2)] ^ - TD2[get_byte(2, T1)] ^ TD3[get_byte(3, T0)] ^ DK[7]; - - for(u32bit j = 2; j != ROUNDS; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - const u32bit K0 = DK[4*j+0]; - const u32bit K1 = DK[4*j+1]; - const u32bit K2 = DK[4*j+2]; - const u32bit K3 = DK[4*j+3]; - - T0 = TD0[get_byte(0, B0)] ^ TD1[get_byte(1, B3)] ^ - TD2[get_byte(2, B2)] ^ TD3[get_byte(3, B1)] ^ K0; - T1 = TD0[get_byte(0, B1)] ^ TD1[get_byte(1, B0)] ^ - TD2[get_byte(2, B3)] ^ TD3[get_byte(3, B2)] ^ K1; - T2 = TD0[get_byte(0, B2)] ^ TD1[get_byte(1, B1)] ^ - TD2[get_byte(2, B0)] ^ TD3[get_byte(3, B3)] ^ K2; - T3 = TD0[get_byte(0, B3)] ^ TD1[get_byte(1, B2)] ^ - TD2[get_byte(2, B1)] ^ TD3[get_byte(3, B0)] ^ K3; - - const u32bit K4 = DK[4*(j+1)+0]; - const u32bit K5 = DK[4*(j+1)+1]; - const u32bit K6 = DK[4*(j+1)+2]; - const u32bit K7 = DK[4*(j+1)+3]; + u32bit T0 = load_be(in, 0) ^ DK[0]; + u32bit T1 = load_be(in, 1) ^ DK[1]; + u32bit T2 = load_be(in, 2) ^ DK[2]; + u32bit T3 = load_be(in, 3) ^ DK[3]; + u32bit B0, B1, B2, B3; B0 = TD0[get_byte(0, T0)] ^ TD1[get_byte(1, T3)] ^ - TD2[get_byte(2, T2)] ^ TD3[get_byte(3, T1)] ^ K4; + TD2[get_byte(2, T2)] ^ TD3[get_byte(3, T1)] ^ DK[4]; B1 = TD0[get_byte(0, T1)] ^ TD1[get_byte(1, T0)] ^ - TD2[get_byte(2, T3)] ^ TD3[get_byte(3, T2)] ^ K5; + TD2[get_byte(2, T3)] ^ TD3[get_byte(3, T2)] ^ DK[5]; B2 = TD0[get_byte(0, T2)] ^ TD1[get_byte(1, T1)] ^ - TD2[get_byte(2, T0)] ^ TD3[get_byte(3, T3)] ^ K6; + TD2[get_byte(2, T0)] ^ TD3[get_byte(3, T3)] ^ DK[6]; B3 = TD0[get_byte(0, T3)] ^ TD1[get_byte(1, T2)] ^ - TD2[get_byte(2, T1)] ^ TD3[get_byte(3, T0)] ^ K7; - } + TD2[get_byte(2, T1)] ^ TD3[get_byte(3, T0)] ^ DK[7]; + + for(u32bit j = 2; j != ROUNDS; j += 2) + { + const u32bit K0 = DK[4*j+0]; + const u32bit K1 = DK[4*j+1]; + const u32bit K2 = DK[4*j+2]; + const u32bit K3 = DK[4*j+3]; + + T0 = TD0[get_byte(0, B0)] ^ TD1[get_byte(1, B3)] ^ + TD2[get_byte(2, B2)] ^ TD3[get_byte(3, B1)] ^ K0; + T1 = TD0[get_byte(0, B1)] ^ TD1[get_byte(1, B0)] ^ + TD2[get_byte(2, B3)] ^ TD3[get_byte(3, B2)] ^ K1; + T2 = TD0[get_byte(0, B2)] ^ TD1[get_byte(1, B1)] ^ + TD2[get_byte(2, B0)] ^ TD3[get_byte(3, B3)] ^ K2; + T3 = TD0[get_byte(0, B3)] ^ TD1[get_byte(1, B2)] ^ + TD2[get_byte(2, B1)] ^ TD3[get_byte(3, B0)] ^ K3; + + const u32bit K4 = DK[4*(j+1)+0]; + const u32bit K5 = DK[4*(j+1)+1]; + const u32bit K6 = DK[4*(j+1)+2]; + const u32bit K7 = DK[4*(j+1)+3]; - out[ 0] = SD[get_byte(0, B0)] ^ MD[0]; - out[ 1] = SD[get_byte(1, B3)] ^ MD[1]; - out[ 2] = SD[get_byte(2, B2)] ^ MD[2]; - out[ 3] = SD[get_byte(3, B1)] ^ MD[3]; - out[ 4] = SD[get_byte(0, B1)] ^ MD[4]; - out[ 5] = SD[get_byte(1, B0)] ^ MD[5]; - out[ 6] = SD[get_byte(2, B3)] ^ MD[6]; - out[ 7] = SD[get_byte(3, B2)] ^ MD[7]; - out[ 8] = SD[get_byte(0, B2)] ^ MD[8]; - out[ 9] = SD[get_byte(1, B1)] ^ MD[9]; - out[10] = SD[get_byte(2, B0)] ^ MD[10]; - out[11] = SD[get_byte(3, B3)] ^ MD[11]; - out[12] = SD[get_byte(0, B3)] ^ MD[12]; - out[13] = SD[get_byte(1, B2)] ^ MD[13]; - out[14] = SD[get_byte(2, B1)] ^ MD[14]; - out[15] = SD[get_byte(3, B0)] ^ MD[15]; + B0 = TD0[get_byte(0, T0)] ^ TD1[get_byte(1, T3)] ^ + TD2[get_byte(2, T2)] ^ TD3[get_byte(3, T1)] ^ K4; + B1 = TD0[get_byte(0, T1)] ^ TD1[get_byte(1, T0)] ^ + TD2[get_byte(2, T3)] ^ TD3[get_byte(3, T2)] ^ K5; + B2 = TD0[get_byte(0, T2)] ^ TD1[get_byte(1, T1)] ^ + TD2[get_byte(2, T0)] ^ TD3[get_byte(3, T3)] ^ K6; + B3 = TD0[get_byte(0, T3)] ^ TD1[get_byte(1, T2)] ^ + TD2[get_byte(2, T1)] ^ TD3[get_byte(3, T0)] ^ K7; + } + + out[ 0] = SD[get_byte(0, B0)] ^ MD[0]; + out[ 1] = SD[get_byte(1, B3)] ^ MD[1]; + out[ 2] = SD[get_byte(2, B2)] ^ MD[2]; + out[ 3] = SD[get_byte(3, B1)] ^ MD[3]; + out[ 4] = SD[get_byte(0, B1)] ^ MD[4]; + out[ 5] = SD[get_byte(1, B0)] ^ MD[5]; + out[ 6] = SD[get_byte(2, B3)] ^ MD[6]; + out[ 7] = SD[get_byte(3, B2)] ^ MD[7]; + out[ 8] = SD[get_byte(0, B2)] ^ MD[8]; + out[ 9] = SD[get_byte(1, B1)] ^ MD[9]; + out[10] = SD[get_byte(2, B0)] ^ MD[10]; + out[11] = SD[get_byte(3, B3)] ^ MD[11]; + out[12] = SD[get_byte(0, B3)] ^ MD[12]; + out[13] = SD[get_byte(1, B2)] ^ MD[13]; + out[14] = SD[get_byte(2, B1)] ^ MD[14]; + out[15] = SD[get_byte(3, B0)] ^ MD[15]; + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /** diff --git a/src/block/aes/aes.h b/src/block/aes/aes.h index 05e2e3123..940e11a48 100644 --- a/src/block/aes/aes.h +++ b/src/block/aes/aes.h @@ -1,6 +1,6 @@ /** * AES -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -24,8 +24,8 @@ class BOTAN_DLL AES : public BlockCipher AES() : BlockCipher(16, 16, 32, 8) { ROUNDS = 14; } AES(u32bit); private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static u32bit S(u32bit); diff --git a/src/block/block_cipher.h b/src/block/block_cipher.h index 01c45af04..a27609171 100644 --- a/src/block/block_cipher.h +++ b/src/block/block_cipher.h @@ -1,6 +1,6 @@ /** * Block Cipher Base Class -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -45,7 +45,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm * @param out The byte array designated to hold the encrypted block. * Must be of length BLOCK_SIZE. */ - void encrypt(const byte in[], byte out[]) const { enc(in, out); } + void encrypt(const byte in[], byte out[]) const + { encrypt_n(in, out, 1); } /** * Decrypt a block. @@ -54,7 +55,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm * @param out The byte array designated to hold the decrypted block. * Must be of length BLOCK_SIZE. */ - void decrypt(const byte in[], byte out[]) const { dec(in, out); } + void decrypt(const byte in[], byte out[]) const + { decrypt_n(in, out, 1); } /** * Encrypt a block. @@ -62,7 +64,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm * Must be of length BLOCK_SIZE. Will hold the result when the function * has finished. */ - void encrypt(byte block[]) const { enc(block, block); } + void encrypt(byte block[]) const { encrypt_n(block, block, 1); } /** * Decrypt a block. @@ -70,7 +72,12 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm * Must be of length BLOCK_SIZE. Will hold the result when the function * has finished. */ - void decrypt(byte block[]) const { dec(block, block); } + void decrypt(byte block[]) const { decrypt_n(block, block, 1); } + + virtual void encrypt_n(const byte in[], byte out[], + u32bit blocks) const = 0; + virtual void decrypt_n(const byte in[], byte out[], + u32bit blocks) const = 0; /** * Get a new object representing the same algorithm as *this @@ -90,9 +97,6 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm BLOCK_SIZE(block_size) {} virtual ~BlockCipher() {} - private: - virtual void enc(const byte[], byte[]) const = 0; - virtual void dec(const byte[], byte[]) const = 0; }; } diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp index b0599d6c5..312603c3a 100644 --- a/src/block/blowfish/blowfish.cpp +++ b/src/block/blowfish/blowfish.cpp @@ -1,6 +1,6 @@ /* * Blowfish -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -13,59 +13,71 @@ namespace Botan { /* * Blowfish Encryption */ -void Blowfish::enc(const byte in[], byte out[]) const +void Blowfish::encrypt_n(const byte in[], byte out[], u32bit blocks) const { const u32bit* S1 = S + 0; const u32bit* S2 = S + 256; const u32bit* S3 = S + 512; const u32bit* S4 = S + 768; - u32bit L = load_be(in, 0); - u32bit R = load_be(in, 1); - - for(u32bit j = 0; j != 16; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - L ^= P[j]; - R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ - S3[get_byte(2, L)]) + S4[get_byte(3, L)]; + u32bit L = load_be(in, 0); + u32bit R = load_be(in, 1); - R ^= P[j+1]; - L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ - S3[get_byte(2, R)]) + S4[get_byte(3, R)]; - } + for(u32bit j = 0; j != 16; j += 2) + { + L ^= P[j]; + R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ + S3[get_byte(2, L)]) + S4[get_byte(3, L)]; - L ^= P[16]; R ^= P[17]; + R ^= P[j+1]; + L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ + S3[get_byte(2, R)]) + S4[get_byte(3, R)]; + } + + L ^= P[16]; R ^= P[17]; - store_be(out, R, L); + store_be(out, R, L); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Blowfish Decryption */ -void Blowfish::dec(const byte in[], byte out[]) const +void Blowfish::decrypt_n(const byte in[], byte out[], u32bit blocks) const { const u32bit* S1 = S + 0; const u32bit* S2 = S + 256; const u32bit* S3 = S + 512; const u32bit* S4 = S + 768; - u32bit L = load_be(in, 0); - u32bit R = load_be(in, 1); - - for(u32bit j = 17; j != 1; j -= 2) + for(u32bit i = 0; i != blocks; ++i) { - L ^= P[j]; - R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ - S3[get_byte(2, L)]) + S4[get_byte(3, L)]; + u32bit L = load_be(in, 0); + u32bit R = load_be(in, 1); - R ^= P[j-1]; - L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ - S3[get_byte(2, R)]) + S4[get_byte(3, R)]; - } + for(u32bit j = 17; j != 1; j -= 2) + { + L ^= P[j]; + R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ + S3[get_byte(2, L)]) + S4[get_byte(3, L)]; - L ^= P[1]; R ^= P[0]; + R ^= P[j-1]; + L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ + S3[get_byte(2, R)]) + S4[get_byte(3, R)]; + } + + L ^= P[1]; R ^= P[0]; - store_be(out, R, L); + store_be(out, R, L); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h index f0f26418d..3623c2087 100644 --- a/src/block/blowfish/blowfish.h +++ b/src/block/blowfish/blowfish.h @@ -1,6 +1,6 @@ /* * Blowfish -* (C) 1999-2008 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -23,8 +23,8 @@ class BOTAN_DLL Blowfish : public BlockCipher BlockCipher* clone() const { return new Blowfish; } Blowfish() : BlockCipher(8, 1, 56) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); void generate_sbox(u32bit[], u32bit, u32bit&, u32bit&) const; diff --git a/src/block/cast/cast128.cpp b/src/block/cast/cast128.cpp index 046638ab9..887dcf994 100644 --- a/src/block/cast/cast128.cpp +++ b/src/block/cast/cast128.cpp @@ -48,57 +48,69 @@ inline void R3(u32bit& L, u32bit R, u32bit MK, u32bit RK) /* * CAST-128 Encryption */ -void CAST_128::enc(const byte in[], byte out[]) const +void CAST_128::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit L = load_be(in, 0); - u32bit R = load_be(in, 1); - - R1(L, R, MK[ 0], RK[ 0]); - R2(R, L, MK[ 1], RK[ 1]); - R3(L, R, MK[ 2], RK[ 2]); - R1(R, L, MK[ 3], RK[ 3]); - R2(L, R, MK[ 4], RK[ 4]); - R3(R, L, MK[ 5], RK[ 5]); - R1(L, R, MK[ 6], RK[ 6]); - R2(R, L, MK[ 7], RK[ 7]); - R3(L, R, MK[ 8], RK[ 8]); - R1(R, L, MK[ 9], RK[ 9]); - R2(L, R, MK[10], RK[10]); - R3(R, L, MK[11], RK[11]); - R1(L, R, MK[12], RK[12]); - R2(R, L, MK[13], RK[13]); - R3(L, R, MK[14], RK[14]); - R1(R, L, MK[15], RK[15]); - - store_be(out, R, L); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit L = load_be(in, 0); + u32bit R = load_be(in, 1); + + R1(L, R, MK[ 0], RK[ 0]); + R2(R, L, MK[ 1], RK[ 1]); + R3(L, R, MK[ 2], RK[ 2]); + R1(R, L, MK[ 3], RK[ 3]); + R2(L, R, MK[ 4], RK[ 4]); + R3(R, L, MK[ 5], RK[ 5]); + R1(L, R, MK[ 6], RK[ 6]); + R2(R, L, MK[ 7], RK[ 7]); + R3(L, R, MK[ 8], RK[ 8]); + R1(R, L, MK[ 9], RK[ 9]); + R2(L, R, MK[10], RK[10]); + R3(R, L, MK[11], RK[11]); + R1(L, R, MK[12], RK[12]); + R2(R, L, MK[13], RK[13]); + R3(L, R, MK[14], RK[14]); + R1(R, L, MK[15], RK[15]); + + store_be(out, R, L); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * CAST-128 Decryption */ -void CAST_128::dec(const byte in[], byte out[]) const +void CAST_128::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit L = load_be(in, 0); - u32bit R = load_be(in, 1); - - R1(L, R, MK[15], RK[15]); - R3(R, L, MK[14], RK[14]); - R2(L, R, MK[13], RK[13]); - R1(R, L, MK[12], RK[12]); - R3(L, R, MK[11], RK[11]); - R2(R, L, MK[10], RK[10]); - R1(L, R, MK[ 9], RK[ 9]); - R3(R, L, MK[ 8], RK[ 8]); - R2(L, R, MK[ 7], RK[ 7]); - R1(R, L, MK[ 6], RK[ 6]); - R3(L, R, MK[ 5], RK[ 5]); - R2(R, L, MK[ 4], RK[ 4]); - R1(L, R, MK[ 3], RK[ 3]); - R3(R, L, MK[ 2], RK[ 2]); - R2(L, R, MK[ 1], RK[ 1]); - R1(R, L, MK[ 0], RK[ 0]); - - store_be(out, R, L); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit L = load_be(in, 0); + u32bit R = load_be(in, 1); + + R1(L, R, MK[15], RK[15]); + R3(R, L, MK[14], RK[14]); + R2(L, R, MK[13], RK[13]); + R1(R, L, MK[12], RK[12]); + R3(L, R, MK[11], RK[11]); + R2(R, L, MK[10], RK[10]); + R1(L, R, MK[ 9], RK[ 9]); + R3(R, L, MK[ 8], RK[ 8]); + R2(L, R, MK[ 7], RK[ 7]); + R1(R, L, MK[ 6], RK[ 6]); + R3(L, R, MK[ 5], RK[ 5]); + R2(R, L, MK[ 4], RK[ 4]); + R1(L, R, MK[ 3], RK[ 3]); + R3(R, L, MK[ 2], RK[ 2]); + R2(L, R, MK[ 1], RK[ 1]); + R1(R, L, MK[ 0], RK[ 0]); + + store_be(out, R, L); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h index 680481482..092ee824b 100644 --- a/src/block/cast/cast128.h +++ b/src/block/cast/cast128.h @@ -23,8 +23,8 @@ class BOTAN_DLL CAST_128 : public BlockCipher BlockCipher* clone() const { return new CAST_128; } CAST_128() : BlockCipher(8, 11, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static void key_schedule(u32bit[16], u32bit[4]); diff --git a/src/block/cast/cast256.cpp b/src/block/cast/cast256.cpp index 22ff876fa..7a4a4e805 100644 --- a/src/block/cast/cast256.cpp +++ b/src/block/cast/cast256.cpp @@ -48,77 +48,89 @@ void round3(u32bit& out, u32bit in, u32bit mask, u32bit rot) /* * CAST-256 Encryption */ -void CAST_256::enc(const byte in[], byte out[]) const +void CAST_256::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_be(in, 0); - u32bit B = load_be(in, 1); - u32bit C = load_be(in, 2); - u32bit D = load_be(in, 3); - - round1(C, D, MK[ 0], RK[ 0]); round2(B, C, MK[ 1], RK[ 1]); - round3(A, B, MK[ 2], RK[ 2]); round1(D, A, MK[ 3], RK[ 3]); - round1(C, D, MK[ 4], RK[ 4]); round2(B, C, MK[ 5], RK[ 5]); - round3(A, B, MK[ 6], RK[ 6]); round1(D, A, MK[ 7], RK[ 7]); - round1(C, D, MK[ 8], RK[ 8]); round2(B, C, MK[ 9], RK[ 9]); - round3(A, B, MK[10], RK[10]); round1(D, A, MK[11], RK[11]); - round1(C, D, MK[12], RK[12]); round2(B, C, MK[13], RK[13]); - round3(A, B, MK[14], RK[14]); round1(D, A, MK[15], RK[15]); - round1(C, D, MK[16], RK[16]); round2(B, C, MK[17], RK[17]); - round3(A, B, MK[18], RK[18]); round1(D, A, MK[19], RK[19]); - round1(C, D, MK[20], RK[20]); round2(B, C, MK[21], RK[21]); - round3(A, B, MK[22], RK[22]); round1(D, A, MK[23], RK[23]); - round1(D, A, MK[27], RK[27]); round3(A, B, MK[26], RK[26]); - round2(B, C, MK[25], RK[25]); round1(C, D, MK[24], RK[24]); - round1(D, A, MK[31], RK[31]); round3(A, B, MK[30], RK[30]); - round2(B, C, MK[29], RK[29]); round1(C, D, MK[28], RK[28]); - round1(D, A, MK[35], RK[35]); round3(A, B, MK[34], RK[34]); - round2(B, C, MK[33], RK[33]); round1(C, D, MK[32], RK[32]); - round1(D, A, MK[39], RK[39]); round3(A, B, MK[38], RK[38]); - round2(B, C, MK[37], RK[37]); round1(C, D, MK[36], RK[36]); - round1(D, A, MK[43], RK[43]); round3(A, B, MK[42], RK[42]); - round2(B, C, MK[41], RK[41]); round1(C, D, MK[40], RK[40]); - round1(D, A, MK[47], RK[47]); round3(A, B, MK[46], RK[46]); - round2(B, C, MK[45], RK[45]); round1(C, D, MK[44], RK[44]); - - store_be(out, A, B, C, D); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit A = load_be(in, 0); + u32bit B = load_be(in, 1); + u32bit C = load_be(in, 2); + u32bit D = load_be(in, 3); + + round1(C, D, MK[ 0], RK[ 0]); round2(B, C, MK[ 1], RK[ 1]); + round3(A, B, MK[ 2], RK[ 2]); round1(D, A, MK[ 3], RK[ 3]); + round1(C, D, MK[ 4], RK[ 4]); round2(B, C, MK[ 5], RK[ 5]); + round3(A, B, MK[ 6], RK[ 6]); round1(D, A, MK[ 7], RK[ 7]); + round1(C, D, MK[ 8], RK[ 8]); round2(B, C, MK[ 9], RK[ 9]); + round3(A, B, MK[10], RK[10]); round1(D, A, MK[11], RK[11]); + round1(C, D, MK[12], RK[12]); round2(B, C, MK[13], RK[13]); + round3(A, B, MK[14], RK[14]); round1(D, A, MK[15], RK[15]); + round1(C, D, MK[16], RK[16]); round2(B, C, MK[17], RK[17]); + round3(A, B, MK[18], RK[18]); round1(D, A, MK[19], RK[19]); + round1(C, D, MK[20], RK[20]); round2(B, C, MK[21], RK[21]); + round3(A, B, MK[22], RK[22]); round1(D, A, MK[23], RK[23]); + round1(D, A, MK[27], RK[27]); round3(A, B, MK[26], RK[26]); + round2(B, C, MK[25], RK[25]); round1(C, D, MK[24], RK[24]); + round1(D, A, MK[31], RK[31]); round3(A, B, MK[30], RK[30]); + round2(B, C, MK[29], RK[29]); round1(C, D, MK[28], RK[28]); + round1(D, A, MK[35], RK[35]); round3(A, B, MK[34], RK[34]); + round2(B, C, MK[33], RK[33]); round1(C, D, MK[32], RK[32]); + round1(D, A, MK[39], RK[39]); round3(A, B, MK[38], RK[38]); + round2(B, C, MK[37], RK[37]); round1(C, D, MK[36], RK[36]); + round1(D, A, MK[43], RK[43]); round3(A, B, MK[42], RK[42]); + round2(B, C, MK[41], RK[41]); round1(C, D, MK[40], RK[40]); + round1(D, A, MK[47], RK[47]); round3(A, B, MK[46], RK[46]); + round2(B, C, MK[45], RK[45]); round1(C, D, MK[44], RK[44]); + + store_be(out, A, B, C, D); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * CAST-256 Decryption */ -void CAST_256::dec(const byte in[], byte out[]) const +void CAST_256::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_be(in, 0); - u32bit B = load_be(in, 1); - u32bit C = load_be(in, 2); - u32bit D = load_be(in, 3); - - round1(C, D, MK[44], RK[44]); round2(B, C, MK[45], RK[45]); - round3(A, B, MK[46], RK[46]); round1(D, A, MK[47], RK[47]); - round1(C, D, MK[40], RK[40]); round2(B, C, MK[41], RK[41]); - round3(A, B, MK[42], RK[42]); round1(D, A, MK[43], RK[43]); - round1(C, D, MK[36], RK[36]); round2(B, C, MK[37], RK[37]); - round3(A, B, MK[38], RK[38]); round1(D, A, MK[39], RK[39]); - round1(C, D, MK[32], RK[32]); round2(B, C, MK[33], RK[33]); - round3(A, B, MK[34], RK[34]); round1(D, A, MK[35], RK[35]); - round1(C, D, MK[28], RK[28]); round2(B, C, MK[29], RK[29]); - round3(A, B, MK[30], RK[30]); round1(D, A, MK[31], RK[31]); - round1(C, D, MK[24], RK[24]); round2(B, C, MK[25], RK[25]); - round3(A, B, MK[26], RK[26]); round1(D, A, MK[27], RK[27]); - round1(D, A, MK[23], RK[23]); round3(A, B, MK[22], RK[22]); - round2(B, C, MK[21], RK[21]); round1(C, D, MK[20], RK[20]); - round1(D, A, MK[19], RK[19]); round3(A, B, MK[18], RK[18]); - round2(B, C, MK[17], RK[17]); round1(C, D, MK[16], RK[16]); - round1(D, A, MK[15], RK[15]); round3(A, B, MK[14], RK[14]); - round2(B, C, MK[13], RK[13]); round1(C, D, MK[12], RK[12]); - round1(D, A, MK[11], RK[11]); round3(A, B, MK[10], RK[10]); - round2(B, C, MK[ 9], RK[ 9]); round1(C, D, MK[ 8], RK[ 8]); - round1(D, A, MK[ 7], RK[ 7]); round3(A, B, MK[ 6], RK[ 6]); - round2(B, C, MK[ 5], RK[ 5]); round1(C, D, MK[ 4], RK[ 4]); - round1(D, A, MK[ 3], RK[ 3]); round3(A, B, MK[ 2], RK[ 2]); - round2(B, C, MK[ 1], RK[ 1]); round1(C, D, MK[ 0], RK[ 0]); - - store_be(out, A, B, C, D); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit A = load_be(in, 0); + u32bit B = load_be(in, 1); + u32bit C = load_be(in, 2); + u32bit D = load_be(in, 3); + + round1(C, D, MK[44], RK[44]); round2(B, C, MK[45], RK[45]); + round3(A, B, MK[46], RK[46]); round1(D, A, MK[47], RK[47]); + round1(C, D, MK[40], RK[40]); round2(B, C, MK[41], RK[41]); + round3(A, B, MK[42], RK[42]); round1(D, A, MK[43], RK[43]); + round1(C, D, MK[36], RK[36]); round2(B, C, MK[37], RK[37]); + round3(A, B, MK[38], RK[38]); round1(D, A, MK[39], RK[39]); + round1(C, D, MK[32], RK[32]); round2(B, C, MK[33], RK[33]); + round3(A, B, MK[34], RK[34]); round1(D, A, MK[35], RK[35]); + round1(C, D, MK[28], RK[28]); round2(B, C, MK[29], RK[29]); + round3(A, B, MK[30], RK[30]); round1(D, A, MK[31], RK[31]); + round1(C, D, MK[24], RK[24]); round2(B, C, MK[25], RK[25]); + round3(A, B, MK[26], RK[26]); round1(D, A, MK[27], RK[27]); + round1(D, A, MK[23], RK[23]); round3(A, B, MK[22], RK[22]); + round2(B, C, MK[21], RK[21]); round1(C, D, MK[20], RK[20]); + round1(D, A, MK[19], RK[19]); round3(A, B, MK[18], RK[18]); + round2(B, C, MK[17], RK[17]); round1(C, D, MK[16], RK[16]); + round1(D, A, MK[15], RK[15]); round3(A, B, MK[14], RK[14]); + round2(B, C, MK[13], RK[13]); round1(C, D, MK[12], RK[12]); + round1(D, A, MK[11], RK[11]); round3(A, B, MK[10], RK[10]); + round2(B, C, MK[ 9], RK[ 9]); round1(C, D, MK[ 8], RK[ 8]); + round1(D, A, MK[ 7], RK[ 7]); round3(A, B, MK[ 6], RK[ 6]); + round2(B, C, MK[ 5], RK[ 5]); round1(C, D, MK[ 4], RK[ 4]); + round1(D, A, MK[ 3], RK[ 3]); round3(A, B, MK[ 2], RK[ 2]); + round2(B, C, MK[ 1], RK[ 1]); round1(C, D, MK[ 0], RK[ 0]); + + store_be(out, A, B, C, D); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h index cd48edd5e..ea80df65d 100644 --- a/src/block/cast/cast256.h +++ b/src/block/cast/cast256.h @@ -23,8 +23,8 @@ class BOTAN_DLL CAST_256 : public BlockCipher BlockCipher* clone() const { return new CAST_256; } CAST_256() : BlockCipher(16, 4, 32, 4) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static const u32bit KEY_MASK[192]; diff --git a/src/block/des/des.cpp b/src/block/des/des.cpp index 37520e0fc..1c9d37e6b 100644 --- a/src/block/des/des.cpp +++ b/src/block/des/des.cpp @@ -139,51 +139,63 @@ void des_decrypt(u32bit& L, u32bit& R, /* * DES Encryption */ -void DES::enc(const byte in[], byte out[]) const +void DES::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | - (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | - (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | - (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + for(u32bit i = 0; i != blocks; ++i) + { + u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | + (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | + (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | + (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + + u32bit L = static_cast(T >> 32); + u32bit R = static_cast(T); - u32bit L = static_cast(T >> 32); - u32bit R = static_cast(T); + des_encrypt(L, R, round_key); - des_encrypt(L, R, round_key); + T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | + (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | + (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | + (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); - T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | - (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | - (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | - (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); + T = rotate_left(T, 32); - T = rotate_left(T, 32); + store_be(T, out); - store_be(T, out); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * DES Decryption */ -void DES::dec(const byte in[], byte out[]) const +void DES::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | - (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | - (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | - (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + for(u32bit i = 0; i != blocks; ++i) + { + u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | + (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | + (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | + (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + + u32bit L = static_cast(T >> 32); + u32bit R = static_cast(T); - u32bit L = static_cast(T >> 32); - u32bit R = static_cast(T); + des_decrypt(L, R, round_key); - des_decrypt(L, R, round_key); + T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | + (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | + (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | + (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); - T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | - (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | - (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | - (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); + T = rotate_left(T, 32); - T = rotate_left(T, 32); + store_be(T, out); - store_be(T, out); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* @@ -197,55 +209,67 @@ void DES::key_schedule(const byte key[], u32bit) /* * TripleDES Encryption */ -void TripleDES::enc(const byte in[], byte out[]) const +void TripleDES::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | - (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | - (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | - (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + for(u32bit i = 0; i != blocks; ++i) + { + u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | + (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | + (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | + (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + + u32bit L = static_cast(T >> 32); + u32bit R = static_cast(T); - u32bit L = static_cast(T >> 32); - u32bit R = static_cast(T); + des_encrypt(L, R, round_key); + des_decrypt(R, L, round_key + 32); + des_encrypt(L, R, round_key + 64); - des_encrypt(L, R, round_key); - des_decrypt(R, L, round_key + 32); - des_encrypt(L, R, round_key + 64); + T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | + (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | + (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | + (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); - T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | - (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | - (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | - (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); + T = rotate_left(T, 32); - T = rotate_left(T, 32); + store_be(T, out); - store_be(T, out); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * TripleDES Decryption */ -void TripleDES::dec(const byte in[], byte out[]) const +void TripleDES::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | - (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | - (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | - (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + for(u32bit i = 0; i != blocks; ++i) + { + u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) | + (DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) | + (DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) | + (DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] ); + + u32bit L = static_cast(T >> 32); + u32bit R = static_cast(T); - u32bit L = static_cast(T >> 32); - u32bit R = static_cast(T); + des_decrypt(L, R, round_key + 64); + des_encrypt(R, L, round_key + 32); + des_decrypt(L, R, round_key); - des_decrypt(L, R, round_key + 64); - des_encrypt(R, L, round_key + 32); - des_decrypt(L, R, round_key); + T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | + (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | + (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | + (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); - T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | - (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | - (DES_FPTAB1[get_byte(0, R)] << 4) | (DES_FPTAB1[get_byte(1, R)] << 2) | - (DES_FPTAB1[get_byte(2, R)] ) | (DES_FPTAB2[get_byte(3, R)] ); + T = rotate_left(T, 32); - T = rotate_left(T, 32); + store_be(T, out); - store_be(T, out); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/des/des.h b/src/block/des/des.h index 6fa59de5e..39d1ac404 100644 --- a/src/block/des/des.h +++ b/src/block/des/des.h @@ -23,8 +23,8 @@ class BOTAN_DLL DES : public BlockCipher BlockCipher* clone() const { return new DES; } DES() : BlockCipher(8, 8) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer round_key; @@ -41,8 +41,8 @@ class BOTAN_DLL TripleDES : public BlockCipher BlockCipher* clone() const { return new TripleDES; } TripleDES() : BlockCipher(8, 16, 24, 8) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer round_key; diff --git a/src/block/des/desx.cpp b/src/block/des/desx.cpp index e557901d3..1fc1c47f2 100644 --- a/src/block/des/desx.cpp +++ b/src/block/des/desx.cpp @@ -13,21 +13,33 @@ namespace Botan { /* * DESX Encryption */ -void DESX::enc(const byte in[], byte out[]) const +void DESX::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - xor_buf(out, in, K1.begin(), BLOCK_SIZE); - des.encrypt(out); - xor_buf(out, K2.begin(), BLOCK_SIZE); + for(u32bit i = 0; i != blocks; ++i) + { + xor_buf(out, in, K1.begin(), BLOCK_SIZE); + des.encrypt(out); + xor_buf(out, K2.begin(), BLOCK_SIZE); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * DESX Decryption */ -void DESX::dec(const byte in[], byte out[]) const +void DESX::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - xor_buf(out, in, K2.begin(), BLOCK_SIZE); - des.decrypt(out); - xor_buf(out, K1.begin(), BLOCK_SIZE); + for(u32bit i = 0; i != blocks; ++i) + { + xor_buf(out, in, K2.begin(), BLOCK_SIZE); + des.decrypt(out); + xor_buf(out, K1.begin(), BLOCK_SIZE); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/des/desx.h b/src/block/des/desx.h index 49ecc2421..d71335071 100644 --- a/src/block/des/desx.h +++ b/src/block/des/desx.h @@ -23,8 +23,8 @@ class BOTAN_DLL DESX : public BlockCipher BlockCipher* clone() const { return new DESX; } DESX() : BlockCipher(8, 24) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer K1, K2; DES des; diff --git a/src/block/gost_28147/gost_28147.cpp b/src/block/gost_28147/gost_28147.cpp index bfd092c56..272f1bcab 100644 --- a/src/block/gost_28147/gost_28147.cpp +++ b/src/block/gost_28147/gost_28147.cpp @@ -84,47 +84,58 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : /* * GOST Encryption */ -void GOST_28147_89::enc(const byte in[], byte out[]) const +void GOST_28147_89::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit N1 = load_le(in, 0), N2 = load_le(in, 1); - - for(size_t i = 0; i != 3; ++i) + for(u32bit i = 0; i != blocks; ++i) { - GOST_2ROUND(N1, N2, 0, 1); - GOST_2ROUND(N1, N2, 2, 3); - GOST_2ROUND(N1, N2, 4, 5); - GOST_2ROUND(N1, N2, 6, 7); - } + u32bit N1 = load_le(in, 0), N2 = load_le(in, 1); - GOST_2ROUND(N1, N2, 7, 6); - GOST_2ROUND(N1, N2, 5, 4); - GOST_2ROUND(N1, N2, 3, 2); - GOST_2ROUND(N1, N2, 1, 0); + for(size_t j = 0; j != 3; ++j) + { + GOST_2ROUND(N1, N2, 0, 1); + GOST_2ROUND(N1, N2, 2, 3); + GOST_2ROUND(N1, N2, 4, 5); + GOST_2ROUND(N1, N2, 6, 7); + } - store_le(out, N2, N1); + GOST_2ROUND(N1, N2, 7, 6); + GOST_2ROUND(N1, N2, 5, 4); + GOST_2ROUND(N1, N2, 3, 2); + GOST_2ROUND(N1, N2, 1, 0); + + store_le(out, N2, N1); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * GOST Decryption */ -void GOST_28147_89::dec(const byte in[], byte out[]) const +void GOST_28147_89::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit N1 = load_le(in, 0), N2 = load_le(in, 1); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit N1 = load_le(in, 0), N2 = load_le(in, 1); - GOST_2ROUND(N1, N2, 0, 1); - GOST_2ROUND(N1, N2, 2, 3); - GOST_2ROUND(N1, N2, 4, 5); - GOST_2ROUND(N1, N2, 6, 7); + GOST_2ROUND(N1, N2, 0, 1); + GOST_2ROUND(N1, N2, 2, 3); + GOST_2ROUND(N1, N2, 4, 5); + GOST_2ROUND(N1, N2, 6, 7); - for(size_t i = 0; i != 3; ++i) - { - GOST_2ROUND(N1, N2, 7, 6); - GOST_2ROUND(N1, N2, 5, 4); - GOST_2ROUND(N1, N2, 3, 2); - GOST_2ROUND(N1, N2, 1, 0); - } + for(size_t i = 0; i != 3; ++i) + { + GOST_2ROUND(N1, N2, 7, 6); + GOST_2ROUND(N1, N2, 5, 4); + GOST_2ROUND(N1, N2, 3, 2); + GOST_2ROUND(N1, N2, 1, 0); + } - store_le(out, N2, N1); + store_le(out, N2, N1); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/gost_28147/gost_28147.h b/src/block/gost_28147/gost_28147.h index 96d24c669..825e106a2 100644 --- a/src/block/gost_28147/gost_28147.h +++ b/src/block/gost_28147/gost_28147.h @@ -54,8 +54,8 @@ class BOTAN_DLL GOST_28147_89 : public BlockCipher GOST_28147_89(const SecureBuffer& other_SBOX) : BlockCipher(8, 32), SBOX(other_SBOX) {} - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer SBOX; diff --git a/src/block/idea/idea.cpp b/src/block/idea/idea.cpp index 5bbe47087..fb5fe83f1 100644 --- a/src/block/idea/idea.cpp +++ b/src/block/idea/idea.cpp @@ -60,77 +60,89 @@ u16bit mul_inv(u16bit x) /* * IDEA Encryption */ -void IDEA::enc(const byte in[], byte out[]) const +void IDEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit X1 = load_be(in, 0); - u16bit X2 = load_be(in, 1); - u16bit X3 = load_be(in, 2); - u16bit X4 = load_be(in, 3); - - for(u32bit j = 0; j != 8; ++j) + for(u32bit i = 0; i != blocks; ++i) { - X1 = mul(X1, EK[6*j+0]); - X2 += EK[6*j+1]; - X3 += EK[6*j+2]; - X4 = mul(X4, EK[6*j+3]); - - u16bit T0 = X3; - X3 = mul(X3 ^ X1, EK[6*j+4]); - - u16bit T1 = X2; - X2 = mul((X2 ^ X4) + X3, EK[6*j+5]); - X3 += X2; - - X1 ^= X2; - X4 ^= X3; - X2 ^= T0; - X3 ^= T1; + u16bit X1 = load_be(in, 0); + u16bit X2 = load_be(in, 1); + u16bit X3 = load_be(in, 2); + u16bit X4 = load_be(in, 3); + + for(u32bit j = 0; j != 8; ++j) + { + X1 = mul(X1, EK[6*j+0]); + X2 += EK[6*j+1]; + X3 += EK[6*j+2]; + X4 = mul(X4, EK[6*j+3]); + + u16bit T0 = X3; + X3 = mul(X3 ^ X1, EK[6*j+4]); + + u16bit T1 = X2; + X2 = mul((X2 ^ X4) + X3, EK[6*j+5]); + X3 += X2; + + X1 ^= X2; + X4 ^= X3; + X2 ^= T0; + X3 ^= T1; + } + + X1 = mul(X1, EK[48]); + X2 += EK[50]; + X3 += EK[49]; + X4 = mul(X4, EK[51]); + + store_be(out, X1, X3, X2, X4); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - - X1 = mul(X1, EK[48]); - X2 += EK[50]; - X3 += EK[49]; - X4 = mul(X4, EK[51]); - - store_be(out, X1, X3, X2, X4); } /* * IDEA Decryption */ -void IDEA::dec(const byte in[], byte out[]) const +void IDEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit X1 = load_be(in, 0); - u16bit X2 = load_be(in, 1); - u16bit X3 = load_be(in, 2); - u16bit X4 = load_be(in, 3); - - for(u32bit j = 0; j != 8; ++j) + for(u32bit i = 0; i != blocks; ++i) { - X1 = mul(X1, DK[6*j+0]); - X2 += DK[6*j+1]; - X3 += DK[6*j+2]; - X4 = mul(X4, DK[6*j+3]); - - u16bit T0 = X3; - X3 = mul(X3 ^ X1, DK[6*j+4]); - - u16bit T1 = X2; - X2 = mul((X2 ^ X4) + X3, DK[6*j+5]); - X3 += X2; - - X1 ^= X2; - X4 ^= X3; - X2 ^= T0; - X3 ^= T1; + u16bit X1 = load_be(in, 0); + u16bit X2 = load_be(in, 1); + u16bit X3 = load_be(in, 2); + u16bit X4 = load_be(in, 3); + + for(u32bit j = 0; j != 8; ++j) + { + X1 = mul(X1, DK[6*j+0]); + X2 += DK[6*j+1]; + X3 += DK[6*j+2]; + X4 = mul(X4, DK[6*j+3]); + + u16bit T0 = X3; + X3 = mul(X3 ^ X1, DK[6*j+4]); + + u16bit T1 = X2; + X2 = mul((X2 ^ X4) + X3, DK[6*j+5]); + X3 += X2; + + X1 ^= X2; + X4 ^= X3; + X2 ^= T0; + X3 ^= T1; + } + + X1 = mul(X1, DK[48]); + X2 += DK[50]; + X3 += DK[49]; + X4 = mul(X4, DK[51]); + + store_be(out, X1, X3, X2, X4); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - - X1 = mul(X1, DK[48]); - X2 += DK[50]; - X3 += DK[49]; - X4 = mul(X4, DK[51]); - - store_be(out, X1, X3, X2, X4); } /* diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h index 2c53cd0e4..a3384b667 100644 --- a/src/block/idea/idea.h +++ b/src/block/idea/idea.h @@ -23,8 +23,8 @@ class BOTAN_DLL IDEA : public BlockCipher BlockCipher* clone() const { return new IDEA; } IDEA() : BlockCipher(8, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK, DK; }; diff --git a/src/block/kasumi/kasumi.cpp b/src/block/kasumi/kasumi.cpp index e051ddefb..dff6db13c 100644 --- a/src/block/kasumi/kasumi.cpp +++ b/src/block/kasumi/kasumi.cpp @@ -109,79 +109,91 @@ u16bit FI(u16bit I, u16bit K) /* * KASUMI Encryption */ -void KASUMI::enc(const byte in[], byte out[]) const +void KASUMI::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit B0 = load_be(in, 0); - u16bit B1 = load_be(in, 1); - u16bit B2 = load_be(in, 2); - u16bit B3 = load_be(in, 3); - - for(u32bit j = 0; j != 8; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - const u16bit* K = EK + 8*j; + u16bit B0 = load_be(in, 0); + u16bit B1 = load_be(in, 1); + u16bit B2 = load_be(in, 2); + u16bit B3 = load_be(in, 3); - u16bit R = B1 ^ (rotate_left(B0, 1) & K[0]); - u16bit L = B0 ^ (rotate_left(R, 1) | K[1]); + for(u32bit j = 0; j != 8; j += 2) + { + const u16bit* K = EK + 8*j; - L = FI(L ^ K[ 2], K[ 3]) ^ R; - R = FI(R ^ K[ 4], K[ 5]) ^ L; - L = FI(L ^ K[ 6], K[ 7]) ^ R; + u16bit R = B1 ^ (rotate_left(B0, 1) & K[0]); + u16bit L = B0 ^ (rotate_left(R, 1) | K[1]); - R = B2 ^= R; - L = B3 ^= L; + L = FI(L ^ K[ 2], K[ 3]) ^ R; + R = FI(R ^ K[ 4], K[ 5]) ^ L; + L = FI(L ^ K[ 6], K[ 7]) ^ R; - R = FI(R ^ K[10], K[11]) ^ L; - L = FI(L ^ K[12], K[13]) ^ R; - R = FI(R ^ K[14], K[15]) ^ L; + R = B2 ^= R; + L = B3 ^= L; - R ^= (rotate_left(L, 1) & K[8]); - L ^= (rotate_left(R, 1) | K[9]); + R = FI(R ^ K[10], K[11]) ^ L; + L = FI(L ^ K[12], K[13]) ^ R; + R = FI(R ^ K[14], K[15]) ^ L; - B0 ^= L; - B1 ^= R; - } + R ^= (rotate_left(L, 1) & K[8]); + L ^= (rotate_left(R, 1) | K[9]); + + B0 ^= L; + B1 ^= R; + } - store_be(out, B0, B1, B2, B3); + store_be(out, B0, B1, B2, B3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * KASUMI Decryption */ -void KASUMI::dec(const byte in[], byte out[]) const +void KASUMI::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit B0 = load_be(in, 0); - u16bit B1 = load_be(in, 1); - u16bit B2 = load_be(in, 2); - u16bit B3 = load_be(in, 3); - - for(u32bit j = 0; j != 8; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - const u16bit* K = EK + 8*(6-j); + u16bit B0 = load_be(in, 0); + u16bit B1 = load_be(in, 1); + u16bit B2 = load_be(in, 2); + u16bit B3 = load_be(in, 3); - u16bit L = B2, R = B3; + for(u32bit j = 0; j != 8; j += 2) + { + const u16bit* K = EK + 8*(6-j); - L = FI(L ^ K[10], K[11]) ^ R; - R = FI(R ^ K[12], K[13]) ^ L; - L = FI(L ^ K[14], K[15]) ^ R; + u16bit L = B2, R = B3; - L ^= (rotate_left(R, 1) & K[8]); - R ^= (rotate_left(L, 1) | K[9]); + L = FI(L ^ K[10], K[11]) ^ R; + R = FI(R ^ K[12], K[13]) ^ L; + L = FI(L ^ K[14], K[15]) ^ R; - R = B0 ^= R; - L = B1 ^= L; + L ^= (rotate_left(R, 1) & K[8]); + R ^= (rotate_left(L, 1) | K[9]); - L ^= (rotate_left(R, 1) & K[0]); - R ^= (rotate_left(L, 1) | K[1]); + R = B0 ^= R; + L = B1 ^= L; - R = FI(R ^ K[2], K[3]) ^ L; - L = FI(L ^ K[4], K[5]) ^ R; - R = FI(R ^ K[6], K[7]) ^ L; + L ^= (rotate_left(R, 1) & K[0]); + R ^= (rotate_left(L, 1) | K[1]); - B2 ^= L; - B3 ^= R; - } + R = FI(R ^ K[2], K[3]) ^ L; + L = FI(L ^ K[4], K[5]) ^ R; + R = FI(R ^ K[6], K[7]) ^ L; + + B2 ^= L; + B3 ^= R; + } - store_be(out, B0, B1, B2, B3); + store_be(out, B0, B1, B2, B3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/kasumi/kasumi.h b/src/block/kasumi/kasumi.h index df49fa9eb..3b18e675b 100644 --- a/src/block/kasumi/kasumi.h +++ b/src/block/kasumi/kasumi.h @@ -24,8 +24,8 @@ class BOTAN_DLL KASUMI : public BlockCipher KASUMI() : BlockCipher(8, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK; diff --git a/src/block/lion/lion.cpp b/src/block/lion/lion.cpp index c7cdf6d13..bfff64b67 100644 --- a/src/block/lion/lion.cpp +++ b/src/block/lion/lion.cpp @@ -14,41 +14,53 @@ namespace Botan { /* * Lion Encryption */ -void Lion::enc(const byte in[], byte out[]) const +void Lion::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - SecureVector buffer(LEFT_SIZE); + for(u32bit i = 0; i != blocks; ++i) + { + SecureVector buffer(LEFT_SIZE); - xor_buf(buffer, in, key1, LEFT_SIZE); - cipher->set_key(buffer, LEFT_SIZE); - cipher->encrypt(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE); + xor_buf(buffer, in, key1, LEFT_SIZE); + cipher->set_key(buffer, LEFT_SIZE); + cipher->encrypt(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE); - hash->update(out + LEFT_SIZE, RIGHT_SIZE); - hash->final(buffer); - xor_buf(out, in, buffer, LEFT_SIZE); + hash->update(out + LEFT_SIZE, RIGHT_SIZE); + hash->final(buffer); + xor_buf(out, in, buffer, LEFT_SIZE); - xor_buf(buffer, out, key2, LEFT_SIZE); - cipher->set_key(buffer, LEFT_SIZE); - cipher->encrypt(out + LEFT_SIZE, RIGHT_SIZE); + xor_buf(buffer, out, key2, LEFT_SIZE); + cipher->set_key(buffer, LEFT_SIZE); + cipher->encrypt(out + LEFT_SIZE, RIGHT_SIZE); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Lion Decryption */ -void Lion::dec(const byte in[], byte out[]) const +void Lion::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - SecureVector buffer(LEFT_SIZE); + for(u32bit i = 0; i != blocks; ++i) + { + SecureVector buffer(LEFT_SIZE); + + xor_buf(buffer, in, key2, LEFT_SIZE); + cipher->set_key(buffer, LEFT_SIZE); + cipher->encrypt(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE); - xor_buf(buffer, in, key2, LEFT_SIZE); - cipher->set_key(buffer, LEFT_SIZE); - cipher->encrypt(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE); + hash->update(out + LEFT_SIZE, RIGHT_SIZE); + hash->final(buffer); + xor_buf(out, in, buffer, LEFT_SIZE); - hash->update(out + LEFT_SIZE, RIGHT_SIZE); - hash->final(buffer); - xor_buf(out, in, buffer, LEFT_SIZE); + xor_buf(buffer, out, key1, LEFT_SIZE); + cipher->set_key(buffer, LEFT_SIZE); + cipher->encrypt(out + LEFT_SIZE, RIGHT_SIZE); - xor_buf(buffer, out, key1, LEFT_SIZE); - cipher->set_key(buffer, LEFT_SIZE); - cipher->encrypt(out + LEFT_SIZE, RIGHT_SIZE); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/lion/lion.h b/src/block/lion/lion.h index 5bc4e72c0..d9f933846 100644 --- a/src/block/lion/lion.h +++ b/src/block/lion/lion.h @@ -27,8 +27,8 @@ class BOTAN_DLL Lion : public BlockCipher Lion(HashFunction*, StreamCipher*, u32bit); ~Lion() { delete hash; delete cipher; } private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); const u32bit LEFT_SIZE, RIGHT_SIZE; diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp index a9d2b1db2..6ad64f2b0 100644 --- a/src/block/lubyrack/lubyrack.cpp +++ b/src/block/lubyrack/lubyrack.cpp @@ -13,59 +13,71 @@ namespace Botan { /* * Luby-Rackoff Encryption */ -void LubyRackoff::enc(const byte in[], byte out[]) const +void LubyRackoff::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - const u32bit len = hash->OUTPUT_LENGTH; - - SecureVector buffer(len); - hash->update(K1); - hash->update(in, len); - hash->final(buffer); - xor_buf(out + len, in + len, buffer, len); - - hash->update(K2); - hash->update(out + len, len); - hash->final(buffer); - xor_buf(out, in, buffer, len); - - hash->update(K1); - hash->update(out, len); - hash->final(buffer); - xor_buf(out + len, buffer, len); - - hash->update(K2); - hash->update(out + len, len); - hash->final(buffer); - xor_buf(out, buffer, len); + for(u32bit i = 0; i != blocks; ++i) + { + const u32bit len = hash->OUTPUT_LENGTH; + + SecureVector buffer(len); + hash->update(K1); + hash->update(in, len); + hash->final(buffer); + xor_buf(out + len, in + len, buffer, len); + + hash->update(K2); + hash->update(out + len, len); + hash->final(buffer); + xor_buf(out, in, buffer, len); + + hash->update(K1); + hash->update(out, len); + hash->final(buffer); + xor_buf(out + len, buffer, len); + + hash->update(K2); + hash->update(out + len, len); + hash->final(buffer); + xor_buf(out, buffer, len); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Luby-Rackoff Decryption */ -void LubyRackoff::dec(const byte in[], byte out[]) const +void LubyRackoff::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - const u32bit len = hash->OUTPUT_LENGTH; - - SecureVector buffer(len); - hash->update(K2); - hash->update(in + len, len); - hash->final(buffer); - xor_buf(out, in, buffer, len); - - hash->update(K1); - hash->update(out, len); - hash->final(buffer); - xor_buf(out + len, in + len, buffer, len); - - hash->update(K2); - hash->update(out + len, len); - hash->final(buffer); - xor_buf(out, buffer, len); - - hash->update(K1); - hash->update(out, len); - hash->final(buffer); - xor_buf(out + len, buffer, len); + for(u32bit i = 0; i != blocks; ++i) + { + const u32bit len = hash->OUTPUT_LENGTH; + + SecureVector buffer(len); + hash->update(K2); + hash->update(in + len, len); + hash->final(buffer); + xor_buf(out, in, buffer, len); + + hash->update(K1); + hash->update(out, len); + hash->final(buffer); + xor_buf(out + len, in + len, buffer, len); + + hash->update(K2); + hash->update(out + len, len); + hash->final(buffer); + xor_buf(out, buffer, len); + + hash->update(K1); + hash->update(out, len); + hash->final(buffer); + xor_buf(out + len, buffer, len); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/lubyrack/lubyrack.h b/src/block/lubyrack/lubyrack.h index ebde31304..1e83748a6 100644 --- a/src/block/lubyrack/lubyrack.h +++ b/src/block/lubyrack/lubyrack.h @@ -26,8 +26,8 @@ class BOTAN_DLL LubyRackoff : public BlockCipher LubyRackoff(HashFunction* hash); ~LubyRackoff() { delete hash; } private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); HashFunction* hash; SecureVector K1, K2; diff --git a/src/block/mars/mars.cpp b/src/block/mars/mars.cpp index 08c8409c5..69556acb3 100644 --- a/src/block/mars/mars.cpp +++ b/src/block/mars/mars.cpp @@ -1,6 +1,6 @@ /* * MARS -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -50,75 +50,87 @@ u32bit gen_mask(u32bit input) /* * MARS Encryption */ -void MARS::enc(const byte in[], byte out[]) const +void MARS::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0) + EK[0]; - u32bit B = load_le(in, 1) + EK[1]; - u32bit C = load_le(in, 2) + EK[2]; - u32bit D = load_le(in, 3) + EK[3]; - - forward_mix(A, B, C, D); - - encrypt_round(A, B, C, D, 0); - encrypt_round(B, C, D, A, 1); - encrypt_round(C, D, A, B, 2); - encrypt_round(D, A, B, C, 3); - encrypt_round(A, B, C, D, 4); - encrypt_round(B, C, D, A, 5); - encrypt_round(C, D, A, B, 6); - encrypt_round(D, A, B, C, 7); - - encrypt_round(A, D, C, B, 8); - encrypt_round(B, A, D, C, 9); - encrypt_round(C, B, A, D, 10); - encrypt_round(D, C, B, A, 11); - encrypt_round(A, D, C, B, 12); - encrypt_round(B, A, D, C, 13); - encrypt_round(C, B, A, D, 14); - encrypt_round(D, C, B, A, 15); - - reverse_mix(A, B, C, D); - - A -= EK[36]; B -= EK[37]; C -= EK[38]; D -= EK[39]; - - store_le(out, A, B, C, D); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit A = load_le(in, 0) + EK[0]; + u32bit B = load_le(in, 1) + EK[1]; + u32bit C = load_le(in, 2) + EK[2]; + u32bit D = load_le(in, 3) + EK[3]; + + forward_mix(A, B, C, D); + + encrypt_round(A, B, C, D, 0); + encrypt_round(B, C, D, A, 1); + encrypt_round(C, D, A, B, 2); + encrypt_round(D, A, B, C, 3); + encrypt_round(A, B, C, D, 4); + encrypt_round(B, C, D, A, 5); + encrypt_round(C, D, A, B, 6); + encrypt_round(D, A, B, C, 7); + + encrypt_round(A, D, C, B, 8); + encrypt_round(B, A, D, C, 9); + encrypt_round(C, B, A, D, 10); + encrypt_round(D, C, B, A, 11); + encrypt_round(A, D, C, B, 12); + encrypt_round(B, A, D, C, 13); + encrypt_round(C, B, A, D, 14); + encrypt_round(D, C, B, A, 15); + + reverse_mix(A, B, C, D); + + A -= EK[36]; B -= EK[37]; C -= EK[38]; D -= EK[39]; + + store_le(out, A, B, C, D); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * MARS Decryption */ -void MARS::dec(const byte in[], byte out[]) const +void MARS::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 3) + EK[39]; - u32bit B = load_le(in, 2) + EK[38]; - u32bit C = load_le(in, 1) + EK[37]; - u32bit D = load_le(in, 0) + EK[36]; - - forward_mix(A, B, C, D); - - decrypt_round(A, B, C, D, 15); - decrypt_round(B, C, D, A, 14); - decrypt_round(C, D, A, B, 13); - decrypt_round(D, A, B, C, 12); - decrypt_round(A, B, C, D, 11); - decrypt_round(B, C, D, A, 10); - decrypt_round(C, D, A, B, 9); - decrypt_round(D, A, B, C, 8); - - decrypt_round(A, D, C, B, 7); - decrypt_round(B, A, D, C, 6); - decrypt_round(C, B, A, D, 5); - decrypt_round(D, C, B, A, 4); - decrypt_round(A, D, C, B, 3); - decrypt_round(B, A, D, C, 2); - decrypt_round(C, B, A, D, 1); - decrypt_round(D, C, B, A, 0); - - reverse_mix(A, B, C, D); - - A -= EK[3]; B -= EK[2]; C -= EK[1]; D -= EK[0]; - - store_le(out, D, C, B, A); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit A = load_le(in, 3) + EK[39]; + u32bit B = load_le(in, 2) + EK[38]; + u32bit C = load_le(in, 1) + EK[37]; + u32bit D = load_le(in, 0) + EK[36]; + + forward_mix(A, B, C, D); + + decrypt_round(A, B, C, D, 15); + decrypt_round(B, C, D, A, 14); + decrypt_round(C, D, A, B, 13); + decrypt_round(D, A, B, C, 12); + decrypt_round(A, B, C, D, 11); + decrypt_round(B, C, D, A, 10); + decrypt_round(C, D, A, B, 9); + decrypt_round(D, A, B, C, 8); + + decrypt_round(A, D, C, B, 7); + decrypt_round(B, A, D, C, 6); + decrypt_round(C, B, A, D, 5); + decrypt_round(D, C, B, A, 4); + decrypt_round(A, D, C, B, 3); + decrypt_round(B, A, D, C, 2); + decrypt_round(C, B, A, D, 1); + decrypt_round(D, C, B, A, 0); + + reverse_mix(A, B, C, D); + + A -= EK[3]; B -= EK[2]; C -= EK[1]; D -= EK[0]; + + store_le(out, D, C, B, A); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h index ca49695af..b3d74b179 100644 --- a/src/block/mars/mars.h +++ b/src/block/mars/mars.h @@ -20,8 +20,8 @@ class BOTAN_DLL MARS : public BlockCipher BlockCipher* clone() const { return new MARS; } MARS() : BlockCipher(16, 16, 32, 4) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); void encrypt_round(u32bit&, u32bit&, u32bit&, u32bit&, u32bit) const; diff --git a/src/block/misty1/misty1.cpp b/src/block/misty1/misty1.cpp index a35ff584d..8a92824cc 100644 --- a/src/block/misty1/misty1.cpp +++ b/src/block/misty1/misty1.cpp @@ -1,6 +1,6 @@ /* * MISTY1 -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -102,89 +102,101 @@ u16bit FI(u16bit input, u16bit key7, u16bit key9) /* * MISTY1 Encryption */ -void MISTY1::enc(const byte in[], byte out[]) const +void MISTY1::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit B0 = load_be(in, 0); - u16bit B1 = load_be(in, 1); - u16bit B2 = load_be(in, 2); - u16bit B3 = load_be(in, 3); - - for(u32bit j = 0; j != 12; j += 3) + for(u32bit i = 0; i != blocks; ++i) { - const u16bit* RK = EK + 8 * j; + u16bit B0 = load_be(in, 0); + u16bit B1 = load_be(in, 1); + u16bit B2 = load_be(in, 2); + u16bit B3 = load_be(in, 3); - B1 ^= B0 & RK[0]; - B0 ^= B1 | RK[1]; - B3 ^= B2 & RK[2]; - B2 ^= B3 | RK[3]; + for(u32bit j = 0; j != 12; j += 3) + { + const u16bit* RK = EK + 8 * j; - u32bit T0, T1; + B1 ^= B0 & RK[0]; + B0 ^= B1 | RK[1]; + B3 ^= B2 & RK[2]; + B2 ^= B3 | RK[3]; - T0 = FI(B0 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B1; - T1 = FI(B1 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0; - T0 = FI(T0 ^ RK[10], RK[11], RK[12]) ^ T1; + u32bit T0, T1; - B2 ^= T1 ^ RK[13]; - B3 ^= T0; + T0 = FI(B0 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B1; + T1 = FI(B1 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0; + T0 = FI(T0 ^ RK[10], RK[11], RK[12]) ^ T1; - T0 = FI(B2 ^ RK[14], RK[15], RK[16]) ^ B3; - T1 = FI(B3 ^ RK[17], RK[18], RK[19]) ^ T0; - T0 = FI(T0 ^ RK[20], RK[21], RK[22]) ^ T1; + B2 ^= T1 ^ RK[13]; + B3 ^= T0; - B0 ^= T1 ^ RK[23]; - B1 ^= T0; - } + T0 = FI(B2 ^ RK[14], RK[15], RK[16]) ^ B3; + T1 = FI(B3 ^ RK[17], RK[18], RK[19]) ^ T0; + T0 = FI(T0 ^ RK[20], RK[21], RK[22]) ^ T1; + + B0 ^= T1 ^ RK[23]; + B1 ^= T0; + } - B1 ^= B0 & EK[96]; - B0 ^= B1 | EK[97]; - B3 ^= B2 & EK[98]; - B2 ^= B3 | EK[99]; + B1 ^= B0 & EK[96]; + B0 ^= B1 | EK[97]; + B3 ^= B2 & EK[98]; + B2 ^= B3 | EK[99]; - store_be(out, B2, B3, B0, B1); + store_be(out, B2, B3, B0, B1); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * MISTY1 Decryption */ -void MISTY1::dec(const byte in[], byte out[]) const +void MISTY1::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit B0 = load_be(in, 2); - u16bit B1 = load_be(in, 3); - u16bit B2 = load_be(in, 0); - u16bit B3 = load_be(in, 1); - - for(u32bit j = 0; j != 12; j += 3) + for(u32bit i = 0; i != blocks; ++i) { - const u16bit* RK = DK + 8 * j; + u16bit B0 = load_be(in, 2); + u16bit B1 = load_be(in, 3); + u16bit B2 = load_be(in, 0); + u16bit B3 = load_be(in, 1); - B2 ^= B3 | RK[0]; - B3 ^= B2 & RK[1]; - B0 ^= B1 | RK[2]; - B1 ^= B0 & RK[3]; + for(u32bit j = 0; j != 12; j += 3) + { + const u16bit* RK = DK + 8 * j; - u32bit T0, T1; + B2 ^= B3 | RK[0]; + B3 ^= B2 & RK[1]; + B0 ^= B1 | RK[2]; + B1 ^= B0 & RK[3]; - T0 = FI(B2 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B3; - T1 = FI(B3 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0; - T0 = FI(T0 ^ RK[10], RK[11], RK[12]) ^ T1; + u32bit T0, T1; - B0 ^= T1 ^ RK[13]; - B1 ^= T0; + T0 = FI(B2 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B3; + T1 = FI(B3 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0; + T0 = FI(T0 ^ RK[10], RK[11], RK[12]) ^ T1; - T0 = FI(B0 ^ RK[14], RK[15], RK[16]) ^ B1; - T1 = FI(B1 ^ RK[17], RK[18], RK[19]) ^ T0; - T0 = FI(T0 ^ RK[20], RK[21], RK[22]) ^ T1; + B0 ^= T1 ^ RK[13]; + B1 ^= T0; - B2 ^= T1 ^ RK[23]; - B3 ^= T0; - } + T0 = FI(B0 ^ RK[14], RK[15], RK[16]) ^ B1; + T1 = FI(B1 ^ RK[17], RK[18], RK[19]) ^ T0; + T0 = FI(T0 ^ RK[20], RK[21], RK[22]) ^ T1; + + B2 ^= T1 ^ RK[23]; + B3 ^= T0; + } - B2 ^= B3 | DK[96]; - B3 ^= B2 & DK[97]; - B0 ^= B1 | DK[98]; - B1 ^= B0 & DK[99]; + B2 ^= B3 | DK[96]; + B3 ^= B2 & DK[97]; + B0 ^= B1 | DK[98]; + B1 ^= B0 & DK[99]; - store_be(out, B0, B1, B2, B3); + store_be(out, B0, B1, B2, B3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/misty1/misty1.h b/src/block/misty1/misty1.h index 62d4f856f..14b7c8e45 100644 --- a/src/block/misty1/misty1.h +++ b/src/block/misty1/misty1.h @@ -23,8 +23,8 @@ class BOTAN_DLL MISTY1 : public BlockCipher BlockCipher* clone() const { return new MISTY1; } MISTY1(u32bit = 8); private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK, DK; diff --git a/src/block/noekeon/noekeon.cpp b/src/block/noekeon/noekeon.cpp index 90eb9ad2b..1b327aa47 100644 --- a/src/block/noekeon/noekeon.cpp +++ b/src/block/noekeon/noekeon.cpp @@ -84,65 +84,77 @@ const byte Noekeon::RC[] = { /* * Noekeon Encryption */ -void Noekeon::enc(const byte in[], byte out[]) const +void Noekeon::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A0 = load_be(in, 0); - u32bit A1 = load_be(in, 1); - u32bit A2 = load_be(in, 2); - u32bit A3 = load_be(in, 3); - - for(u32bit j = 0; j != 16; ++j) + for(u32bit i = 0; i != blocks; ++i) { - A0 ^= RC[j]; - theta(A0, A1, A2, A3, EK); + u32bit A0 = load_be(in, 0); + u32bit A1 = load_be(in, 1); + u32bit A2 = load_be(in, 2); + u32bit A3 = load_be(in, 3); - A1 = rotate_left(A1, 1); - A2 = rotate_left(A2, 5); - A3 = rotate_left(A3, 2); + for(u32bit j = 0; j != 16; ++j) + { + A0 ^= RC[j]; + theta(A0, A1, A2, A3, EK); - gamma(A0, A1, A2, A3); + A1 = rotate_left(A1, 1); + A2 = rotate_left(A2, 5); + A3 = rotate_left(A3, 2); - A1 = rotate_right(A1, 1); - A2 = rotate_right(A2, 5); - A3 = rotate_right(A3, 2); - } + gamma(A0, A1, A2, A3); - A0 ^= RC[16]; - theta(A0, A1, A2, A3, EK); + A1 = rotate_right(A1, 1); + A2 = rotate_right(A2, 5); + A3 = rotate_right(A3, 2); + } + + A0 ^= RC[16]; + theta(A0, A1, A2, A3, EK); + + store_be(out, A0, A1, A2, A3); - store_be(out, A0, A1, A2, A3); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Noekeon Encryption */ -void Noekeon::dec(const byte in[], byte out[]) const +void Noekeon::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A0 = load_be(in, 0); - u32bit A1 = load_be(in, 1); - u32bit A2 = load_be(in, 2); - u32bit A3 = load_be(in, 3); - - for(u32bit j = 16; j != 0; --j) + for(u32bit i = 0; i != blocks; ++i) { - theta(A0, A1, A2, A3, DK); - A0 ^= RC[j]; + u32bit A0 = load_be(in, 0); + u32bit A1 = load_be(in, 1); + u32bit A2 = load_be(in, 2); + u32bit A3 = load_be(in, 3); - A1 = rotate_left(A1, 1); - A2 = rotate_left(A2, 5); - A3 = rotate_left(A3, 2); + for(u32bit j = 16; j != 0; --j) + { + theta(A0, A1, A2, A3, DK); + A0 ^= RC[j]; - gamma(A0, A1, A2, A3); + A1 = rotate_left(A1, 1); + A2 = rotate_left(A2, 5); + A3 = rotate_left(A3, 2); - A1 = rotate_right(A1, 1); - A2 = rotate_right(A2, 5); - A3 = rotate_right(A3, 2); - } + gamma(A0, A1, A2, A3); - theta(A0, A1, A2, A3, DK); - A0 ^= RC[0]; + A1 = rotate_right(A1, 1); + A2 = rotate_right(A2, 5); + A3 = rotate_right(A3, 2); + } - store_be(out, A0, A1, A2, A3); + theta(A0, A1, A2, A3, DK); + A0 ^= RC[0]; + + store_be(out, A0, A1, A2, A3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/noekeon/noekeon.h b/src/block/noekeon/noekeon.h index 893892446..b4f3980d7 100644 --- a/src/block/noekeon/noekeon.h +++ b/src/block/noekeon/noekeon.h @@ -23,8 +23,8 @@ class BOTAN_DLL Noekeon : public BlockCipher BlockCipher* clone() const { return new Noekeon; } Noekeon() : BlockCipher(16, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static const byte RC[17]; diff --git a/src/block/rc2/rc2.cpp b/src/block/rc2/rc2.cpp index 5827bdb68..b5e4a7d50 100644 --- a/src/block/rc2/rc2.cpp +++ b/src/block/rc2/rc2.cpp @@ -14,73 +14,85 @@ namespace Botan { /* * RC2 Encryption */ -void RC2::enc(const byte in[], byte out[]) const +void RC2::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit R0 = load_le(in, 0); - u16bit R1 = load_le(in, 1); - u16bit R2 = load_le(in, 2); - u16bit R3 = load_le(in, 3); - - for(u32bit j = 0; j != 16; ++j) + for(u32bit i = 0; i != blocks; ++i) { - R0 += (R1 & ~R3) + (R2 & R3) + K[4*j]; - R0 = rotate_left(R0, 1); + u16bit R0 = load_le(in, 0); + u16bit R1 = load_le(in, 1); + u16bit R2 = load_le(in, 2); + u16bit R3 = load_le(in, 3); + + for(u32bit j = 0; j != 16; ++j) + { + R0 += (R1 & ~R3) + (R2 & R3) + K[4*j]; + R0 = rotate_left(R0, 1); - R1 += (R2 & ~R0) + (R3 & R0) + K[4*j + 1]; - R1 = rotate_left(R1, 2); + R1 += (R2 & ~R0) + (R3 & R0) + K[4*j + 1]; + R1 = rotate_left(R1, 2); - R2 += (R3 & ~R1) + (R0 & R1) + K[4*j + 2]; - R2 = rotate_left(R2, 3); + R2 += (R3 & ~R1) + (R0 & R1) + K[4*j + 2]; + R2 = rotate_left(R2, 3); - R3 += (R0 & ~R2) + (R1 & R2) + K[4*j + 3]; - R3 = rotate_left(R3, 5); + R3 += (R0 & ~R2) + (R1 & R2) + K[4*j + 3]; + R3 = rotate_left(R3, 5); - if(j == 4 || j == 10) - { - R0 += K[R3 % 64]; - R1 += K[R0 % 64]; - R2 += K[R1 % 64]; - R3 += K[R2 % 64]; + if(j == 4 || j == 10) + { + R0 += K[R3 % 64]; + R1 += K[R0 % 64]; + R2 += K[R1 % 64]; + R3 += K[R2 % 64]; + } } - } - store_le(out, R0, R1, R2, R3); + store_le(out, R0, R1, R2, R3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * RC2 Decryption */ -void RC2::dec(const byte in[], byte out[]) const +void RC2::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit R0 = load_le(in, 0); - u16bit R1 = load_le(in, 1); - u16bit R2 = load_le(in, 2); - u16bit R3 = load_le(in, 3); - - for(u32bit j = 0; j != 16; ++j) + for(u32bit i = 0; i != blocks; ++i) { - R3 = rotate_right(R3, 5); - R3 -= (R0 & ~R2) + (R1 & R2) + K[63 - (4*j + 0)]; + u16bit R0 = load_le(in, 0); + u16bit R1 = load_le(in, 1); + u16bit R2 = load_le(in, 2); + u16bit R3 = load_le(in, 3); + + for(u32bit j = 0; j != 16; ++j) + { + R3 = rotate_right(R3, 5); + R3 -= (R0 & ~R2) + (R1 & R2) + K[63 - (4*j + 0)]; - R2 = rotate_right(R2, 3); - R2 -= (R3 & ~R1) + (R0 & R1) + K[63 - (4*j + 1)]; + R2 = rotate_right(R2, 3); + R2 -= (R3 & ~R1) + (R0 & R1) + K[63 - (4*j + 1)]; - R1 = rotate_right(R1, 2); - R1 -= (R2 & ~R0) + (R3 & R0) + K[63 - (4*j + 2)]; + R1 = rotate_right(R1, 2); + R1 -= (R2 & ~R0) + (R3 & R0) + K[63 - (4*j + 2)]; - R0 = rotate_right(R0, 1); - R0 -= (R1 & ~R3) + (R2 & R3) + K[63 - (4*j + 3)]; + R0 = rotate_right(R0, 1); + R0 -= (R1 & ~R3) + (R2 & R3) + K[63 - (4*j + 3)]; - if(j == 4 || j == 10) - { - R3 -= K[R2 % 64]; - R2 -= K[R1 % 64]; - R1 -= K[R0 % 64]; - R0 -= K[R3 % 64]; + if(j == 4 || j == 10) + { + R3 -= K[R2 % 64]; + R2 -= K[R1 % 64]; + R1 -= K[R0 % 64]; + R0 -= K[R3 % 64]; + } } - } - store_le(out, R0, R1, R2, R3); + store_le(out, R0, R1, R2, R3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/rc2/rc2.h b/src/block/rc2/rc2.h index cb6f58f04..0d94d69a2 100644 --- a/src/block/rc2/rc2.h +++ b/src/block/rc2/rc2.h @@ -25,8 +25,8 @@ class BOTAN_DLL RC2 : public BlockCipher BlockCipher* clone() const { return new RC2; } RC2() : BlockCipher(8, 1, 32) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer K; diff --git a/src/block/rc5/rc5.cpp b/src/block/rc5/rc5.cpp index 5d83d5a4e..4bfa27ea0 100644 --- a/src/block/rc5/rc5.cpp +++ b/src/block/rc5/rc5.cpp @@ -16,47 +16,59 @@ namespace Botan { /* * RC5 Encryption */ -void RC5::enc(const byte in[], byte out[]) const +void RC5::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0), B = load_le(in, 1); - - A += S[0]; B += S[1]; - for(u32bit j = 0; j != ROUNDS; j += 4) + for(u32bit i = 0; i != blocks; ++i) { - A = rotate_left(A ^ B, B % 32) + S[2*j+2]; - B = rotate_left(B ^ A, A % 32) + S[2*j+3]; - A = rotate_left(A ^ B, B % 32) + S[2*j+4]; - B = rotate_left(B ^ A, A % 32) + S[2*j+5]; - A = rotate_left(A ^ B, B % 32) + S[2*j+6]; - B = rotate_left(B ^ A, A % 32) + S[2*j+7]; - A = rotate_left(A ^ B, B % 32) + S[2*j+8]; - B = rotate_left(B ^ A, A % 32) + S[2*j+9]; - } + u32bit A = load_le(in, 0), B = load_le(in, 1); + + A += S[0]; B += S[1]; + for(u32bit j = 0; j != ROUNDS; j += 4) + { + A = rotate_left(A ^ B, B % 32) + S[2*j+2]; + B = rotate_left(B ^ A, A % 32) + S[2*j+3]; + A = rotate_left(A ^ B, B % 32) + S[2*j+4]; + B = rotate_left(B ^ A, A % 32) + S[2*j+5]; + A = rotate_left(A ^ B, B % 32) + S[2*j+6]; + B = rotate_left(B ^ A, A % 32) + S[2*j+7]; + A = rotate_left(A ^ B, B % 32) + S[2*j+8]; + B = rotate_left(B ^ A, A % 32) + S[2*j+9]; + } - store_le(out, A, B); + store_le(out, A, B); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * RC5 Decryption */ -void RC5::dec(const byte in[], byte out[]) const +void RC5::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0), B = load_le(in, 1); - - for(u32bit j = ROUNDS; j != 0; j -= 4) + for(u32bit i = 0; i != blocks; ++i) { - B = rotate_right(B - S[2*j+1], A % 32) ^ A; - A = rotate_right(A - S[2*j ], B % 32) ^ B; - B = rotate_right(B - S[2*j-1], A % 32) ^ A; - A = rotate_right(A - S[2*j-2], B % 32) ^ B; - B = rotate_right(B - S[2*j-3], A % 32) ^ A; - A = rotate_right(A - S[2*j-4], B % 32) ^ B; - B = rotate_right(B - S[2*j-5], A % 32) ^ A; - A = rotate_right(A - S[2*j-6], B % 32) ^ B; - } - B -= S[1]; A -= S[0]; + u32bit A = load_le(in, 0), B = load_le(in, 1); + + for(u32bit j = ROUNDS; j != 0; j -= 4) + { + B = rotate_right(B - S[2*j+1], A % 32) ^ A; + A = rotate_right(A - S[2*j ], B % 32) ^ B; + B = rotate_right(B - S[2*j-1], A % 32) ^ A; + A = rotate_right(A - S[2*j-2], B % 32) ^ B; + B = rotate_right(B - S[2*j-3], A % 32) ^ A; + A = rotate_right(A - S[2*j-4], B % 32) ^ B; + B = rotate_right(B - S[2*j-5], A % 32) ^ A; + A = rotate_right(A - S[2*j-6], B % 32) ^ B; + } + B -= S[1]; A -= S[0]; - store_le(out, A, B); + store_le(out, A, B); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/rc5/rc5.h b/src/block/rc5/rc5.h index 083224720..1816994dc 100644 --- a/src/block/rc5/rc5.h +++ b/src/block/rc5/rc5.h @@ -23,8 +23,8 @@ class BOTAN_DLL RC5 : public BlockCipher BlockCipher* clone() const { return new RC5(ROUNDS); } RC5(u32bit); private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureVector S; const u32bit ROUNDS; diff --git a/src/block/rc6/rc6.cpp b/src/block/rc6/rc6.cpp index 3b30ea93a..8bda62259 100644 --- a/src/block/rc6/rc6.cpp +++ b/src/block/rc6/rc6.cpp @@ -15,85 +15,97 @@ namespace Botan { /* * RC6 Encryption */ -void RC6::enc(const byte in[], byte out[]) const +void RC6::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0); - u32bit B = load_le(in, 1); - u32bit C = load_le(in, 2); - u32bit D = load_le(in, 3); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit A = load_le(in, 0); + u32bit B = load_le(in, 1); + u32bit C = load_le(in, 2); + u32bit D = load_le(in, 3); - B += S[0]; D += S[1]; + B += S[0]; D += S[1]; - for(u32bit j = 0; j != 20; j += 4) - { - u32bit T1, T2; - - T1 = rotate_left(B*(2*B+1), 5); - T2 = rotate_left(D*(2*D+1), 5); - A = rotate_left(A ^ T1, T2 % 32) + S[2*j+2]; - C = rotate_left(C ^ T2, T1 % 32) + S[2*j+3]; - - T1 = rotate_left(C*(2*C+1), 5); - T2 = rotate_left(A*(2*A+1), 5); - B = rotate_left(B ^ T1, T2 % 32) + S[2*j+4]; - D = rotate_left(D ^ T2, T1 % 32) + S[2*j+5]; - - T1 = rotate_left(D*(2*D+1), 5); - T2 = rotate_left(B*(2*B+1), 5); - C = rotate_left(C ^ T1, T2 % 32) + S[2*j+6]; - A = rotate_left(A ^ T2, T1 % 32) + S[2*j+7]; - - T1 = rotate_left(A*(2*A+1), 5); - T2 = rotate_left(C*(2*C+1), 5); - D = rotate_left(D ^ T1, T2 % 32) + S[2*j+8]; - B = rotate_left(B ^ T2, T1 % 32) + S[2*j+9]; - } + for(u32bit j = 0; j != 20; j += 4) + { + u32bit T1, T2; + + T1 = rotate_left(B*(2*B+1), 5); + T2 = rotate_left(D*(2*D+1), 5); + A = rotate_left(A ^ T1, T2 % 32) + S[2*j+2]; + C = rotate_left(C ^ T2, T1 % 32) + S[2*j+3]; + + T1 = rotate_left(C*(2*C+1), 5); + T2 = rotate_left(A*(2*A+1), 5); + B = rotate_left(B ^ T1, T2 % 32) + S[2*j+4]; + D = rotate_left(D ^ T2, T1 % 32) + S[2*j+5]; - A += S[42]; C += S[43]; + T1 = rotate_left(D*(2*D+1), 5); + T2 = rotate_left(B*(2*B+1), 5); + C = rotate_left(C ^ T1, T2 % 32) + S[2*j+6]; + A = rotate_left(A ^ T2, T1 % 32) + S[2*j+7]; - store_le(out, A, B, C, D); + T1 = rotate_left(A*(2*A+1), 5); + T2 = rotate_left(C*(2*C+1), 5); + D = rotate_left(D ^ T1, T2 % 32) + S[2*j+8]; + B = rotate_left(B ^ T2, T1 % 32) + S[2*j+9]; + } + + A += S[42]; C += S[43]; + + store_le(out, A, B, C, D); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * RC6 Decryption */ -void RC6::dec(const byte in[], byte out[]) const +void RC6::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0); - u32bit B = load_le(in, 1); - u32bit C = load_le(in, 2); - u32bit D = load_le(in, 3); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit A = load_le(in, 0); + u32bit B = load_le(in, 1); + u32bit C = load_le(in, 2); + u32bit D = load_le(in, 3); - C -= S[43]; A -= S[42]; + C -= S[43]; A -= S[42]; - for(u32bit j = 0; j != 20; j += 4) - { - u32bit T1, T2; - - T1 = rotate_left(A*(2*A+1), 5); - T2 = rotate_left(C*(2*C+1), 5); - B = rotate_right(B - S[41 - 2*j], T1 % 32) ^ T2; - D = rotate_right(D - S[40 - 2*j], T2 % 32) ^ T1; - - T1 = rotate_left(D*(2*D+1), 5); - T2 = rotate_left(B*(2*B+1), 5); - A = rotate_right(A - S[39 - 2*j], T1 % 32) ^ T2; - C = rotate_right(C - S[38 - 2*j], T2 % 32) ^ T1; - - T1 = rotate_left(C*(2*C+1), 5); - T2 = rotate_left(A*(2*A+1), 5); - D = rotate_right(D - S[37 - 2*j], T1 % 32) ^ T2; - B = rotate_right(B - S[36 - 2*j], T2 % 32) ^ T1; - - T1 = rotate_left(B*(2*B+1), 5); - T2 = rotate_left(D*(2*D+1), 5); - C = rotate_right(C - S[35 - 2*j], T1 % 32) ^ T2; - A = rotate_right(A - S[34 - 2*j], T2 % 32) ^ T1; - } + for(u32bit j = 0; j != 20; j += 4) + { + u32bit T1, T2; + + T1 = rotate_left(A*(2*A+1), 5); + T2 = rotate_left(C*(2*C+1), 5); + B = rotate_right(B - S[41 - 2*j], T1 % 32) ^ T2; + D = rotate_right(D - S[40 - 2*j], T2 % 32) ^ T1; + + T1 = rotate_left(D*(2*D+1), 5); + T2 = rotate_left(B*(2*B+1), 5); + A = rotate_right(A - S[39 - 2*j], T1 % 32) ^ T2; + C = rotate_right(C - S[38 - 2*j], T2 % 32) ^ T1; - D -= S[1]; B -= S[0]; + T1 = rotate_left(C*(2*C+1), 5); + T2 = rotate_left(A*(2*A+1), 5); + D = rotate_right(D - S[37 - 2*j], T1 % 32) ^ T2; + B = rotate_right(B - S[36 - 2*j], T2 % 32) ^ T1; - store_le(out, A, B, C, D); + T1 = rotate_left(B*(2*B+1), 5); + T2 = rotate_left(D*(2*D+1), 5); + C = rotate_right(C - S[35 - 2*j], T1 % 32) ^ T2; + A = rotate_right(A - S[34 - 2*j], T2 % 32) ^ T1; + } + + D -= S[1]; B -= S[0]; + + store_le(out, A, B, C, D); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/rc6/rc6.h b/src/block/rc6/rc6.h index cb2800be7..f634ebcd9 100644 --- a/src/block/rc6/rc6.h +++ b/src/block/rc6/rc6.h @@ -23,8 +23,8 @@ class BOTAN_DLL RC6 : public BlockCipher BlockCipher* clone() const { return new RC6; } RC6() : BlockCipher(16, 1, 32) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer S; diff --git a/src/block/safer/safer_sk.cpp b/src/block/safer/safer_sk.cpp index f72c4773b..eb5c22fc9 100644 --- a/src/block/safer/safer_sk.cpp +++ b/src/block/safer/safer_sk.cpp @@ -1,6 +1,6 @@ /* * SAFER-SK -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -15,54 +15,75 @@ namespace Botan { /* * SAFER-SK Encryption */ -void SAFER_SK::enc(const byte in[], byte out[]) const +void SAFER_SK::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - byte A = in[0], B = in[1], C = in[2], D = in[3], - E = in[4], F = in[5], G = in[6], H = in[7], X, Y; - for(u32bit j = 0; j != 16*ROUNDS; j += 16) + for(u32bit i = 0; i != blocks; ++i) { - A = EXP[A ^ EK[j ]]; B = LOG[B + EK[j+1]]; - C = LOG[C + EK[j+2]]; D = EXP[D ^ EK[j+3]]; - E = EXP[E ^ EK[j+4]]; F = LOG[F + EK[j+5]]; - G = LOG[G + EK[j+6]]; H = EXP[H ^ EK[j+7]]; - A += EK[j+ 8]; B ^= EK[j+ 9]; C ^= EK[j+10]; D += EK[j+11]; - E += EK[j+12]; F ^= EK[j+13]; G ^= EK[j+14]; H += EK[j+15]; - B += A; D += C; F += E; H += G; A += B; C += D; E += F; G += H; - C += A; G += E; D += B; H += F; A += C; E += G; B += D; F += H; - H += D; Y = D + H; D = B + F; X = B + D; B = A + E; - A += B; F = C + G; E = C + F; C = X; G = Y; + byte A = in[0], B = in[1], C = in[2], D = in[3], + E = in[4], F = in[5], G = in[6], H = in[7], X, Y; + + for(u32bit j = 0; j != 16*ROUNDS; j += 16) + { + A = EXP[A ^ EK[j ]]; B = LOG[B + EK[j+1]]; + C = LOG[C + EK[j+2]]; D = EXP[D ^ EK[j+3]]; + E = EXP[E ^ EK[j+4]]; F = LOG[F + EK[j+5]]; + G = LOG[G + EK[j+6]]; H = EXP[H ^ EK[j+7]]; + + A += EK[j+ 8]; B ^= EK[j+ 9]; C ^= EK[j+10]; D += EK[j+11]; + E += EK[j+12]; F ^= EK[j+13]; G ^= EK[j+14]; H += EK[j+15]; + + B += A; D += C; F += E; H += G; A += B; C += D; E += F; G += H; + C += A; G += E; D += B; H += F; A += C; E += G; B += D; F += H; + H += D; Y = D + H; D = B + F; X = B + D; B = A + E; + A += B; F = C + G; E = C + F; C = X; G = Y; + } + + out[0] = A ^ EK[16*ROUNDS+0]; out[1] = B + EK[16*ROUNDS+1]; + out[2] = C + EK[16*ROUNDS+2]; out[3] = D ^ EK[16*ROUNDS+3]; + out[4] = E ^ EK[16*ROUNDS+4]; out[5] = F + EK[16*ROUNDS+5]; + out[6] = G + EK[16*ROUNDS+6]; out[7] = H ^ EK[16*ROUNDS+7]; + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - out[0] = A ^ EK[16*ROUNDS+0]; out[1] = B + EK[16*ROUNDS+1]; - out[2] = C + EK[16*ROUNDS+2]; out[3] = D ^ EK[16*ROUNDS+3]; - out[4] = E ^ EK[16*ROUNDS+4]; out[5] = F + EK[16*ROUNDS+5]; - out[6] = G + EK[16*ROUNDS+6]; out[7] = H ^ EK[16*ROUNDS+7]; } /* * SAFER-SK Decryption */ -void SAFER_SK::dec(const byte in[], byte out[]) const +void SAFER_SK::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - byte A = in[0], B = in[1], C = in[2], D = in[3], - E = in[4], F = in[5], G = in[6], H = in[7]; - A ^= EK[16*ROUNDS+0]; B -= EK[16*ROUNDS+1]; C -= EK[16*ROUNDS+2]; - D ^= EK[16*ROUNDS+3]; E ^= EK[16*ROUNDS+4]; F -= EK[16*ROUNDS+5]; - G -= EK[16*ROUNDS+6]; H ^= EK[16*ROUNDS+7]; - for(s32bit j = 16*(ROUNDS-1); j >= 0; j -= 16) + for(u32bit i = 0; i != blocks; ++i) { - byte T = E; E = B; B = C; C = T; T = F; F = D; D = G; G = T; - A -= E; B -= F; C -= G; D -= H; E -= A; F -= B; G -= C; H -= D; - A -= C; E -= G; B -= D; F -= H; C -= A; G -= E; D -= B; H -= F; - A -= B; C -= D; E -= F; G -= H; B -= A; D -= C; F -= E; H -= G; - A = LOG[A - EK[j+8 ] + 256]; B = EXP[B ^ EK[j+9 ]]; - C = EXP[C ^ EK[j+10]]; D = LOG[D - EK[j+11] + 256]; - E = LOG[E - EK[j+12] + 256]; F = EXP[F ^ EK[j+13]]; - G = EXP[G ^ EK[j+14]]; H = LOG[H - EK[j+15] + 256]; - A ^= EK[j+0]; B -= EK[j+1]; C -= EK[j+2]; D ^= EK[j+3]; - E ^= EK[j+4]; F -= EK[j+5]; G -= EK[j+6]; H ^= EK[j+7]; + byte A = in[0], B = in[1], C = in[2], D = in[3], + E = in[4], F = in[5], G = in[6], H = in[7]; + + A ^= EK[16*ROUNDS+0]; B -= EK[16*ROUNDS+1]; C -= EK[16*ROUNDS+2]; + D ^= EK[16*ROUNDS+3]; E ^= EK[16*ROUNDS+4]; F -= EK[16*ROUNDS+5]; + G -= EK[16*ROUNDS+6]; H ^= EK[16*ROUNDS+7]; + + for(s32bit j = 16*(ROUNDS-1); j >= 0; j -= 16) + { + byte T = E; E = B; B = C; C = T; T = F; F = D; D = G; G = T; + A -= E; B -= F; C -= G; D -= H; E -= A; F -= B; G -= C; H -= D; + A -= C; E -= G; B -= D; F -= H; C -= A; G -= E; D -= B; H -= F; + A -= B; C -= D; E -= F; G -= H; B -= A; D -= C; F -= E; H -= G; + + A = LOG[A - EK[j+8 ] + 256]; B = EXP[B ^ EK[j+9 ]]; + C = EXP[C ^ EK[j+10]]; D = LOG[D - EK[j+11] + 256]; + E = LOG[E - EK[j+12] + 256]; F = EXP[F ^ EK[j+13]]; + G = EXP[G ^ EK[j+14]]; H = LOG[H - EK[j+15] + 256]; + + A ^= EK[j+0]; B -= EK[j+1]; C -= EK[j+2]; D ^= EK[j+3]; + E ^= EK[j+4]; F -= EK[j+5]; G -= EK[j+6]; H ^= EK[j+7]; + } + + out[0] = A; out[1] = B; out[2] = C; out[3] = D; + out[4] = E; out[5] = F; out[6] = G; out[7] = H; + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - out[0] = A; out[1] = B; out[2] = C; out[3] = D; - out[4] = E; out[5] = F; out[6] = G; out[7] = H; } /* diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h index e52c5837c..ae3d4f9a8 100644 --- a/src/block/safer/safer_sk.h +++ b/src/block/safer/safer_sk.h @@ -23,8 +23,8 @@ class BOTAN_DLL SAFER_SK : public BlockCipher BlockCipher* clone() const; SAFER_SK(u32bit); private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static const byte EXP[256]; diff --git a/src/block/seed/seed.cpp b/src/block/seed/seed.cpp index b06a7cd77..378be16e4 100644 --- a/src/block/seed/seed.cpp +++ b/src/block/seed/seed.cpp @@ -22,69 +22,81 @@ u32bit SEED::G_FUNC::operator()(u32bit X) const /* * SEED Encryption */ -void SEED::enc(const byte in[], byte out[]) const +void SEED::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit B0 = load_be(in, 0); - u32bit B1 = load_be(in, 1); - u32bit B2 = load_be(in, 2); - u32bit B3 = load_be(in, 3); - - G_FUNC G; - - for(u32bit j = 0; j != 16; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - u32bit T0, T1; - - T0 = B2 ^ K[2*j]; - T1 = G(B2 ^ B3 ^ K[2*j+1]); - T0 = G(T1 + T0); - T1 = G(T1 + T0); - B1 ^= T1; - B0 ^= T0 + T1; - - T0 = B0 ^ K[2*j+2]; - T1 = G(B0 ^ B1 ^ K[2*j+3]); - T0 = G(T1 + T0); - T1 = G(T1 + T0); - B3 ^= T1; - B2 ^= T0 + T1; + u32bit B0 = load_be(in, 0); + u32bit B1 = load_be(in, 1); + u32bit B2 = load_be(in, 2); + u32bit B3 = load_be(in, 3); + + G_FUNC G; + + for(u32bit j = 0; j != 16; j += 2) + { + u32bit T0, T1; + + T0 = B2 ^ K[2*j]; + T1 = G(B2 ^ B3 ^ K[2*j+1]); + T0 = G(T1 + T0); + T1 = G(T1 + T0); + B1 ^= T1; + B0 ^= T0 + T1; + + T0 = B0 ^ K[2*j+2]; + T1 = G(B0 ^ B1 ^ K[2*j+3]); + T0 = G(T1 + T0); + T1 = G(T1 + T0); + B3 ^= T1; + B2 ^= T0 + T1; + } + + store_be(out, B2, B3, B0, B1); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - - store_be(out, B2, B3, B0, B1); } /* * SEED Decryption */ -void SEED::dec(const byte in[], byte out[]) const +void SEED::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit B0 = load_be(in, 0); - u32bit B1 = load_be(in, 1); - u32bit B2 = load_be(in, 2); - u32bit B3 = load_be(in, 3); - - G_FUNC G; - - for(u32bit j = 0; j != 16; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - u32bit T0, T1; - - T0 = B2 ^ K[30-2*j]; - T1 = G(B2 ^ B3 ^ K[31-2*j]); - T0 = G(T1 + T0); - T1 = G(T1 + T0); - B1 ^= T1; - B0 ^= T0 + T1; - - T0 = B0 ^ K[28-2*j]; - T1 = G(B0 ^ B1 ^ K[29-2*j]); - T0 = G(T1 + T0); - T1 = G(T1 + T0); - B3 ^= T1; - B2 ^= T0 + T1; + u32bit B0 = load_be(in, 0); + u32bit B1 = load_be(in, 1); + u32bit B2 = load_be(in, 2); + u32bit B3 = load_be(in, 3); + + G_FUNC G; + + for(u32bit j = 0; j != 16; j += 2) + { + u32bit T0, T1; + + T0 = B2 ^ K[30-2*j]; + T1 = G(B2 ^ B3 ^ K[31-2*j]); + T0 = G(T1 + T0); + T1 = G(T1 + T0); + B1 ^= T1; + B0 ^= T0 + T1; + + T0 = B0 ^ K[28-2*j]; + T1 = G(B0 ^ B1 ^ K[29-2*j]); + T0 = G(T1 + T0); + T1 = G(T1 + T0); + B3 ^= T1; + B2 ^= T0 + T1; + } + + store_be(out, B2, B3, B0, B1); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - - store_be(out, B2, B3, B0, B1); } /* diff --git a/src/block/seed/seed.h b/src/block/seed/seed.h index 54c25d580..0c9c2c8af 100644 --- a/src/block/seed/seed.h +++ b/src/block/seed/seed.h @@ -23,8 +23,8 @@ class BOTAN_DLL SEED : public BlockCipher BlockCipher* clone() const { return new SEED; } SEED() : BlockCipher(16, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); class G_FUNC diff --git a/src/block/serpent/serpent.cpp b/src/block/serpent/serpent.cpp index df7592fea..2fa27308f 100644 --- a/src/block/serpent/serpent.cpp +++ b/src/block/serpent/serpent.cpp @@ -243,93 +243,105 @@ inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3) /* * Serpent Encryption */ -void Serpent::enc(const byte in[], byte out[]) const +void Serpent::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit B0 = load_le(in, 0); - u32bit B1 = load_le(in, 1); - u32bit B2 = load_le(in, 2); - u32bit B3 = load_le(in, 3); - - key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 1,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 2,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 3,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 4,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 5,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 6,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 7,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 8,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor( 9,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(10,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(11,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(12,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(13,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(14,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(15,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(16,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(17,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(18,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(19,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(20,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(21,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(22,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(23,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(24,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(25,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(26,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(27,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(28,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(29,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(30,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(31,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); key_xor(32,B0,B1,B2,B3); - - store_le(out, B0, B1, B2, B3); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit B0 = load_le(in, 0); + u32bit B1 = load_le(in, 1); + u32bit B2 = load_le(in, 2); + u32bit B3 = load_le(in, 3); + + key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 1,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 2,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 3,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 4,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 5,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 6,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 7,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 8,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 9,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(10,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(11,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(12,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(13,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(14,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(15,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(16,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(17,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(18,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(19,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(20,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(21,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(22,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(23,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(24,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(25,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(26,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(27,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(28,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(29,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(30,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(31,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); key_xor(32,B0,B1,B2,B3); + + store_le(out, B0, B1, B2, B3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Serpent Decryption */ -void Serpent::dec(const byte in[], byte out[]) const +void Serpent::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit B0 = load_le(in, 0); - u32bit B1 = load_le(in, 1); - u32bit B2 = load_le(in, 2); - u32bit B3 = load_le(in, 3); - - key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(30,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(29,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(28,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(27,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(26,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor(25,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor(24,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(23,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(22,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(21,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(20,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(19,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(18,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor(17,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor(16,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(15,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(14,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(13,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(12,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(11,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(10,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 9,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 8,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor( 7,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor( 6,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor( 5,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor( 4,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor( 3,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor( 2,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 1,B0,B1,B2,B3); - i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 0,B0,B1,B2,B3); - - store_le(out, B0, B1, B2, B3); + for(u32bit i = 0; i != blocks; ++i) + { + u32bit B0 = load_le(in, 0); + u32bit B1 = load_le(in, 1); + u32bit B2 = load_le(in, 2); + u32bit B3 = load_le(in, 3); + + key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(30,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(29,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(28,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(27,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(26,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor(25,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor(24,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(23,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(22,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(21,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(20,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(19,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(18,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor(17,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor(16,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(15,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(14,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(13,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(12,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(11,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(10,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 9,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 8,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor( 7,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor( 6,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor( 5,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor( 4,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor( 3,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor( 2,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 1,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 0,B0,B1,B2,B3); + + store_le(out, B0, B1, B2, B3); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/serpent/serpent.h b/src/block/serpent/serpent.h index 5b9be257f..9c9fb59f2 100644 --- a/src/block/serpent/serpent.h +++ b/src/block/serpent/serpent.h @@ -23,8 +23,8 @@ class BOTAN_DLL Serpent : public BlockCipher BlockCipher* clone() const { return new Serpent; } Serpent() : BlockCipher(16, 16, 32, 8) {} protected: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer round_key; diff --git a/src/block/serpent_ia32/serp_ia32.cpp b/src/block/serpent_ia32/serp_ia32.cpp index 37dd4e637..997bec2fc 100644 --- a/src/block/serpent_ia32/serp_ia32.cpp +++ b/src/block/serpent_ia32/serp_ia32.cpp @@ -21,17 +21,27 @@ void botan_serpent_ia32_key_schedule(u32bit[140]); /* * Serpent Encryption */ -void Serpent_IA32::enc(const byte in[], byte out[]) const +void Serpent_IA32::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - botan_serpent_ia32_encrypt(in, out, round_key); + for(u32bit i = 0; i != blocks; ++i) + { + botan_serpent_ia32_encrypt(in, out, round_key); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Serpent Decryption */ -void Serpent_IA32::dec(const byte in[], byte out[]) const +void Serpent_IA32::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - botan_serpent_ia32_decrypt(in, out, round_key); + for(u32bit i = 0; i != blocks; ++i) + { + botan_serpent_ia32_decrypt(in, out, round_key); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/serpent_ia32/serp_ia32.h b/src/block/serpent_ia32/serp_ia32.h index 565e9889d..2b4a95d3d 100644 --- a/src/block/serpent_ia32/serp_ia32.h +++ b/src/block/serpent_ia32/serp_ia32.h @@ -20,8 +20,8 @@ class BOTAN_DLL Serpent_IA32 : public Serpent public: BlockCipher* clone() const { return new Serpent_IA32; } private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); }; diff --git a/src/block/skipjack/skipjack.cpp b/src/block/skipjack/skipjack.cpp index f5ffc861e..6c308c0f8 100644 --- a/src/block/skipjack/skipjack.cpp +++ b/src/block/skipjack/skipjack.cpp @@ -13,51 +13,63 @@ namespace Botan { /* * Skipjack Encryption */ -void Skipjack::enc(const byte in[], byte out[]) const +void Skipjack::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit W1 = load_le(in, 3); - u16bit W2 = load_le(in, 2); - u16bit W3 = load_le(in, 1); - u16bit W4 = load_le(in, 0); + for(u32bit i = 0; i != blocks; ++i) + { + u16bit W1 = load_le(in, 3); + u16bit W2 = load_le(in, 2); + u16bit W3 = load_le(in, 1); + u16bit W4 = load_le(in, 0); - step_A(W1,W4, 1); step_A(W4,W3, 2); step_A(W3,W2, 3); step_A(W2,W1, 4); - step_A(W1,W4, 5); step_A(W4,W3, 6); step_A(W3,W2, 7); step_A(W2,W1, 8); + step_A(W1,W4, 1); step_A(W4,W3, 2); step_A(W3,W2, 3); step_A(W2,W1, 4); + step_A(W1,W4, 5); step_A(W4,W3, 6); step_A(W3,W2, 7); step_A(W2,W1, 8); - step_B(W1,W2, 9); step_B(W4,W1,10); step_B(W3,W4,11); step_B(W2,W3,12); - step_B(W1,W2,13); step_B(W4,W1,14); step_B(W3,W4,15); step_B(W2,W3,16); + step_B(W1,W2, 9); step_B(W4,W1,10); step_B(W3,W4,11); step_B(W2,W3,12); + step_B(W1,W2,13); step_B(W4,W1,14); step_B(W3,W4,15); step_B(W2,W3,16); - step_A(W1,W4,17); step_A(W4,W3,18); step_A(W3,W2,19); step_A(W2,W1,20); - step_A(W1,W4,21); step_A(W4,W3,22); step_A(W3,W2,23); step_A(W2,W1,24); + step_A(W1,W4,17); step_A(W4,W3,18); step_A(W3,W2,19); step_A(W2,W1,20); + step_A(W1,W4,21); step_A(W4,W3,22); step_A(W3,W2,23); step_A(W2,W1,24); - step_B(W1,W2,25); step_B(W4,W1,26); step_B(W3,W4,27); step_B(W2,W3,28); - step_B(W1,W2,29); step_B(W4,W1,30); step_B(W3,W4,31); step_B(W2,W3,32); + step_B(W1,W2,25); step_B(W4,W1,26); step_B(W3,W4,27); step_B(W2,W3,28); + step_B(W1,W2,29); step_B(W4,W1,30); step_B(W3,W4,31); step_B(W2,W3,32); - store_le(out, W4, W3, W2, W1); + store_le(out, W4, W3, W2, W1); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Skipjack Decryption */ -void Skipjack::dec(const byte in[], byte out[]) const +void Skipjack::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u16bit W1 = load_le(in, 3); - u16bit W2 = load_le(in, 2); - u16bit W3 = load_le(in, 1); - u16bit W4 = load_le(in, 0); + for(u32bit i = 0; i != blocks; ++i) + { + u16bit W1 = load_le(in, 3); + u16bit W2 = load_le(in, 2); + u16bit W3 = load_le(in, 1); + u16bit W4 = load_le(in, 0); + + step_Bi(W2,W3,32); step_Bi(W3,W4,31); step_Bi(W4,W1,30); step_Bi(W1,W2,29); + step_Bi(W2,W3,28); step_Bi(W3,W4,27); step_Bi(W4,W1,26); step_Bi(W1,W2,25); - step_Bi(W2,W3,32); step_Bi(W3,W4,31); step_Bi(W4,W1,30); step_Bi(W1,W2,29); - step_Bi(W2,W3,28); step_Bi(W3,W4,27); step_Bi(W4,W1,26); step_Bi(W1,W2,25); + step_Ai(W1,W2,24); step_Ai(W2,W3,23); step_Ai(W3,W4,22); step_Ai(W4,W1,21); + step_Ai(W1,W2,20); step_Ai(W2,W3,19); step_Ai(W3,W4,18); step_Ai(W4,W1,17); - step_Ai(W1,W2,24); step_Ai(W2,W3,23); step_Ai(W3,W4,22); step_Ai(W4,W1,21); - step_Ai(W1,W2,20); step_Ai(W2,W3,19); step_Ai(W3,W4,18); step_Ai(W4,W1,17); + step_Bi(W2,W3,16); step_Bi(W3,W4,15); step_Bi(W4,W1,14); step_Bi(W1,W2,13); + step_Bi(W2,W3,12); step_Bi(W3,W4,11); step_Bi(W4,W1,10); step_Bi(W1,W2, 9); - step_Bi(W2,W3,16); step_Bi(W3,W4,15); step_Bi(W4,W1,14); step_Bi(W1,W2,13); - step_Bi(W2,W3,12); step_Bi(W3,W4,11); step_Bi(W4,W1,10); step_Bi(W1,W2, 9); + step_Ai(W1,W2, 8); step_Ai(W2,W3, 7); step_Ai(W3,W4, 6); step_Ai(W4,W1, 5); + step_Ai(W1,W2, 4); step_Ai(W2,W3, 3); step_Ai(W3,W4, 2); step_Ai(W4,W1, 1); - step_Ai(W1,W2, 8); step_Ai(W2,W3, 7); step_Ai(W3,W4, 6); step_Ai(W4,W1, 5); - step_Ai(W1,W2, 4); step_Ai(W2,W3, 3); step_Ai(W3,W4, 2); step_Ai(W4,W1, 1); + store_le(out, W4, W3, W2, W1); - store_le(out, W4, W3, W2, W1); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/skipjack/skipjack.h b/src/block/skipjack/skipjack.h index 231cd9c87..ec071dfe7 100644 --- a/src/block/skipjack/skipjack.h +++ b/src/block/skipjack/skipjack.h @@ -23,8 +23,8 @@ class BOTAN_DLL Skipjack : public BlockCipher BlockCipher* clone() const { return new Skipjack; } Skipjack() : BlockCipher(8, 10) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); void step_A(u16bit&, u16bit&, u32bit) const; void step_B(u16bit&, u16bit&, u32bit) const; diff --git a/src/block/square/square.cpp b/src/block/square/square.cpp index cb226542d..fdd47d3b2 100644 --- a/src/block/square/square.cpp +++ b/src/block/square/square.cpp @@ -14,103 +14,123 @@ namespace Botan { /* * Square Encryption */ -void Square::enc(const byte in[], byte out[]) const +void Square::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit T0, T1, T2, T3, B0, B1, B2, B3; - B0 = TE0[in[ 0] ^ ME[ 0]] ^ TE1[in[ 4] ^ ME[ 4]] ^ - TE2[in[ 8] ^ ME[ 8]] ^ TE3[in[12] ^ ME[12]] ^ EK[0]; - B1 = TE0[in[ 1] ^ ME[ 1]] ^ TE1[in[ 5] ^ ME[ 5]] ^ - TE2[in[ 9] ^ ME[ 9]] ^ TE3[in[13] ^ ME[13]] ^ EK[1]; - B2 = TE0[in[ 2] ^ ME[ 2]] ^ TE1[in[ 6] ^ ME[ 6]] ^ - TE2[in[10] ^ ME[10]] ^ TE3[in[14] ^ ME[14]] ^ EK[2]; - B3 = TE0[in[ 3] ^ ME[ 3]] ^ TE1[in[ 7] ^ ME[ 7]] ^ - TE2[in[11] ^ ME[11]] ^ TE3[in[15] ^ ME[15]] ^ EK[3]; - for(u32bit j = 1; j != 7; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - T0 = TE0[get_byte(0, B0)] ^ TE1[get_byte(0, B1)] ^ - TE2[get_byte(0, B2)] ^ TE3[get_byte(0, B3)] ^ EK[4*j+0]; - T1 = TE0[get_byte(1, B0)] ^ TE1[get_byte(1, B1)] ^ - TE2[get_byte(1, B2)] ^ TE3[get_byte(1, B3)] ^ EK[4*j+1]; - T2 = TE0[get_byte(2, B0)] ^ TE1[get_byte(2, B1)] ^ - TE2[get_byte(2, B2)] ^ TE3[get_byte(2, B3)] ^ EK[4*j+2]; - T3 = TE0[get_byte(3, B0)] ^ TE1[get_byte(3, B1)] ^ - TE2[get_byte(3, B2)] ^ TE3[get_byte(3, B3)] ^ EK[4*j+3]; - B0 = TE0[get_byte(0, T0)] ^ TE1[get_byte(0, T1)] ^ - TE2[get_byte(0, T2)] ^ TE3[get_byte(0, T3)] ^ EK[4*j+4]; - B1 = TE0[get_byte(1, T0)] ^ TE1[get_byte(1, T1)] ^ - TE2[get_byte(1, T2)] ^ TE3[get_byte(1, T3)] ^ EK[4*j+5]; - B2 = TE0[get_byte(2, T0)] ^ TE1[get_byte(2, T1)] ^ - TE2[get_byte(2, T2)] ^ TE3[get_byte(2, T3)] ^ EK[4*j+6]; - B3 = TE0[get_byte(3, T0)] ^ TE1[get_byte(3, T1)] ^ - TE2[get_byte(3, T2)] ^ TE3[get_byte(3, T3)] ^ EK[4*j+7]; + u32bit T0, T1, T2, T3, B0, B1, B2, B3; + + B0 = TE0[in[ 0] ^ ME[ 0]] ^ TE1[in[ 4] ^ ME[ 4]] ^ + TE2[in[ 8] ^ ME[ 8]] ^ TE3[in[12] ^ ME[12]] ^ EK[0]; + B1 = TE0[in[ 1] ^ ME[ 1]] ^ TE1[in[ 5] ^ ME[ 5]] ^ + TE2[in[ 9] ^ ME[ 9]] ^ TE3[in[13] ^ ME[13]] ^ EK[1]; + B2 = TE0[in[ 2] ^ ME[ 2]] ^ TE1[in[ 6] ^ ME[ 6]] ^ + TE2[in[10] ^ ME[10]] ^ TE3[in[14] ^ ME[14]] ^ EK[2]; + B3 = TE0[in[ 3] ^ ME[ 3]] ^ TE1[in[ 7] ^ ME[ 7]] ^ + TE2[in[11] ^ ME[11]] ^ TE3[in[15] ^ ME[15]] ^ EK[3]; + + for(u32bit j = 1; j != 7; j += 2) + { + T0 = TE0[get_byte(0, B0)] ^ TE1[get_byte(0, B1)] ^ + TE2[get_byte(0, B2)] ^ TE3[get_byte(0, B3)] ^ EK[4*j+0]; + T1 = TE0[get_byte(1, B0)] ^ TE1[get_byte(1, B1)] ^ + TE2[get_byte(1, B2)] ^ TE3[get_byte(1, B3)] ^ EK[4*j+1]; + T2 = TE0[get_byte(2, B0)] ^ TE1[get_byte(2, B1)] ^ + TE2[get_byte(2, B2)] ^ TE3[get_byte(2, B3)] ^ EK[4*j+2]; + T3 = TE0[get_byte(3, B0)] ^ TE1[get_byte(3, B1)] ^ + TE2[get_byte(3, B2)] ^ TE3[get_byte(3, B3)] ^ EK[4*j+3]; + + B0 = TE0[get_byte(0, T0)] ^ TE1[get_byte(0, T1)] ^ + TE2[get_byte(0, T2)] ^ TE3[get_byte(0, T3)] ^ EK[4*j+4]; + B1 = TE0[get_byte(1, T0)] ^ TE1[get_byte(1, T1)] ^ + TE2[get_byte(1, T2)] ^ TE3[get_byte(1, T3)] ^ EK[4*j+5]; + B2 = TE0[get_byte(2, T0)] ^ TE1[get_byte(2, T1)] ^ + TE2[get_byte(2, T2)] ^ TE3[get_byte(2, T3)] ^ EK[4*j+6]; + B3 = TE0[get_byte(3, T0)] ^ TE1[get_byte(3, T1)] ^ + TE2[get_byte(3, T2)] ^ TE3[get_byte(3, T3)] ^ EK[4*j+7]; + } + + out[ 0] = SE[get_byte(0, B0)] ^ ME[16]; + out[ 1] = SE[get_byte(0, B1)] ^ ME[17]; + out[ 2] = SE[get_byte(0, B2)] ^ ME[18]; + out[ 3] = SE[get_byte(0, B3)] ^ ME[19]; + out[ 4] = SE[get_byte(1, B0)] ^ ME[20]; + out[ 5] = SE[get_byte(1, B1)] ^ ME[21]; + out[ 6] = SE[get_byte(1, B2)] ^ ME[22]; + out[ 7] = SE[get_byte(1, B3)] ^ ME[23]; + out[ 8] = SE[get_byte(2, B0)] ^ ME[24]; + out[ 9] = SE[get_byte(2, B1)] ^ ME[25]; + out[10] = SE[get_byte(2, B2)] ^ ME[26]; + out[11] = SE[get_byte(2, B3)] ^ ME[27]; + out[12] = SE[get_byte(3, B0)] ^ ME[28]; + out[13] = SE[get_byte(3, B1)] ^ ME[29]; + out[14] = SE[get_byte(3, B2)] ^ ME[30]; + out[15] = SE[get_byte(3, B3)] ^ ME[31]; + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - out[ 0] = SE[get_byte(0, B0)] ^ ME[16]; - out[ 1] = SE[get_byte(0, B1)] ^ ME[17]; - out[ 2] = SE[get_byte(0, B2)] ^ ME[18]; - out[ 3] = SE[get_byte(0, B3)] ^ ME[19]; - out[ 4] = SE[get_byte(1, B0)] ^ ME[20]; - out[ 5] = SE[get_byte(1, B1)] ^ ME[21]; - out[ 6] = SE[get_byte(1, B2)] ^ ME[22]; - out[ 7] = SE[get_byte(1, B3)] ^ ME[23]; - out[ 8] = SE[get_byte(2, B0)] ^ ME[24]; - out[ 9] = SE[get_byte(2, B1)] ^ ME[25]; - out[10] = SE[get_byte(2, B2)] ^ ME[26]; - out[11] = SE[get_byte(2, B3)] ^ ME[27]; - out[12] = SE[get_byte(3, B0)] ^ ME[28]; - out[13] = SE[get_byte(3, B1)] ^ ME[29]; - out[14] = SE[get_byte(3, B2)] ^ ME[30]; - out[15] = SE[get_byte(3, B3)] ^ ME[31]; } /* * Square Decryption */ -void Square::dec(const byte in[], byte out[]) const +void Square::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit T0, T1, T2, T3, B0, B1, B2, B3; - B0 = TD0[in[ 0] ^ MD[ 0]] ^ TD1[in[ 4] ^ MD[ 4]] ^ - TD2[in[ 8] ^ MD[ 8]] ^ TD3[in[12] ^ MD[12]] ^ DK[0]; - B1 = TD0[in[ 1] ^ MD[ 1]] ^ TD1[in[ 5] ^ MD[ 5]] ^ - TD2[in[ 9] ^ MD[ 9]] ^ TD3[in[13] ^ MD[13]] ^ DK[1]; - B2 = TD0[in[ 2] ^ MD[ 2]] ^ TD1[in[ 6] ^ MD[ 6]] ^ - TD2[in[10] ^ MD[10]] ^ TD3[in[14] ^ MD[14]] ^ DK[2]; - B3 = TD0[in[ 3] ^ MD[ 3]] ^ TD1[in[ 7] ^ MD[ 7]] ^ - TD2[in[11] ^ MD[11]] ^ TD3[in[15] ^ MD[15]] ^ DK[3]; - for(u32bit j = 1; j != 7; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - T0 = TD0[get_byte(0, B0)] ^ TD1[get_byte(0, B1)] ^ - TD2[get_byte(0, B2)] ^ TD3[get_byte(0, B3)] ^ DK[4*j+0]; - T1 = TD0[get_byte(1, B0)] ^ TD1[get_byte(1, B1)] ^ - TD2[get_byte(1, B2)] ^ TD3[get_byte(1, B3)] ^ DK[4*j+1]; - T2 = TD0[get_byte(2, B0)] ^ TD1[get_byte(2, B1)] ^ - TD2[get_byte(2, B2)] ^ TD3[get_byte(2, B3)] ^ DK[4*j+2]; - T3 = TD0[get_byte(3, B0)] ^ TD1[get_byte(3, B1)] ^ - TD2[get_byte(3, B2)] ^ TD3[get_byte(3, B3)] ^ DK[4*j+3]; - B0 = TD0[get_byte(0, T0)] ^ TD1[get_byte(0, T1)] ^ - TD2[get_byte(0, T2)] ^ TD3[get_byte(0, T3)] ^ DK[4*j+4]; - B1 = TD0[get_byte(1, T0)] ^ TD1[get_byte(1, T1)] ^ - TD2[get_byte(1, T2)] ^ TD3[get_byte(1, T3)] ^ DK[4*j+5]; - B2 = TD0[get_byte(2, T0)] ^ TD1[get_byte(2, T1)] ^ - TD2[get_byte(2, T2)] ^ TD3[get_byte(2, T3)] ^ DK[4*j+6]; - B3 = TD0[get_byte(3, T0)] ^ TD1[get_byte(3, T1)] ^ - TD2[get_byte(3, T2)] ^ TD3[get_byte(3, T3)] ^ DK[4*j+7]; + u32bit T0, T1, T2, T3, B0, B1, B2, B3; + + B0 = TD0[in[ 0] ^ MD[ 0]] ^ TD1[in[ 4] ^ MD[ 4]] ^ + TD2[in[ 8] ^ MD[ 8]] ^ TD3[in[12] ^ MD[12]] ^ DK[0]; + B1 = TD0[in[ 1] ^ MD[ 1]] ^ TD1[in[ 5] ^ MD[ 5]] ^ + TD2[in[ 9] ^ MD[ 9]] ^ TD3[in[13] ^ MD[13]] ^ DK[1]; + B2 = TD0[in[ 2] ^ MD[ 2]] ^ TD1[in[ 6] ^ MD[ 6]] ^ + TD2[in[10] ^ MD[10]] ^ TD3[in[14] ^ MD[14]] ^ DK[2]; + B3 = TD0[in[ 3] ^ MD[ 3]] ^ TD1[in[ 7] ^ MD[ 7]] ^ + TD2[in[11] ^ MD[11]] ^ TD3[in[15] ^ MD[15]] ^ DK[3]; + + for(u32bit j = 1; j != 7; j += 2) + { + T0 = TD0[get_byte(0, B0)] ^ TD1[get_byte(0, B1)] ^ + TD2[get_byte(0, B2)] ^ TD3[get_byte(0, B3)] ^ DK[4*j+0]; + T1 = TD0[get_byte(1, B0)] ^ TD1[get_byte(1, B1)] ^ + TD2[get_byte(1, B2)] ^ TD3[get_byte(1, B3)] ^ DK[4*j+1]; + T2 = TD0[get_byte(2, B0)] ^ TD1[get_byte(2, B1)] ^ + TD2[get_byte(2, B2)] ^ TD3[get_byte(2, B3)] ^ DK[4*j+2]; + T3 = TD0[get_byte(3, B0)] ^ TD1[get_byte(3, B1)] ^ + TD2[get_byte(3, B2)] ^ TD3[get_byte(3, B3)] ^ DK[4*j+3]; + + B0 = TD0[get_byte(0, T0)] ^ TD1[get_byte(0, T1)] ^ + TD2[get_byte(0, T2)] ^ TD3[get_byte(0, T3)] ^ DK[4*j+4]; + B1 = TD0[get_byte(1, T0)] ^ TD1[get_byte(1, T1)] ^ + TD2[get_byte(1, T2)] ^ TD3[get_byte(1, T3)] ^ DK[4*j+5]; + B2 = TD0[get_byte(2, T0)] ^ TD1[get_byte(2, T1)] ^ + TD2[get_byte(2, T2)] ^ TD3[get_byte(2, T3)] ^ DK[4*j+6]; + B3 = TD0[get_byte(3, T0)] ^ TD1[get_byte(3, T1)] ^ + TD2[get_byte(3, T2)] ^ TD3[get_byte(3, T3)] ^ DK[4*j+7]; + } + + out[ 0] = SD[get_byte(0, B0)] ^ MD[16]; + out[ 1] = SD[get_byte(0, B1)] ^ MD[17]; + out[ 2] = SD[get_byte(0, B2)] ^ MD[18]; + out[ 3] = SD[get_byte(0, B3)] ^ MD[19]; + out[ 4] = SD[get_byte(1, B0)] ^ MD[20]; + out[ 5] = SD[get_byte(1, B1)] ^ MD[21]; + out[ 6] = SD[get_byte(1, B2)] ^ MD[22]; + out[ 7] = SD[get_byte(1, B3)] ^ MD[23]; + out[ 8] = SD[get_byte(2, B0)] ^ MD[24]; + out[ 9] = SD[get_byte(2, B1)] ^ MD[25]; + out[10] = SD[get_byte(2, B2)] ^ MD[26]; + out[11] = SD[get_byte(2, B3)] ^ MD[27]; + out[12] = SD[get_byte(3, B0)] ^ MD[28]; + out[13] = SD[get_byte(3, B1)] ^ MD[29]; + out[14] = SD[get_byte(3, B2)] ^ MD[30]; + out[15] = SD[get_byte(3, B3)] ^ MD[31]; + + in += BLOCK_SIZE; + out += BLOCK_SIZE; } - out[ 0] = SD[get_byte(0, B0)] ^ MD[16]; - out[ 1] = SD[get_byte(0, B1)] ^ MD[17]; - out[ 2] = SD[get_byte(0, B2)] ^ MD[18]; - out[ 3] = SD[get_byte(0, B3)] ^ MD[19]; - out[ 4] = SD[get_byte(1, B0)] ^ MD[20]; - out[ 5] = SD[get_byte(1, B1)] ^ MD[21]; - out[ 6] = SD[get_byte(1, B2)] ^ MD[22]; - out[ 7] = SD[get_byte(1, B3)] ^ MD[23]; - out[ 8] = SD[get_byte(2, B0)] ^ MD[24]; - out[ 9] = SD[get_byte(2, B1)] ^ MD[25]; - out[10] = SD[get_byte(2, B2)] ^ MD[26]; - out[11] = SD[get_byte(2, B3)] ^ MD[27]; - out[12] = SD[get_byte(3, B0)] ^ MD[28]; - out[13] = SD[get_byte(3, B1)] ^ MD[29]; - out[14] = SD[get_byte(3, B2)] ^ MD[30]; - out[15] = SD[get_byte(3, B3)] ^ MD[31]; } /* diff --git a/src/block/square/square.h b/src/block/square/square.h index 94a1fc370..0de4c20bd 100644 --- a/src/block/square/square.h +++ b/src/block/square/square.h @@ -23,8 +23,8 @@ class BOTAN_DLL Square : public BlockCipher BlockCipher* clone() const { return new Square; } Square() : BlockCipher(16, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static void transform(u32bit[4]); diff --git a/src/block/tea/tea.cpp b/src/block/tea/tea.cpp index 2b4212d9c..de30858da 100644 --- a/src/block/tea/tea.cpp +++ b/src/block/tea/tea.cpp @@ -13,37 +13,49 @@ namespace Botan { /* * TEA Encryption */ -void TEA::enc(const byte in[], byte out[]) const +void TEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit L = load_be(in, 0), R = load_be(in, 1); - - u32bit S = 0; - for(u32bit j = 0; j != 32; ++j) + for(u32bit i = 0; i != blocks; ++i) { - S += 0x9E3779B9; - L += ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]); - R += ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]); - } + u32bit L = load_be(in, 0), R = load_be(in, 1); + + u32bit S = 0; + for(u32bit j = 0; j != 32; ++j) + { + S += 0x9E3779B9; + L += ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]); + R += ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]); + } - store_be(out, L, R); + store_be(out, L, R); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * TEA Decryption */ -void TEA::dec(const byte in[], byte out[]) const +void TEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit L = load_be(in, 0), R = load_be(in, 1); - - u32bit S = 0xC6EF3720; - for(u32bit j = 0; j != 32; ++j) + for(u32bit i = 0; i != blocks; ++i) { - R -= ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]); - L -= ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]); - S -= 0x9E3779B9; - } + u32bit L = load_be(in, 0), R = load_be(in, 1); + + u32bit S = 0xC6EF3720; + for(u32bit j = 0; j != 32; ++j) + { + R -= ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]); + L -= ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]); + S -= 0x9E3779B9; + } - store_be(out, L, R); + store_be(out, L, R); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/tea/tea.h b/src/block/tea/tea.h index 8ddf3e330..141899e88 100644 --- a/src/block/tea/tea.h +++ b/src/block/tea/tea.h @@ -23,8 +23,8 @@ class BOTAN_DLL TEA : public BlockCipher BlockCipher* clone() const { return new TEA; } TEA() : BlockCipher(8, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer K; }; diff --git a/src/block/twofish/twofish.cpp b/src/block/twofish/twofish.cpp index 9784b00a2..6a482a8f3 100644 --- a/src/block/twofish/twofish.cpp +++ b/src/block/twofish/twofish.cpp @@ -14,91 +14,103 @@ namespace Botan { /* * Twofish Encryption */ -void Twofish::enc(const byte in[], byte out[]) const +void Twofish::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0) ^ round_key[0]; - u32bit B = load_le(in, 1) ^ round_key[1]; - u32bit C = load_le(in, 2) ^ round_key[2]; - u32bit D = load_le(in, 3) ^ round_key[3]; - - for(u32bit j = 0; j != 16; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - u32bit X, Y; - - X = SBox0[get_byte(3, A)] ^ SBox1[get_byte(2, A)] ^ - SBox2[get_byte(1, A)] ^ SBox3[get_byte(0, A)]; - Y = SBox0[get_byte(0, B)] ^ SBox1[get_byte(3, B)] ^ - SBox2[get_byte(2, B)] ^ SBox3[get_byte(1, B)]; - X += Y; - Y += X + round_key[2*j + 9]; - X += round_key[2*j + 8]; - - C = rotate_right(C ^ X, 1); - D = rotate_left(D, 1) ^ Y; - - X = SBox0[get_byte(3, C)] ^ SBox1[get_byte(2, C)] ^ - SBox2[get_byte(1, C)] ^ SBox3[get_byte(0, C)]; - Y = SBox0[get_byte(0, D)] ^ SBox1[get_byte(3, D)] ^ - SBox2[get_byte(2, D)] ^ SBox3[get_byte(1, D)]; - X += Y; - Y += X + round_key[2*j + 11]; - X += round_key[2*j + 10]; - - A = rotate_right(A ^ X, 1); - B = rotate_left(B, 1) ^ Y; - } + u32bit A = load_le(in, 0) ^ round_key[0]; + u32bit B = load_le(in, 1) ^ round_key[1]; + u32bit C = load_le(in, 2) ^ round_key[2]; + u32bit D = load_le(in, 3) ^ round_key[3]; - C ^= round_key[4]; - D ^= round_key[5]; - A ^= round_key[6]; - B ^= round_key[7]; + for(u32bit j = 0; j != 16; j += 2) + { + u32bit X, Y; + + X = SBox0[get_byte(3, A)] ^ SBox1[get_byte(2, A)] ^ + SBox2[get_byte(1, A)] ^ SBox3[get_byte(0, A)]; + Y = SBox0[get_byte(0, B)] ^ SBox1[get_byte(3, B)] ^ + SBox2[get_byte(2, B)] ^ SBox3[get_byte(1, B)]; + X += Y; + Y += X + round_key[2*j + 9]; + X += round_key[2*j + 8]; + + C = rotate_right(C ^ X, 1); + D = rotate_left(D, 1) ^ Y; + + X = SBox0[get_byte(3, C)] ^ SBox1[get_byte(2, C)] ^ + SBox2[get_byte(1, C)] ^ SBox3[get_byte(0, C)]; + Y = SBox0[get_byte(0, D)] ^ SBox1[get_byte(3, D)] ^ + SBox2[get_byte(2, D)] ^ SBox3[get_byte(1, D)]; + X += Y; + Y += X + round_key[2*j + 11]; + X += round_key[2*j + 10]; + + A = rotate_right(A ^ X, 1); + B = rotate_left(B, 1) ^ Y; + } - store_le(out, C, D, A, B); + C ^= round_key[4]; + D ^= round_key[5]; + A ^= round_key[6]; + B ^= round_key[7]; + + store_le(out, C, D, A, B); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * Twofish Decryption */ -void Twofish::dec(const byte in[], byte out[]) const +void Twofish::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit A = load_le(in, 0) ^ round_key[4]; - u32bit B = load_le(in, 1) ^ round_key[5]; - u32bit C = load_le(in, 2) ^ round_key[6]; - u32bit D = load_le(in, 3) ^ round_key[7]; - - for(u32bit j = 0; j != 16; j += 2) + for(u32bit i = 0; i != blocks; ++i) { - u32bit X, Y; - - X = SBox0[get_byte(3, A)] ^ SBox1[get_byte(2, A)] ^ - SBox2[get_byte(1, A)] ^ SBox3[get_byte(0, A)]; - Y = SBox0[get_byte(0, B)] ^ SBox1[get_byte(3, B)] ^ - SBox2[get_byte(2, B)] ^ SBox3[get_byte(1, B)]; - X += Y; - Y += X + round_key[39 - 2*j]; - X += round_key[38 - 2*j]; - - C = rotate_left(C, 1) ^ X; - D = rotate_right(D ^ Y, 1); - - X = SBox0[get_byte(3, C)] ^ SBox1[get_byte(2, C)] ^ - SBox2[get_byte(1, C)] ^ SBox3[get_byte(0, C)]; - Y = SBox0[get_byte(0, D)] ^ SBox1[get_byte(3, D)] ^ - SBox2[get_byte(2, D)] ^ SBox3[get_byte(1, D)]; - X += Y; - Y += X + round_key[37 - 2*j]; - X += round_key[36 - 2*j]; - - A = rotate_left(A, 1) ^ X; - B = rotate_right(B ^ Y, 1); - } + u32bit A = load_le(in, 0) ^ round_key[4]; + u32bit B = load_le(in, 1) ^ round_key[5]; + u32bit C = load_le(in, 2) ^ round_key[6]; + u32bit D = load_le(in, 3) ^ round_key[7]; - C ^= round_key[0]; - D ^= round_key[1]; - A ^= round_key[2]; - B ^= round_key[3]; + for(u32bit j = 0; j != 16; j += 2) + { + u32bit X, Y; + + X = SBox0[get_byte(3, A)] ^ SBox1[get_byte(2, A)] ^ + SBox2[get_byte(1, A)] ^ SBox3[get_byte(0, A)]; + Y = SBox0[get_byte(0, B)] ^ SBox1[get_byte(3, B)] ^ + SBox2[get_byte(2, B)] ^ SBox3[get_byte(1, B)]; + X += Y; + Y += X + round_key[39 - 2*j]; + X += round_key[38 - 2*j]; + + C = rotate_left(C, 1) ^ X; + D = rotate_right(D ^ Y, 1); + + X = SBox0[get_byte(3, C)] ^ SBox1[get_byte(2, C)] ^ + SBox2[get_byte(1, C)] ^ SBox3[get_byte(0, C)]; + Y = SBox0[get_byte(0, D)] ^ SBox1[get_byte(3, D)] ^ + SBox2[get_byte(2, D)] ^ SBox3[get_byte(1, D)]; + X += Y; + Y += X + round_key[37 - 2*j]; + X += round_key[36 - 2*j]; + + A = rotate_left(A, 1) ^ X; + B = rotate_right(B ^ Y, 1); + } - store_le(out, C, D, A, B); + C ^= round_key[0]; + D ^= round_key[1]; + A ^= round_key[2]; + B ^= round_key[3]; + + store_le(out, C, D, A, B); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/twofish/twofish.h b/src/block/twofish/twofish.h index 0640e32f8..640fb58ad 100644 --- a/src/block/twofish/twofish.h +++ b/src/block/twofish/twofish.h @@ -23,8 +23,8 @@ class BOTAN_DLL Twofish : public BlockCipher BlockCipher* clone() const { return new Twofish; } Twofish() : BlockCipher(16, 16, 32, 8) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static void rs_mul(byte[4], byte, u32bit); diff --git a/src/block/xtea/xtea.cpp b/src/block/xtea/xtea.cpp index 5047f6594..0dba5f2be 100644 --- a/src/block/xtea/xtea.cpp +++ b/src/block/xtea/xtea.cpp @@ -14,33 +14,45 @@ namespace Botan { /* * XTEA Encryption */ -void XTEA::enc(const byte in[], byte out[]) const +void XTEA::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit L = load_be(in, 0), R = load_be(in, 1); - - for(u32bit j = 0; j != 32; ++j) + for(u32bit i = 0; i != blocks; ++i) { - L += (((R << 4) ^ (R >> 5)) + R) ^ EK[2*j]; - R += (((L << 4) ^ (L >> 5)) + L) ^ EK[2*j+1]; - } + u32bit L = load_be(in, 0), R = load_be(in, 1); + + for(u32bit j = 0; j != 32; ++j) + { + L += (((R << 4) ^ (R >> 5)) + R) ^ EK[2*j]; + R += (((L << 4) ^ (L >> 5)) + L) ^ EK[2*j+1]; + } - store_be(out, L, R); + store_be(out, L, R); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* * XTEA Decryption */ -void XTEA::dec(const byte in[], byte out[]) const +void XTEA::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - u32bit L = load_be(in, 0), R = load_be(in, 1); - - for(u32bit j = 0; j != 32; ++j) + for(u32bit i = 0; i != blocks; ++i) { - R -= (((L << 4) ^ (L >> 5)) + L) ^ EK[63 - 2*j]; - L -= (((R << 4) ^ (R >> 5)) + R) ^ EK[62 - 2*j]; - } + u32bit L = load_be(in, 0), R = load_be(in, 1); + + for(u32bit j = 0; j != 32; ++j) + { + R -= (((L << 4) ^ (L >> 5)) + L) ^ EK[63 - 2*j]; + L -= (((R << 4) ^ (R >> 5)) + R) ^ EK[62 - 2*j]; + } - store_be(out, L, R); + store_be(out, L, R); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } } /* diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h index d9c6066cb..b50f487b4 100644 --- a/src/block/xtea/xtea.h +++ b/src/block/xtea/xtea.h @@ -23,8 +23,8 @@ class BOTAN_DLL XTEA : public BlockCipher BlockCipher* clone() const { return new XTEA; } XTEA() : BlockCipher(8, 16) {} private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK; }; diff --git a/src/modes/ctr/ctr.cpp b/src/modes/ctr/ctr.cpp index 9eb42ec5a..5c27ca63c 100644 --- a/src/modes/ctr/ctr.cpp +++ b/src/modes/ctr/ctr.cpp @@ -1,6 +1,6 @@ /* * CTR Mode -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -14,9 +14,13 @@ namespace Botan { /* * CTR-BE Constructor */ -CTR_BE::CTR_BE(BlockCipher* ciph) : - BlockCipherMode(ciph, "CTR-BE", ciph->BLOCK_SIZE, 1) +CTR_BE::CTR_BE(BlockCipher* ciph) : cipher(ciph) { + base_ptr = cipher; + position = 0; + + counter.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); + enc_buffer.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); } /* @@ -24,39 +28,86 @@ CTR_BE::CTR_BE(BlockCipher* ciph) : */ CTR_BE::CTR_BE(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv) : - BlockCipherMode(ciph, "CTR-BE", ciph->BLOCK_SIZE, 1) + cipher(ciph) { + base_ptr = cipher; + position = 0; + + counter.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); + enc_buffer.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); + set_key(key); set_iv(iv); } +/* +* CTR_BE Destructor +*/ +CTR_BE::~CTR_BE() + { + delete cipher; + } + +/* +* Return the name of this type +*/ +std::string CTR_BE::name() const + { + return ("CTR-BE/" + cipher->name()); + } + +/* +* Set CTR-BE IV +*/ +void CTR_BE::set_iv(const InitializationVector& iv) + { + if(iv.length() != cipher->BLOCK_SIZE) + throw Invalid_IV_Length(name(), iv.length()); + + enc_buffer.clear(); + position = 0; + + for(u32bit i = 0; i != CTR_BLOCKS_PARALLEL; ++i) + { + counter.copy(i*cipher->BLOCK_SIZE, iv.begin(), iv.length()); + + // FIXME: this is stupid + for(u32bit j = 0; j != i; ++j) + for(s32bit k = cipher->BLOCK_SIZE - 1; k >= 0; --k) + if(++counter[i*cipher->BLOCK_SIZE+k]) + break; + } + + cipher->encrypt_n(counter, enc_buffer, CTR_BLOCKS_PARALLEL); + } + /* * CTR-BE Encryption/Decryption */ void CTR_BE::write(const byte input[], u32bit length) { - u32bit copied = std::min(BLOCK_SIZE - position, length); - xor_buf(buffer + position, input, copied); - send(buffer + position, copied); + u32bit copied = std::min(enc_buffer.size() - position, length); + xor_buf(enc_buffer + position, input, copied); + send(enc_buffer + position, copied); input += copied; length -= copied; position += copied; - if(position == BLOCK_SIZE) + if(position == enc_buffer.size()) increment_counter(); - while(length >= BLOCK_SIZE) + while(length >= enc_buffer.size()) { - xor_buf(buffer, input, BLOCK_SIZE); - send(buffer, BLOCK_SIZE); + xor_buf(enc_buffer, input, enc_buffer.size()); + send(enc_buffer, enc_buffer.size()); - input += BLOCK_SIZE; - length -= BLOCK_SIZE; + input += enc_buffer.size(); + length -= enc_buffer.size(); increment_counter(); } - xor_buf(buffer + position, input, length); - send(buffer + position, length); + xor_buf(enc_buffer + position, input, length); + send(enc_buffer + position, length); position += length; } @@ -65,10 +116,25 @@ void CTR_BE::write(const byte input[], u32bit length) */ void CTR_BE::increment_counter() { - for(s32bit j = BLOCK_SIZE - 1; j >= 0; --j) - if(++state[j]) - break; - cipher->encrypt(state, buffer); + for(u32bit i = 0; i != CTR_BLOCKS_PARALLEL; ++i) + { + // FIXME: Can do it in a single loop + /* + for(u32bit j = 1; j != cipher->BLOCK_SIZE; ++j) + { + byte carry = 0; + byte z = counter[(i+1)*cipher->BLOCK_SIZE-1] + CTR_BLOCKS_PARALLEL; + + if( + */ + for(u32bit j = 0; j != CTR_BLOCKS_PARALLEL; ++j) + for(s32bit k = cipher->BLOCK_SIZE - 1; k >= 0; --k) + if(++counter[i*cipher->BLOCK_SIZE+k]) + break; + } + + cipher->encrypt_n(counter, enc_buffer, CTR_BLOCKS_PARALLEL); + position = 0; } diff --git a/src/modes/ctr/ctr.h b/src/modes/ctr/ctr.h index aa0db5761..3d509f02c 100644 --- a/src/modes/ctr/ctr.h +++ b/src/modes/ctr/ctr.h @@ -8,22 +8,33 @@ #ifndef BOTAN_COUNTER_MODE_H__ #define BOTAN_COUNTER_MODE_H__ -#include -#include +#include +#include namespace Botan { /* * CTR-BE Mode */ -class BOTAN_DLL CTR_BE : public BlockCipherMode +class BOTAN_DLL CTR_BE : public Keyed_Filter { public: + std::string name() const; + void set_iv(const InitializationVector&); + CTR_BE(BlockCipher*); CTR_BE(BlockCipher*, const SymmetricKey&, const InitializationVector&); + + ~CTR_BE(); private: + static const u32bit CTR_BLOCKS_PARALLEL = 8; + void write(const byte[], u32bit); void increment_counter(); + + BlockCipher* cipher; + SecureVector counter, enc_buffer; + u32bit position; }; } -- cgit v1.2.3 From 13d50de7b7675d798437c0d465acedd23e08b092 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 11 Aug 2009 17:12:00 +0000 Subject: Modify Keyed_Filter so it is a pure interface Modify ECB to use parallel encryption/decryption where possible Add toggles in build.h specifying how many blocks to process in parallel. Defaults to 8 blocks for all modes, which is sufficient that any likely parallelism can be extracted (via SIMD or concurrent execution) but not so much as to seem likely to cause cache problems (8*128 bits = 128 bytes, or two x86 cache lines) --- checks/validate.dat | 89 ++++++++++++++++++++ src/build-data/buildh.in | 6 ++ src/codec/openpgp/openpgp.cpp | 1 + src/filters/algo_filt.cpp | 10 +-- src/filters/basefilt.cpp | 21 ----- src/filters/basefilt.h | 33 -------- src/filters/filters.h | 42 +++++++++- src/filters/info.txt | 1 + src/filters/key_filt.h | 45 ++++++++++ src/modes/ctr/ctr.cpp | 30 ++++--- src/modes/ctr/ctr.h | 10 ++- src/modes/eax/eax.h | 2 +- src/modes/ecb/ecb.cpp | 191 ++++++++++++++++++++++++++++++++++-------- src/modes/ecb/ecb.h | 68 ++++++++------- src/modes/modebase.cpp | 2 +- src/modes/modebase.h | 9 +- src/modes/xts/xts.h | 8 +- 17 files changed, 418 insertions(+), 150 deletions(-) create mode 100644 src/filters/key_filt.h (limited to 'src') diff --git a/checks/validate.dat b/checks/validate.dat index b8566b62a..c4e0d0121 100644 --- a/checks/validate.dat +++ b/checks/validate.dat @@ -19472,7 +19472,20 @@ D261D6041824D259290EABD3E9132DB8:7E3B14847526572FF2AA5D7BD626B560:\ 01000000000000000000000000000000:07E5E5AD7097B849BADC2D5D803B7F6A:\ 0000000000000000000000000000000000000000000000000000000000000000 +1032547698BADCFEEFCDAB8967452301:D5BAA00A4BB9D8A7C981C8DC90D89D92:\ +FFEEDDCCBBAA99887766554433221100 +145F0B8B663176B95DCAB7E9DCD5CC24:1032547698BADCFEEFCDAB8967452301:\ +FFEEDDCCBBAA99887766554433221100 + +1032547698BADCFEEFCDAB8967452301:DA860842B720802BF404A4C71034879A:\ +8899AABBCCDDEEFFFFEEDDCCBBAA99887766554433221100 + +B2696BD0D98C17953E4239225D27202C:1032547698BADCFEEFCDAB8967452301:\ +8899AABBCCDDEEFFFFEEDDCCBBAA99887766554433221100 + +1032547698BADCFEEFCDAB8967452301:93DF9A3CAFE387BD999EEBE393A17FCA:\ +00112233445566778899AABBCCDDEEFFFFEEDDCCBBAA99887766554433221100 # Corrected test vectors, based on NIST's clarification of May 9, 2002 [Skipjack] @@ -22938,6 +22951,51 @@ B4ECC305C3DBD8E5:FBBEC8F5DBF4CEFD:1B5E23EBD915C1FEE59F57DD91AF7347 # The block cipher tests above are distinct from these ECB mode tests # for testing reasons. They could otherwise easily be CIPHER/ECB/NoPadding + +[AES/ECB/NoPadding] +D8F532538289EF7D06B506A4FD5BE9C9FD7A929E0FD917686D9520ED236A276D\ +69E63C821F9DE0BF23CF1D19C7374FD1C3139DE2E1BA4693C3E9D29D774C2FF4\ +69E63C821F9DE0BF23CF1D19C7374FD1C3139DE2E1BA4693C3E9D29D774C2FF4\ +D8F532538289EF7D06B506A4FD5BE9C9FD7A929E0FD917686D9520ED236A276D\ +D8F532538289EF7D06B506A4FD5BE9C9C3139DE2E1BA4693C3E9D29D774C2FF4:\ +FD7A929E0FD917686D9520ED236A276D69E63C821F9DE0BF23CF1D19C7374FD1\ +C3139DE2E1BA4693C3E9D29D774C2FF46BA2DCF84C0E7E4D75CB53AD11BA76D6\ +C3139DE2E1BA4693C3E9D29D774C2FF46BA2DCF84C0E7E4D75CB53AD11BA76D6\ +FD7A929E0FD917686D9520ED236A276D69E63C821F9DE0BF23CF1D19C7374FD1\ +FD7A929E0FD917686D9520ED236A276D6BA2DCF84C0E7E4D75CB53AD11BA76D6:\ +00010203050607080A0B0C0D0F101112 + +[Serpent/ECB/NoPadding] +D29D576FCEA3A3A7ED9099F29273D78E2D62A890CEA3A3A7ED9099F29273D78E\ +D29D576F315C5C58ED9099F29273D78E2D62A890315C5C58ED9099F29273D78E\ +D29D576FCEA3A3A7126F660D9273D78E2D62A890CEA3A3A7126F660D9273D78E\ +D29D576F315C5C58126F660D9273D78E2D62A890315C5C58126F660D9273D78E\ +D29D576FCEA3A3A7ED9099F26D8C28712D62A890CEA3A3A7ED9099F26D8C2871\ +D29D576F315C5C58ED9099F26D8C28712D62A890315C5C58ED9099F26D8C2871\ +D29D576FCEA3A3A7126F660D6D8C28712D62A890CEA3A3A7126F660D6D8C2871\ +D29D576F315C5C58126F660D6D8C28712D62A890315C5C58126F660D6D8C2871\ +AA26D561F567520E8AE47528C24C18D731A2193D9A97FED6922B17AAA6372B74\ +BE5DEBD559E303C9C92B174A5107BBFEB626D8F65EDCCDF3AEE475C8A1837722\ +41DDE7C1F1631F5FDED4F42746471BD651D238BA86176EFE39E4695AAEB73B52\ +EA5926CADAD8018962E469BA920CB8BF1EA9062E4D9CEDD5FAD4F4C7990367A4\ +B966E5C5D2277288C61B96A559CC84AFB6A6583C5AACFCD6212B0BD8AEF3C6A9\ +A11DDBD175639341052B0B384678D8D9352299B71DD880E29D1B96452DB86540:\ +B2288B968AE8B08648D1CE9606FD992D717EB02EB81A2E939D54ACA91087112D\ +0D809C5EE82F477EBA7B956DBB23463B0F0190D616F5294112FFB7884E8B37F9\ +41BA1B505386B7428B88338188F7E718A3348230BF5CFA552F88D22463D9703A\ +115351622E016BCA26918D17E13225F67EE4E3F2C46FE52ECBDA044C585717DC\ +563A8403FF5309D62370B1DCF5A11EDD2F7D73602B70CD2553E44C1D3F170126\ +155BBD9BE3A965B345E834718F651CEF6CC65E8C5C566E894817350F497816F1\ +EEFA51FC91FEBB6E9F8CB141CC0EB6AF3C6F8380CBD3C996167F2F0E90E71B75\ +6C87EB62A4975356B28DCBF6A64A0BD107206D48FE6DBE19D50314B90AC87B83\ +35706F9B26007071AD8105CFAA1C1E2FF7FEAE5CEC4D11477F24E6B200906870\ +3C0E29E2950F2AC2DACD63DEEB5C7EFA9FDB9F3B740563D5518287DC981FC9CB\ +46D4B5A5A86FEC08FE70D18297DCF51072DDBE038DA040EBB12C509F5940A212\ +DDEB59F02132BE4581FC23EABAA960D6341D9352E36DFD6E4EAF0F6F439BC8CE\ +73A9AB3164FF30350F2DC08E939A104D6DF0C2C28F8E2D44468A61278BB6B429\ +4DAE45AE0CAA032FC97CD4D8C57FB83BBA8AFCAE22070BC882D3A42B38A09E65:\ +00000000000000000000000000000000 + [DES/ECB/NoPadding] 059B5E0851CF143A:86A560F10EC6D85B:0113B970FD34F2CE 4E6F772069732074:3FA40E8A984D4815:0123456789ABCDEF @@ -24901,6 +24959,37 @@ E5C7CDDE872BF27C43E934008C389C0F683788499A7C05F662C16A27E4FCF277:\ 4E6F77206973207468652074696D6520666F7220616C6C20:\ 0123456789ABCDEF:1234567890ABCDEF +[Serpent/ECB/NoPadding] +B2288B968AE8B08648D1CE9606FD992D717EB02EB81A2E939D54ACA91087112D\ +0D809C5EE82F477EBA7B956DBB23463B0F0190D616F5294112FFB7884E8B37F9\ +41BA1B505386B7428B88338188F7E718A3348230BF5CFA552F88D22463D9703A\ +115351622E016BCA26918D17E13225F67EE4E3F2C46FE52ECBDA044C585717DC\ +563A8403FF5309D62370B1DCF5A11EDD2F7D73602B70CD2553E44C1D3F170126\ +155BBD9BE3A965B345E834718F651CEF6CC65E8C5C566E894817350F497816F1\ +EEFA51FC91FEBB6E9F8CB141CC0EB6AF3C6F8380CBD3C996167F2F0E90E71B75\ +6C87EB62A4975356B28DCBF6A64A0BD107206D48FE6DBE19D50314B90AC87B83\ +35706F9B26007071AD8105CFAA1C1E2FF7FEAE5CEC4D11477F24E6B200906870\ +3C0E29E2950F2AC2DACD63DEEB5C7EFA9FDB9F3B740563D5518287DC981FC9CB\ +46D4B5A5A86FEC08FE70D18297DCF51072DDBE038DA040EBB12C509F5940A212\ +DDEB59F02132BE4581FC23EABAA960D6341D9352E36DFD6E4EAF0F6F439BC8CE\ +73A9AB3164FF30350F2DC08E939A104D6DF0C2C28F8E2D44468A61278BB6B429\ +4DAE45AE0CAA032FC97CD4D8C57FB83BBA8AFCAE22070BC882D3A42B38A09E65:\ +D29D576FCEA3A3A7ED9099F29273D78E2D62A890CEA3A3A7ED9099F29273D78E\ +D29D576F315C5C58ED9099F29273D78E2D62A890315C5C58ED9099F29273D78E\ +D29D576FCEA3A3A7126F660D9273D78E2D62A890CEA3A3A7126F660D9273D78E\ +D29D576F315C5C58126F660D9273D78E2D62A890315C5C58126F660D9273D78E\ +D29D576FCEA3A3A7ED9099F26D8C28712D62A890CEA3A3A7ED9099F26D8C2871\ +D29D576F315C5C58ED9099F26D8C28712D62A890315C5C58ED9099F26D8C2871\ +D29D576FCEA3A3A7126F660D6D8C28712D62A890CEA3A3A7126F660D6D8C2871\ +D29D576F315C5C58126F660D6D8C28712D62A890315C5C58126F660D6D8C2871\ +AA26D561F567520E8AE47528C24C18D731A2193D9A97FED6922B17AAA6372B74\ +BE5DEBD559E303C9C92B174A5107BBFEB626D8F65EDCCDF3AEE475C8A1837722\ +41DDE7C1F1631F5FDED4F42746471BD651D238BA86176EFE39E4695AAEB73B52\ +EA5926CADAD8018962E469BA920CB8BF1EA9062E4D9CEDD5FAD4F4C7990367A4\ +B966E5C5D2277288C61B96A559CC84AFB6A6583C5AACFCD6212B0BD8AEF3C6A9\ +A11DDBD175639341052B0B384678D8D9352299B71DD880E29D1B96452DB86540:\ +00000000000000000000000000000000 + [RC5(8)/CBC/PKCS7] 7875DBF6738C64788F34C3C681C99695:FFFFFFFFFFFFFFFF:0102030405:0000000000000000 7875DBF6738C64787CB3F1DF34F948117FD1A023A5BBA217:\ diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index e4ab0f44b..bd900d412 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -22,6 +22,12 @@ #define BOTAN_KARAT_SQR_THRESHOLD 32 #define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64 +/* Toggles for parallel block cipher mode processing */ +#define BOTAN_PARALLEL_BLOCKS_ECB 8 +#define BOTAN_PARALLEL_BLOCKS_CTR 8 +#define BOTAN_PARALLEL_BLOCKS_EAX 8 +#define BOTAN_PARALLEL_BLOCKS_XTS 8 + /* PK key consistency checking toggles */ #define BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD 1 #define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD 1 diff --git a/src/codec/openpgp/openpgp.cpp b/src/codec/openpgp/openpgp.cpp index 7f9cf5f9c..bfba828af 100644 --- a/src/codec/openpgp/openpgp.cpp +++ b/src/codec/openpgp/openpgp.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/src/filters/algo_filt.cpp b/src/filters/algo_filt.cpp index 23f7a20cf..3268276a6 100644 --- a/src/filters/algo_filt.cpp +++ b/src/filters/algo_filt.cpp @@ -18,7 +18,7 @@ StreamCipher_Filter::StreamCipher_Filter(const std::string& sc_name) : buffer(DEFAULT_BUFFERSIZE) { Algorithm_Factory& af = global_state().algorithm_factory(); - base_ptr = cipher = af.make_stream_cipher(sc_name); + cipher = af.make_stream_cipher(sc_name); } /* @@ -27,7 +27,7 @@ StreamCipher_Filter::StreamCipher_Filter(const std::string& sc_name) : StreamCipher_Filter::StreamCipher_Filter(StreamCipher* stream_cipher) : buffer(DEFAULT_BUFFERSIZE) { - base_ptr = cipher = stream_cipher; + cipher = stream_cipher; } /* @@ -38,7 +38,7 @@ StreamCipher_Filter::StreamCipher_Filter(const std::string& sc_name, buffer(DEFAULT_BUFFERSIZE) { Algorithm_Factory& af = global_state().algorithm_factory(); - base_ptr = cipher = af.make_stream_cipher(sc_name); + cipher = af.make_stream_cipher(sc_name); cipher->set_key(key); } @@ -95,7 +95,7 @@ MAC_Filter::MAC_Filter(const std::string& mac_name, u32bit len) : OUTPUT_LENGTH(len) { Algorithm_Factory& af = global_state().algorithm_factory(); - base_ptr = mac = af.make_mac(mac_name); + mac = af.make_mac(mac_name); } /* @@ -105,7 +105,7 @@ MAC_Filter::MAC_Filter(const std::string& mac_name, const SymmetricKey& key, u32bit len) : OUTPUT_LENGTH(len) { Algorithm_Factory& af = global_state().algorithm_factory(); - base_ptr = mac = af.make_mac(mac_name); + mac = af.make_mac(mac_name); mac->set_key(key); } diff --git a/src/filters/basefilt.cpp b/src/filters/basefilt.cpp index 02dbd8a73..c91a5aa62 100644 --- a/src/filters/basefilt.cpp +++ b/src/filters/basefilt.cpp @@ -50,25 +50,4 @@ Fork::Fork(Filter* filters[], u32bit count) set_next(filters, count); } -/* -* Set the algorithm key -*/ -void Keyed_Filter::set_key(const SymmetricKey& key) - { - if(base_ptr) - base_ptr->set_key(key); - else - throw Invalid_State("Keyed_Filter::set_key: No base algorithm set"); - } - -/* -* Check if a keylength is valid -*/ -bool Keyed_Filter::valid_keylength(u32bit n) const - { - if(base_ptr) - return base_ptr->valid_keylength(n); - throw Invalid_State("Keyed_Filter::valid_keylength: No base algorithm set"); - } - } diff --git a/src/filters/basefilt.h b/src/filters/basefilt.h index 75625abb0..348ad6fd3 100644 --- a/src/filters/basefilt.h +++ b/src/filters/basefilt.h @@ -9,7 +9,6 @@ #define BOTAN_BASEFILT_H__ #include -#include namespace Botan { @@ -62,38 +61,6 @@ class BOTAN_DLL Fork : public Fanout_Filter Fork(Filter* filter_arr[], u32bit length); }; -/** -* This class represents keyed filters, i.e. filters that have to be -* fed with a key in order to function. -*/ -class BOTAN_DLL Keyed_Filter : public Filter - { - public: - - /** - * Set the key of this filter. - * @param key the key to set - */ - virtual void set_key(const SymmetricKey& key); - - /** - * Set the initialization vector of this filter. - * @param iv the initialization vector to set - */ - virtual void set_iv(const InitializationVector&) {} - - /** - * Check whether a key length is valid for this filter. - * @param length the key length to be checked for validity - * @return true if the key length is valid, false otherwise - */ - virtual bool valid_keylength(u32bit length) const; - - Keyed_Filter() { base_ptr = 0; } - protected: - SymmetricAlgorithm* base_ptr; - }; - } #endif diff --git a/src/filters/filters.h b/src/filters/filters.h index 725651f7d..26de6e63c 100644 --- a/src/filters/filters.h +++ b/src/filters/filters.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -35,6 +35,13 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter { public: + /** + * Write input data + * @param input data + * @param input_len length of input in bytes + */ + void write(const byte input[], u32bit input_len); + /** * Seek in the stream. * @param position the position to seek ahead @@ -53,7 +60,20 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter * @param iv the initialization vector to set */ void set_iv(const InitializationVector& iv); - void write(const byte[], u32bit); + + /** + * Set the key of this filter. + * @param key the key to set + */ + void set_key(const SymmetricKey& key) { cipher->set_key(key); } + + /** + * Check whether a key length is valid for this filter. + * @param length the key length to be checked for validity + * @return true if the key length is valid, false otherwise + */ + bool valid_keylength(u32bit length) const + { return cipher->valid_keylength(length); } /** * Construct a stream cipher filter. @@ -125,6 +145,20 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter void write(const byte input[], u32bit len) { mac->update(input, len); } void end_msg(); + /** + * Set the key of this filter. + * @param key the key to set + */ + void set_key(const SymmetricKey& key) { mac->set_key(key); } + + /** + * Check whether a key length is valid for this filter. + * @param length the key length to be checked for validity + * @return true if the key length is valid, false otherwise + */ + bool valid_keylength(u32bit length) const + { return mac->valid_keylength(length); } + /** * Construct a MAC filter. The MAC key will be left empty. * @param mac the MAC to use @@ -136,7 +170,7 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter MAC_Filter(MessageAuthenticationCode* mac_obj, u32bit out_len = 0) : OUTPUT_LENGTH(out_len) { - base_ptr = mac = mac_obj; + mac = mac_obj; } /** @@ -152,7 +186,7 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter const SymmetricKey& key, u32bit out_len = 0) : OUTPUT_LENGTH(out_len) { - base_ptr = mac = mac_obj; + mac = mac_obj; mac->set_key(key); } diff --git a/src/filters/info.txt b/src/filters/info.txt index 79a92a9c5..fb8108659 100644 --- a/src/filters/info.txt +++ b/src/filters/info.txt @@ -17,6 +17,7 @@ data_src.h filter.cpp filter.h filters.h +key_filt.h out_buf.cpp out_buf.h pbe.h diff --git a/src/filters/key_filt.h b/src/filters/key_filt.h new file mode 100644 index 000000000..36af91f88 --- /dev/null +++ b/src/filters/key_filt.h @@ -0,0 +1,45 @@ +/* +* Keyed_Filter +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KEYED_FILTER_H__ +#define BOTAN_KEYED_FILTER_H__ + +#include +#include + +namespace Botan { + +/** +* This class represents keyed filters, i.e. filters that have to be +* fed with a key in order to function. +*/ +class BOTAN_DLL Keyed_Filter : public Filter + { + public: + /** + * Set the key of this filter. + * @param key the key to set + */ + virtual void set_key(const SymmetricKey& key) = 0; + + /** + * Set the initialization vector of this filter. + * @param iv the initialization vector to set + */ + virtual void set_iv(const InitializationVector&) {} + + /** + * Check whether a key length is valid for this filter. + * @param length the key length to be checked for validity + * @return true if the key length is valid, false otherwise + */ + virtual bool valid_keylength(u32bit length) const = 0; + }; + +} + +#endif diff --git a/src/modes/ctr/ctr.cpp b/src/modes/ctr/ctr.cpp index 5c27ca63c..a3476c474 100644 --- a/src/modes/ctr/ctr.cpp +++ b/src/modes/ctr/ctr.cpp @@ -11,16 +11,21 @@ namespace Botan { +namespace { + +const u32bit PARALLEL_BLOCKS = BOTAN_PARALLEL_BLOCKS_CTR; + +} + /* * CTR-BE Constructor */ CTR_BE::CTR_BE(BlockCipher* ciph) : cipher(ciph) { - base_ptr = cipher; position = 0; - counter.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); - enc_buffer.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); + counter.create(ciph->BLOCK_SIZE * PARALLEL_BLOCKS); + enc_buffer.create(ciph->BLOCK_SIZE * PARALLEL_BLOCKS); } /* @@ -30,13 +35,12 @@ CTR_BE::CTR_BE(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv) : cipher(ciph) { - base_ptr = cipher; position = 0; - counter.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); - enc_buffer.create(ciph->BLOCK_SIZE * CTR_BLOCKS_PARALLEL); + counter.create(ciph->BLOCK_SIZE * PARALLEL_BLOCKS); + enc_buffer.create(ciph->BLOCK_SIZE * PARALLEL_BLOCKS); - set_key(key); + cipher->set_key(key); set_iv(iv); } @@ -67,7 +71,7 @@ void CTR_BE::set_iv(const InitializationVector& iv) enc_buffer.clear(); position = 0; - for(u32bit i = 0; i != CTR_BLOCKS_PARALLEL; ++i) + for(u32bit i = 0; i != PARALLEL_BLOCKS; ++i) { counter.copy(i*cipher->BLOCK_SIZE, iv.begin(), iv.length()); @@ -78,7 +82,7 @@ void CTR_BE::set_iv(const InitializationVector& iv) break; } - cipher->encrypt_n(counter, enc_buffer, CTR_BLOCKS_PARALLEL); + cipher->encrypt_n(counter, enc_buffer, PARALLEL_BLOCKS); } /* @@ -116,24 +120,24 @@ void CTR_BE::write(const byte input[], u32bit length) */ void CTR_BE::increment_counter() { - for(u32bit i = 0; i != CTR_BLOCKS_PARALLEL; ++i) + for(u32bit i = 0; i != PARALLEL_BLOCKS; ++i) { // FIXME: Can do it in a single loop /* for(u32bit j = 1; j != cipher->BLOCK_SIZE; ++j) { byte carry = 0; - byte z = counter[(i+1)*cipher->BLOCK_SIZE-1] + CTR_BLOCKS_PARALLEL; + byte z = counter[(i+1)*cipher->BLOCK_SIZE-1] + PARALLEL_BLOCKS; if( */ - for(u32bit j = 0; j != CTR_BLOCKS_PARALLEL; ++j) + for(u32bit j = 0; j != PARALLEL_BLOCKS; ++j) for(s32bit k = cipher->BLOCK_SIZE - 1; k >= 0; --k) if(++counter[i*cipher->BLOCK_SIZE+k]) break; } - cipher->encrypt_n(counter, enc_buffer, CTR_BLOCKS_PARALLEL); + cipher->encrypt_n(counter, enc_buffer, PARALLEL_BLOCKS); position = 0; } diff --git a/src/modes/ctr/ctr.h b/src/modes/ctr/ctr.h index 3d509f02c..1948ffe48 100644 --- a/src/modes/ctr/ctr.h +++ b/src/modes/ctr/ctr.h @@ -8,7 +8,7 @@ #ifndef BOTAN_COUNTER_MODE_H__ #define BOTAN_COUNTER_MODE_H__ -#include +#include #include namespace Botan { @@ -20,15 +20,19 @@ class BOTAN_DLL CTR_BE : public Keyed_Filter { public: std::string name() const; + void set_iv(const InitializationVector&); + void set_key(const SymmetricKey& key) { cipher->set_key(key); } + + bool valid_keylength(u32bit key_len) const + { return cipher->valid_keylength(key_len); } + CTR_BE(BlockCipher*); CTR_BE(BlockCipher*, const SymmetricKey&, const InitializationVector&); ~CTR_BE(); private: - static const u32bit CTR_BLOCKS_PARALLEL = 8; - void write(const byte[], u32bit); void increment_counter(); diff --git a/src/modes/eax/eax.h b/src/modes/eax/eax.h index 1bb2e510d..f569f2ede 100644 --- a/src/modes/eax/eax.h +++ b/src/modes/eax/eax.h @@ -8,7 +8,7 @@ #ifndef BOTAN_EAX_H__ #define BOTAN_EAX_H__ -#include +#include #include #include diff --git a/src/modes/ecb/ecb.cpp b/src/modes/ecb/ecb.cpp index 8da0a4802..988a8b3f2 100644 --- a/src/modes/ecb/ecb.cpp +++ b/src/modes/ecb/ecb.cpp @@ -9,22 +9,60 @@ namespace Botan { +namespace { + +const u32bit PARALLEL_BLOCKS = BOTAN_PARALLEL_BLOCKS_ECB; + +} + /* -* Verify the IV is not set +* ECB_Encryption Constructor */ -bool ECB::valid_iv_size(u32bit iv_size) const +ECB_Encryption::ECB_Encryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad) { - if(iv_size == 0) - return true; - return false; + cipher = ciph; + padder = pad; + + plaintext.create(cipher->BLOCK_SIZE); + ciphertext.create(cipher->BLOCK_SIZE * PARALLEL_BLOCKS); + + position = 0; + } + +/* +* ECB_Encryption Constructor +*/ +ECB_Encryption::ECB_Encryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad, + const SymmetricKey& key) + { + cipher = ciph; + padder = pad; + + plaintext.create(cipher->BLOCK_SIZE); + ciphertext.create(cipher->BLOCK_SIZE * PARALLEL_BLOCKS); + + position = 0; + + cipher->set_key(key); + } + +/* +* ECB_Encryption Destructor +*/ +ECB_Encryption::~ECB_Encryption() + { + delete cipher; + delete padder; } /* * Return an ECB mode name */ -std::string ECB::name() const +std::string ECB_Encryption::name() const { - return (cipher->name() + "/" + mode_name + "/" + padder->name()); + return (cipher->name() + "/ECB/" + padder->name()); } /* @@ -32,23 +70,34 @@ std::string ECB::name() const */ void ECB_Encryption::write(const byte input[], u32bit length) { - buffer.copy(position, input, length); - if(position + length >= BLOCK_SIZE) + const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE; + + if(position) { - cipher->encrypt(buffer); - send(buffer, BLOCK_SIZE); - input += (BLOCK_SIZE - position); - length -= (BLOCK_SIZE - position); - while(length >= BLOCK_SIZE) + plaintext.copy(position, input, length); + + if(position + length >= BLOCK_SIZE) { - cipher->encrypt(input, buffer); - send(buffer, BLOCK_SIZE); - input += BLOCK_SIZE; - length -= BLOCK_SIZE; + cipher->encrypt(plaintext, ciphertext); + send(ciphertext, BLOCK_SIZE); + input += (BLOCK_SIZE - position); + length -= (BLOCK_SIZE - position); + position = 0; } - buffer.copy(input, length); - position = 0; } + + while(length >= BLOCK_SIZE) + { + const u32bit to_proc = + std::min(length, ciphertext.size()) / BLOCK_SIZE; + + cipher->encrypt_n(input, ciphertext, to_proc); + send(ciphertext, to_proc * BLOCK_SIZE); + input += to_proc * BLOCK_SIZE; + length -= to_proc * BLOCK_SIZE; + } + + plaintext.copy(position, input, length); position += length; } @@ -57,6 +106,8 @@ void ECB_Encryption::write(const byte input[], u32bit length) */ void ECB_Encryption::end_msg() { + const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE; + SecureVector padding(BLOCK_SIZE); padder->pad(padding, padding.size(), position); write(padding, padder->pad_bytes(BLOCK_SIZE, position)); @@ -64,28 +115,94 @@ void ECB_Encryption::end_msg() throw Encoding_Error(name() + ": Did not pad to full blocksize"); } +/* +* ECB_Decryption Constructor +*/ +ECB_Decryption::ECB_Decryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad) + { + cipher = ciph; + padder = pad; + + ciphertext.create(cipher->BLOCK_SIZE); + plaintext.create(cipher->BLOCK_SIZE * PARALLEL_BLOCKS); + + position = 0; + } + +/* +* ECB_Decryption Constructor +*/ +ECB_Decryption::ECB_Decryption(BlockCipher* ciph, + BlockCipherModePaddingMethod* pad, + const SymmetricKey& key) + { + cipher = ciph; + padder = pad; + + ciphertext.create(cipher->BLOCK_SIZE); + plaintext.create(cipher->BLOCK_SIZE * PARALLEL_BLOCKS); + + position = 0; + + cipher->set_key(key); + } + +/* +* ECB_Decryption Destructor +*/ +ECB_Decryption::~ECB_Decryption() + { + delete cipher; + delete padder; + } + +/* +* Return an ECB mode name +*/ +std::string ECB_Decryption::name() const + { + return (cipher->name() + "/ECB/" + padder->name()); + } + /* * Decrypt in ECB mode */ void ECB_Decryption::write(const byte input[], u32bit length) { - buffer.copy(position, input, length); - if(position + length > BLOCK_SIZE) + const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE; + + if(position) { - cipher->decrypt(buffer); - send(buffer, BLOCK_SIZE); - input += (BLOCK_SIZE - position); - length -= (BLOCK_SIZE - position); - while(length > BLOCK_SIZE) + ciphertext.copy(position, input, length); + + if(position + length > BLOCK_SIZE) { - cipher->decrypt(input, buffer); - send(buffer, BLOCK_SIZE); - input += BLOCK_SIZE; - length -= BLOCK_SIZE; + cipher->decrypt(ciphertext, plaintext); + send(plaintext, BLOCK_SIZE); + input += (BLOCK_SIZE - position); + length -= (BLOCK_SIZE - position); + position = 0; } - buffer.copy(input, length); - position = 0; } + + while(length > BLOCK_SIZE) + { + /* Always leave at least 1 byte left over, to ensure that (as long + as the input message actually is a multiple of the block size) + we will have the full final block left over in end_msg so as + to remove the padding + */ + const u32bit to_proc = + std::min(length - 1, plaintext.size()) / BLOCK_SIZE; + + cipher->decrypt_n(input, plaintext, to_proc); + send(plaintext, to_proc * BLOCK_SIZE); + input += to_proc * BLOCK_SIZE; + length -= to_proc * BLOCK_SIZE; + } + + ciphertext.copy(position, input, length); position += length; } @@ -94,11 +211,11 @@ void ECB_Decryption::write(const byte input[], u32bit length) */ void ECB_Decryption::end_msg() { - if(position != BLOCK_SIZE) + if(position != cipher->BLOCK_SIZE) throw Decoding_Error(name()); - cipher->decrypt(buffer); - send(buffer, padder->unpad(buffer, BLOCK_SIZE)); - state = buffer; + + cipher->decrypt(ciphertext); + send(ciphertext, padder->unpad(ciphertext, cipher->BLOCK_SIZE)); position = 0; } diff --git a/src/modes/ecb/ecb.h b/src/modes/ecb/ecb.h index 5230f9b14..ff9ea9635 100644 --- a/src/modes/ecb/ecb.h +++ b/src/modes/ecb/ecb.h @@ -1,6 +1,6 @@ /* * ECB Mode -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -8,64 +8,74 @@ #ifndef BOTAN_ECB_H__ #define BOTAN_ECB_H__ -#include -#include +#include #include +#include -namespace Botan { - -/* -* ECB -*/ -class BOTAN_DLL ECB : public BlockCipherMode - { - protected: - ECB(BlockCipher* ciph, BlockCipherModePaddingMethod* pad) : - BlockCipherMode(ciph, "ECB", 0), padder(pad) {} - ~ECB() { delete padder; } +#include - std::string name() const; - BlockCipherModePaddingMethod* padder; - private: - bool valid_iv_size(u32bit) const; - }; +namespace Botan { /* * ECB Encryption */ -class BOTAN_DLL ECB_Encryption : public ECB +class BOTAN_DLL ECB_Encryption : public Keyed_Filter { public: + std::string name() const; + + void set_key(const SymmetricKey& key) { cipher->set_key(key); } + + bool valid_keylength(u32bit key_len) const + { return cipher->valid_keylength(key_len); } + ECB_Encryption(BlockCipher* ciph, - BlockCipherModePaddingMethod* pad) : - ECB(ciph, pad) {} + BlockCipherModePaddingMethod* pad); ECB_Encryption(BlockCipher* ciph, BlockCipherModePaddingMethod* pad, - const SymmetricKey& key) : - ECB(ciph, pad) { set_key(key); } + const SymmetricKey& key); + + ~ECB_Encryption(); private: void write(const byte[], u32bit); void end_msg(); + + BlockCipher* cipher; + BlockCipherModePaddingMethod* padder; + SecureVector plaintext, ciphertext; + u32bit position; }; /* * ECB Decryption */ -class BOTAN_DLL ECB_Decryption : public ECB +class BOTAN_DLL ECB_Decryption : public Keyed_Filter { public: + std::string name() const; + + void set_key(const SymmetricKey& key) { cipher->set_key(key); } + + bool valid_keylength(u32bit key_len) const + { return cipher->valid_keylength(key_len); } + ECB_Decryption(BlockCipher* ciph, - BlockCipherModePaddingMethod* pad) : - ECB(ciph, pad) {} + BlockCipherModePaddingMethod* pad); ECB_Decryption(BlockCipher* ciph, BlockCipherModePaddingMethod* pad, - const SymmetricKey& key) : - ECB(ciph, pad) { set_key(key); } + const SymmetricKey& key); + + ~ECB_Decryption(); private: void write(const byte[], u32bit); void end_msg(); + + BlockCipher* cipher; + BlockCipherModePaddingMethod* padder; + SecureVector plaintext, ciphertext; + u32bit position; }; } diff --git a/src/modes/modebase.cpp b/src/modes/modebase.cpp index 8293acc54..b048862a4 100644 --- a/src/modes/modebase.cpp +++ b/src/modes/modebase.cpp @@ -19,7 +19,7 @@ BlockCipherMode::BlockCipherMode(BlockCipher* cipher_ptr, BLOCK_SIZE(cipher_ptr->BLOCK_SIZE), BUFFER_SIZE(buf_mult * BLOCK_SIZE), IV_METHOD(iv_meth), mode_name(cipher_mode_name) { - base_ptr = cipher = cipher_ptr; + cipher = cipher_ptr; buffer.create(BUFFER_SIZE); state.create(iv_size); position = 0; diff --git a/src/modes/modebase.h b/src/modes/modebase.h index 173fde58c..4a15524b6 100644 --- a/src/modes/modebase.h +++ b/src/modes/modebase.h @@ -8,7 +8,7 @@ #ifndef BOTAN_MODEBASE_H__ #define BOTAN_MODEBASE_H__ -#include +#include #include namespace Botan { @@ -21,12 +21,17 @@ class BOTAN_DLL BlockCipherMode : public Keyed_Filter public: std::string name() const; + void set_iv(const InitializationVector&); + void set_key(const SymmetricKey& key) { cipher->set_key(key); } + + bool valid_keylength(u32bit key_len) const + { return cipher->valid_keylength(key_len); } + BlockCipherMode(BlockCipher*, const std::string&, u32bit, u32bit = 0, u32bit = 1); virtual ~BlockCipherMode() { delete cipher; } protected: - void set_iv(const InitializationVector&); const u32bit BLOCK_SIZE, BUFFER_SIZE, IV_METHOD; const std::string mode_name; BlockCipher* cipher; diff --git a/src/modes/xts/xts.h b/src/modes/xts/xts.h index 01558175b..9badd3666 100644 --- a/src/modes/xts/xts.h +++ b/src/modes/xts/xts.h @@ -8,7 +8,7 @@ #ifndef BOTAN_XTS_H__ #define BOTAN_XTS_H__ -#include +#include #include namespace Botan { @@ -22,6 +22,9 @@ class BOTAN_DLL XTS_Encryption : public Keyed_Filter void set_key(const SymmetricKey& key); void set_iv(const InitializationVector& iv); + bool valid_keylength(u32bit key_len) const + { return cipher->valid_keylength(key_len); } + std::string name() const; XTS_Encryption(BlockCipher* ciph); @@ -52,6 +55,9 @@ class BOTAN_DLL XTS_Decryption : public Keyed_Filter void set_key(const SymmetricKey& key); void set_iv(const InitializationVector& iv); + bool valid_keylength(u32bit key_len) const + { return cipher->valid_keylength(key_len); } + std::string name() const; XTS_Decryption(BlockCipher* ciph); -- cgit v1.2.3 From c8c3d7f6eecd753aa87a882b1458346682e606db Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 11 Aug 2009 19:34:50 +0000 Subject: Make encrypt_n public for all BlockCipher implementations - unlike the enc/dec functions it replaces, these are public interfaces. Add the first bits of a SSE2 implementation of Serpent. Currently incomplete. --- src/block/aes/aes.h | 6 +- src/block/blowfish/blowfish.h | 6 +- src/block/cast/cast128.h | 6 +- src/block/cast/cast256.h | 6 +- src/block/des/des.h | 12 ++- src/block/des/desx.h | 6 +- src/block/gost_28147/gost_28147.h | 5 +- src/block/idea/idea.h | 6 +- src/block/kasumi/kasumi.h | 5 +- src/block/lion/lion.h | 5 +- src/block/lubyrack/lubyrack.h | 6 +- src/block/mars/mars.h | 6 +- src/block/misty1/misty1.h | 6 +- src/block/noekeon/noekeon.h | 6 +- src/block/rc2/rc2.h | 6 +- src/block/rc5/rc5.h | 6 +- src/block/rc6/rc6.h | 6 +- src/block/safer/safer_sk.h | 7 +- src/block/seed/seed.h | 6 +- src/block/serpent/serpent.h | 5 +- src/block/serpent_ia32/serp_ia32.h | 5 +- src/block/serpent_sse2/info.txt | 27 ++++++ src/block/serpent_sse2/serp_sse2.cpp | 170 +++++++++++++++++++++++++++++++++++ src/block/serpent_sse2/serp_sse2.h | 29 ++++++ src/block/skipjack/skipjack.h | 7 +- src/block/square/square.h | 6 +- src/block/tea/tea.h | 6 +- src/block/twofish/twofish.h | 6 +- src/block/xtea/xtea.h | 6 +- src/engine/sse2_eng/eng_sse2.cpp | 23 ++++- src/engine/sse2_eng/eng_sse2.h | 5 +- 31 files changed, 355 insertions(+), 58 deletions(-) create mode 100644 src/block/serpent_sse2/info.txt create mode 100644 src/block/serpent_sse2/serp_sse2.cpp create mode 100644 src/block/serpent_sse2/serp_sse2.h (limited to 'src') diff --git a/src/block/aes/aes.h b/src/block/aes/aes.h index 940e11a48..768bb09e7 100644 --- a/src/block/aes/aes.h +++ b/src/block/aes/aes.h @@ -18,14 +18,16 @@ namespace Botan { class BOTAN_DLL AES : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const { return "AES"; } BlockCipher* clone() const { return new AES; } + AES() : BlockCipher(16, 16, 32, 8) { ROUNDS = 14; } AES(u32bit); private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static u32bit S(u32bit); diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h index 3623c2087..345c1ce49 100644 --- a/src/block/blowfish/blowfish.h +++ b/src/block/blowfish/blowfish.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL Blowfish : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const { return "Blowfish"; } BlockCipher* clone() const { return new Blowfish; } + Blowfish() : BlockCipher(8, 1, 56) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); void generate_sbox(u32bit[], u32bit, u32bit&, u32bit&) const; diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h index 092ee824b..864a4e47e 100644 --- a/src/block/cast/cast128.h +++ b/src/block/cast/cast128.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL CAST_128 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { MK.clear(); RK.clear(); } std::string name() const { return "CAST-128"; } BlockCipher* clone() const { return new CAST_128; } + CAST_128() : BlockCipher(8, 11, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static void key_schedule(u32bit[16], u32bit[4]); diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h index ea80df65d..1be7fa9cf 100644 --- a/src/block/cast/cast256.h +++ b/src/block/cast/cast256.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL CAST_256 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { MK.clear(); RK.clear(); } std::string name() const { return "CAST-256"; } BlockCipher* clone() const { return new CAST_256; } + CAST_256() : BlockCipher(16, 4, 32, 4) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static const u32bit KEY_MASK[192]; diff --git a/src/block/des/des.h b/src/block/des/des.h index 39d1ac404..856aaf60c 100644 --- a/src/block/des/des.h +++ b/src/block/des/des.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL DES : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { round_key.clear(); } std::string name() const { return "DES"; } BlockCipher* clone() const { return new DES; } + DES() : BlockCipher(8, 8) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer round_key; @@ -36,13 +38,15 @@ class BOTAN_DLL DES : public BlockCipher class BOTAN_DLL TripleDES : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { round_key.clear(); } std::string name() const { return "TripleDES"; } BlockCipher* clone() const { return new TripleDES; } + TripleDES() : BlockCipher(8, 16, 24, 8) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer round_key; diff --git a/src/block/des/desx.h b/src/block/des/desx.h index d71335071..d22895296 100644 --- a/src/block/des/desx.h +++ b/src/block/des/desx.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL DESX : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { des.clear(); K1.clear(); K2.clear(); } std::string name() const { return "DESX"; } BlockCipher* clone() const { return new DESX; } + DESX() : BlockCipher(8, 24) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer K1, K2; DES des; diff --git a/src/block/gost_28147/gost_28147.h b/src/block/gost_28147/gost_28147.h index 825e106a2..18c1d0a29 100644 --- a/src/block/gost_28147/gost_28147.h +++ b/src/block/gost_28147/gost_28147.h @@ -44,6 +44,9 @@ class GOST_28147_89_Params class BOTAN_DLL GOST_28147_89 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); } std::string name() const { return "GOST-28147-89"; } @@ -54,8 +57,6 @@ class BOTAN_DLL GOST_28147_89 : public BlockCipher GOST_28147_89(const SecureBuffer& other_SBOX) : BlockCipher(8, 32), SBOX(other_SBOX) {} - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer SBOX; diff --git a/src/block/idea/idea.h b/src/block/idea/idea.h index a3384b667..59484531b 100644 --- a/src/block/idea/idea.h +++ b/src/block/idea/idea.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL IDEA : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); DK.clear(); } std::string name() const { return "IDEA"; } BlockCipher* clone() const { return new IDEA; } + IDEA() : BlockCipher(8, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK, DK; }; diff --git a/src/block/kasumi/kasumi.h b/src/block/kasumi/kasumi.h index 3b18e675b..0f5a5d182 100644 --- a/src/block/kasumi/kasumi.h +++ b/src/block/kasumi/kasumi.h @@ -18,14 +18,15 @@ namespace Botan { class BOTAN_DLL KASUMI : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); } std::string name() const { return "KASUMI"; } BlockCipher* clone() const { return new KASUMI; } KASUMI() : BlockCipher(8, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK; diff --git a/src/block/lion/lion.h b/src/block/lion/lion.h index d9f933846..d421771d6 100644 --- a/src/block/lion/lion.h +++ b/src/block/lion/lion.h @@ -20,6 +20,9 @@ namespace Botan { class BOTAN_DLL Lion : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const; BlockCipher* clone() const; @@ -27,8 +30,6 @@ class BOTAN_DLL Lion : public BlockCipher Lion(HashFunction*, StreamCipher*, u32bit); ~Lion() { delete hash; delete cipher; } private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); const u32bit LEFT_SIZE, RIGHT_SIZE; diff --git a/src/block/lubyrack/lubyrack.h b/src/block/lubyrack/lubyrack.h index 1e83748a6..940b34603 100644 --- a/src/block/lubyrack/lubyrack.h +++ b/src/block/lubyrack/lubyrack.h @@ -19,6 +19,9 @@ namespace Botan { class BOTAN_DLL LubyRackoff : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const; BlockCipher* clone() const; @@ -26,9 +29,8 @@ class BOTAN_DLL LubyRackoff : public BlockCipher LubyRackoff(HashFunction* hash); ~LubyRackoff() { delete hash; } private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); + HashFunction* hash; SecureVector K1, K2; }; diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h index b3d74b179..7d0bfe4fa 100644 --- a/src/block/mars/mars.h +++ b/src/block/mars/mars.h @@ -15,13 +15,15 @@ namespace Botan { class BOTAN_DLL MARS : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); } std::string name() const { return "MARS"; } BlockCipher* clone() const { return new MARS; } + MARS() : BlockCipher(16, 16, 32, 4) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); void encrypt_round(u32bit&, u32bit&, u32bit&, u32bit&, u32bit) const; diff --git a/src/block/misty1/misty1.h b/src/block/misty1/misty1.h index 14b7c8e45..8db6881de 100644 --- a/src/block/misty1/misty1.h +++ b/src/block/misty1/misty1.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL MISTY1 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); DK.clear(); } std::string name() const { return "MISTY1"; } BlockCipher* clone() const { return new MISTY1; } + MISTY1(u32bit = 8); private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK, DK; diff --git a/src/block/noekeon/noekeon.h b/src/block/noekeon/noekeon.h index b4f3980d7..37b24fb7d 100644 --- a/src/block/noekeon/noekeon.h +++ b/src/block/noekeon/noekeon.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL Noekeon : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const { return "Noekeon"; } BlockCipher* clone() const { return new Noekeon; } + Noekeon() : BlockCipher(16, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static const byte RC[17]; diff --git a/src/block/rc2/rc2.h b/src/block/rc2/rc2.h index 0d94d69a2..db623b385 100644 --- a/src/block/rc2/rc2.h +++ b/src/block/rc2/rc2.h @@ -18,15 +18,17 @@ namespace Botan { class BOTAN_DLL RC2 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + static byte EKB_code(u32bit); void clear() throw() { K.clear(); } std::string name() const { return "RC2"; } BlockCipher* clone() const { return new RC2; } + RC2() : BlockCipher(8, 1, 32) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer K; diff --git a/src/block/rc5/rc5.h b/src/block/rc5/rc5.h index 1816994dc..ff9204710 100644 --- a/src/block/rc5/rc5.h +++ b/src/block/rc5/rc5.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL RC5 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { S.clear(); } std::string name() const; BlockCipher* clone() const { return new RC5(ROUNDS); } + RC5(u32bit); private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureVector S; const u32bit ROUNDS; diff --git a/src/block/rc6/rc6.h b/src/block/rc6/rc6.h index f634ebcd9..5171006f5 100644 --- a/src/block/rc6/rc6.h +++ b/src/block/rc6/rc6.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL RC6 : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { S.clear(); } std::string name() const { return "RC6"; } BlockCipher* clone() const { return new RC6; } + RC6() : BlockCipher(16, 1, 32) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer S; diff --git a/src/block/safer/safer_sk.h b/src/block/safer/safer_sk.h index ae3d4f9a8..4d17bba51 100644 --- a/src/block/safer/safer_sk.h +++ b/src/block/safer/safer_sk.h @@ -18,19 +18,22 @@ namespace Botan { class BOTAN_DLL SAFER_SK : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); } std::string name() const; BlockCipher* clone() const; + SAFER_SK(u32bit); private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static const byte EXP[256]; static const byte LOG[512]; static const byte BIAS[208]; static const byte KEY_INDEX[208]; + SecureVector EK; const u32bit ROUNDS; }; diff --git a/src/block/seed/seed.h b/src/block/seed/seed.h index 0c9c2c8af..5a5a512e7 100644 --- a/src/block/seed/seed.h +++ b/src/block/seed/seed.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL SEED : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { K.clear(); } std::string name() const { return "SEED"; } BlockCipher* clone() const { return new SEED; } + SEED() : BlockCipher(16, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); class G_FUNC diff --git a/src/block/serpent/serpent.h b/src/block/serpent/serpent.h index 9c9fb59f2..d919c3008 100644 --- a/src/block/serpent/serpent.h +++ b/src/block/serpent/serpent.h @@ -18,13 +18,14 @@ namespace Botan { class BOTAN_DLL Serpent : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { round_key.clear(); } std::string name() const { return "Serpent"; } BlockCipher* clone() const { return new Serpent; } Serpent() : BlockCipher(16, 16, 32, 8) {} protected: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer round_key; diff --git a/src/block/serpent_ia32/serp_ia32.h b/src/block/serpent_ia32/serp_ia32.h index 2b4a95d3d..dc6beaf13 100644 --- a/src/block/serpent_ia32/serp_ia32.h +++ b/src/block/serpent_ia32/serp_ia32.h @@ -18,10 +18,11 @@ namespace Botan { class BOTAN_DLL Serpent_IA32 : public Serpent { public: - BlockCipher* clone() const { return new Serpent_IA32; } - private: void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + + BlockCipher* clone() const { return new Serpent_IA32; } + private: void key_schedule(const byte[], u32bit); }; diff --git a/src/block/serpent_sse2/info.txt b/src/block/serpent_sse2/info.txt new file mode 100644 index 000000000..ad8323f53 --- /dev/null +++ b/src/block/serpent_sse2/info.txt @@ -0,0 +1,27 @@ +realname "Serpent (SSE2)" + +define SERPENT_SSE2 + +load_on auto + + +serp_sse2.cpp +serp_sse2.h + + + +pentium-m +pentium4 +prescott +amd64 + + + +gcc +icc + + + +serpent +sse2_eng + diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_sse2/serp_sse2.cpp new file mode 100644 index 000000000..759f3e1d6 --- /dev/null +++ b/src/block/serpent_sse2/serp_sse2.cpp @@ -0,0 +1,170 @@ +/* +* Serpent (SSE2) +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include +#include + +namespace Botan { + +namespace { + +#define SBoxE1(b0, b1, b2, b3, b4) \ + do { \ + b3 = _mm_xor_si128(b3, b0); \ + b4 = b1; \ + b1 = _mm_and_si128(b1, b3); \ + b4 = _mm_xor_si128(b4, b2); \ + b1 = _mm_xor_si128(b1, b0); \ + b0 = _mm_or_si128(b0, b3); \ + b0 = _mm_xor_si128(b0, b4); \ + b4 = _mm_xor_si128(b4, b3); \ + b3 = _mm_xor_si128(b3, b2); \ + b2 = _mm_or_si128(b2, b1); \ + b2 = _mm_xor_si128(b2, b4); \ + b4 = _mm_andnot_si128(b4, all_ones); \ + b4 = _mm_or_si128(b4, b1); \ + b1 = _mm_xor_si128(b1, b3); \ + b1 = _mm_xor_si128(b1, b4); \ + b3 = _mm_or_si128(b3, b0); \ + b1 = _mm_xor_si128(b1, b3); \ + b4 = _mm_xor_si128(b4, b3); \ + b3 = b0; b0 = b1; b1 = b4; \ + } while(0); + +#define rotate_left_m128(vec, rot) \ + _mm_or_si128(_mm_slli_epi32(vec, rot), _mm_srli_epi32(vec, 32-rot)) + +#define key_xor(round, b0, b1, b2, b3) \ + do { \ + __m128i key = _mm_loadu_si128(keys + round); \ + b0 = _mm_xor_si128(b0, _mm_shuffle_epi32(key, _MM_SHUFFLE(0,0,0,0))); \ + b1 = _mm_xor_si128(b1, _mm_shuffle_epi32(key, _MM_SHUFFLE(1,1,1,1))); \ + b2 = _mm_xor_si128(b2, _mm_shuffle_epi32(key, _MM_SHUFFLE(2,2,2,2))); \ + b3 = _mm_xor_si128(b3, _mm_shuffle_epi32(key, _MM_SHUFFLE(3,3,3,3))); \ + } while(0); + +#define transform(b0, b1, b2, b3) \ + do \ + { \ + b0 = rotate_left_m128(b0, 13); \ + b2 = rotate_left_m128(b2, 3); \ + b1 = _mm_xor_si128(b1, _mm_xor_si128(b0, b2)); \ + b3 = _mm_xor_si128(b3, _mm_xor_si128(b2, _mm_slli_epi32(b0, 3))); \ + b1 = rotate_left_m128(b1, 1); \ + b3 = rotate_left_m128(b3, 7); \ + b0 = _mm_xor_si128(b0, _mm_xor_si128(b1, b3)); \ + b2 = _mm_xor_si128(b2, _mm_xor_si128(b3, _mm_slli_epi32(b1, 7))); \ + b0 = rotate_left_m128(b0, 5); \ + b2 = rotate_left_m128(b2, 22); \ + } while(0); + +void print_simd(const char* name, __m128i vec) + { + union { __m128i v; int32_t ints[4]; } u = { vec }; + + printf("%s: ", name); + for(u32bit i = 0; i != 4; ++i) + printf("%08X ", u.ints[i]); + printf("\n"); + } + +void serpent_encrypt_4(const byte in[64], + byte out[64], + const u32bit keys_32[132]) + { + const __m128i* keys = (const __m128i*)(keys_32); + + /* + FIXME: figure out a fast way to do this with 4 loads with + _mm_loadu_si128 plus shuffle/interleave ops + */ + union { __m128i v; u32bit u32[4]; } convert; + + convert.u32[0] = load_le(in, 0); + convert.u32[1] = load_le(in, 4); + convert.u32[2] = load_le(in, 8); + convert.u32[3] = load_le(in, 12); + + __m128i b0 = convert.v; + + convert.u32[0] = load_le(in, 1); + convert.u32[1] = load_le(in, 5); + convert.u32[2] = load_le(in, 9); + convert.u32[3] = load_le(in, 13); + + __m128i b1 = convert.v; + + convert.u32[0] = load_le(in, 2); + convert.u32[1] = load_le(in, 6); + convert.u32[2] = load_le(in, 10); + convert.u32[3] = load_le(in, 14); + + __m128i b2 = convert.v; + + convert.u32[0] = load_le(in, 3); + convert.u32[1] = load_le(in, 7); + convert.u32[2] = load_le(in, 11); + convert.u32[3] = load_le(in, 15); + + + __m128i b3 = convert.v; + + __m128i b4; // temp + + const __m128i all_ones = _mm_set1_epi8(0xFF); + + key_xor(0, b0, b1, b2, b3); + SBoxE1(b0, b1, b2, b3, b4); + transform(b0, b1, b2, b3); + + key_xor(b0, b1, b2, b3, 1); + + print_simd("b0", b0); + print_simd("b1", b1); + print_simd("b2", b2); + print_simd("b3", b3); + } + +} + +/* +* Serpent Encryption +*/ +void Serpent_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const + { + while(blocks >= 4) + { + serpent_encrypt_4(in, out, this->round_key); + //Serpent::encrypt_n(in, out, 4); + in += 4 * BLOCK_SIZE; + out += 4 * BLOCK_SIZE; + blocks -= 4; + } + + for(u32bit i = 0; i != blocks; ++i) + { + Serpent::encrypt_n(in, out, 1); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } + } + +/* +* Serpent Decryption +*/ +void Serpent_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const + { + for(u32bit i = 0; i != blocks; ++i) + { + Serpent::decrypt_n(in, out, 1); + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } + } + +} diff --git a/src/block/serpent_sse2/serp_sse2.h b/src/block/serpent_sse2/serp_sse2.h new file mode 100644 index 000000000..f1e5c2028 --- /dev/null +++ b/src/block/serpent_sse2/serp_sse2.h @@ -0,0 +1,29 @@ +/* +* Serpent (SSE2) +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SERPENT_SSE2_H__ +#define BOTAN_SERPENT_SSE2_H__ + +#include + +namespace Botan { + +/* +* Serpent +*/ +class BOTAN_DLL Serpent_SSE2 : public Serpent + { + public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + + BlockCipher* clone() const { return new Serpent_SSE2; } + }; + +} + +#endif diff --git a/src/block/skipjack/skipjack.h b/src/block/skipjack/skipjack.h index ec071dfe7..f12032f36 100644 --- a/src/block/skipjack/skipjack.h +++ b/src/block/skipjack/skipjack.h @@ -18,18 +18,21 @@ namespace Botan { class BOTAN_DLL Skipjack : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const { return "Skipjack"; } BlockCipher* clone() const { return new Skipjack; } + Skipjack() : BlockCipher(8, 10) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); void step_A(u16bit&, u16bit&, u32bit) const; void step_B(u16bit&, u16bit&, u32bit) const; void step_Ai(u16bit&, u16bit&, u32bit) const; void step_Bi(u16bit&, u16bit&, u32bit) const; + SecureBuffer FTABLE[10]; }; diff --git a/src/block/square/square.h b/src/block/square/square.h index 0de4c20bd..5d9cfc78c 100644 --- a/src/block/square/square.h +++ b/src/block/square/square.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL Square : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const { return "Square"; } BlockCipher* clone() const { return new Square; } + Square() : BlockCipher(16, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static void transform(u32bit[4]); diff --git a/src/block/tea/tea.h b/src/block/tea/tea.h index 141899e88..825a051aa 100644 --- a/src/block/tea/tea.h +++ b/src/block/tea/tea.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL TEA : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { K.clear(); } std::string name() const { return "TEA"; } BlockCipher* clone() const { return new TEA; } + TEA() : BlockCipher(8, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer K; }; diff --git a/src/block/twofish/twofish.h b/src/block/twofish/twofish.h index 640fb58ad..87b9aa626 100644 --- a/src/block/twofish/twofish.h +++ b/src/block/twofish/twofish.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL Twofish : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw(); std::string name() const { return "Twofish"; } BlockCipher* clone() const { return new Twofish; } + Twofish() : BlockCipher(16, 16, 32, 8) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); static void rs_mul(byte[4], byte, u32bit); diff --git a/src/block/xtea/xtea.h b/src/block/xtea/xtea.h index b50f487b4..de265818d 100644 --- a/src/block/xtea/xtea.h +++ b/src/block/xtea/xtea.h @@ -18,13 +18,15 @@ namespace Botan { class BOTAN_DLL XTEA : public BlockCipher { public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + void clear() throw() { EK.clear(); } std::string name() const { return "XTEA"; } BlockCipher* clone() const { return new XTEA; } + XTEA() : BlockCipher(8, 16) {} private: - void encrypt_n(const byte in[], byte out[], u32bit blocks) const; - void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); SecureBuffer EK; }; diff --git a/src/engine/sse2_eng/eng_sse2.cpp b/src/engine/sse2_eng/eng_sse2.cpp index c738b3d96..9f68a070e 100644 --- a/src/engine/sse2_eng/eng_sse2.cpp +++ b/src/engine/sse2_eng/eng_sse2.cpp @@ -1,6 +1,6 @@ /** * SSE2 Assembly Engine -* (C) 1999-2008 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -11,10 +11,27 @@ #include #endif +#if defined(BOTAN_HAS_SERPENT_SSE2) + #include +#endif + namespace Botan { -HashFunction* SSE2_Assembler_Engine::find_hash(const SCAN_Name& request, - Algorithm_Factory&) const +BlockCipher* +SSE2_Assembler_Engine::find_block_cipher(const SCAN_Name& request, + Algorithm_Factory&) const + { +#if defined(BOTAN_HAS_SERPENT_SSE2) + if(request.algo_name() == "Serpent") + return new Serpent_SSE2; +#endif + + return 0; + } + +HashFunction* +SSE2_Assembler_Engine::find_hash(const SCAN_Name& request, + Algorithm_Factory&) const { #if defined(BOTAN_HAS_SHA1_SSE2) if(request.algo_name() == "SHA-160") diff --git a/src/engine/sse2_eng/eng_sse2.h b/src/engine/sse2_eng/eng_sse2.h index 129697e8f..c6b0ce889 100644 --- a/src/engine/sse2_eng/eng_sse2.h +++ b/src/engine/sse2_eng/eng_sse2.h @@ -1,6 +1,6 @@ /** * SSE2 Assembly Engine -* (C) 1999-2008 Jack Lloyd +* (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -17,6 +17,9 @@ class BOTAN_DLL SSE2_Assembler_Engine : public Engine public: std::string provider_name() const { return "sse2"; } private: + BlockCipher* find_block_cipher(const SCAN_Name&, + Algorithm_Factory&) const; + HashFunction* find_hash(const SCAN_Name& reqeust, Algorithm_Factory&) const; }; -- cgit v1.2.3 From 285d350ed62d2714592a27bf577832a92cb6902f Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 12:23:16 +0000 Subject: Add full 4-way SSE2 Serpent encryption. Load/store operations are via unions and can be made much faster using interleave operations I think. Currently ~2.5x faster in ECB or CTR mode on a Core2, which isn't too bad. --- src/block/serpent_sse2/info.txt | 1 + src/block/serpent_sse2/serp_sse2.cpp | 111 +++++++++------- src/block/serpent_sse2/serp_sse2_sbox.h | 225 ++++++++++++++++++++++++++++++++ 3 files changed, 290 insertions(+), 47 deletions(-) create mode 100644 src/block/serpent_sse2/serp_sse2_sbox.h (limited to 'src') diff --git a/src/block/serpent_sse2/info.txt b/src/block/serpent_sse2/info.txt index ad8323f53..09733e98f 100644 --- a/src/block/serpent_sse2/info.txt +++ b/src/block/serpent_sse2/info.txt @@ -7,6 +7,7 @@ load_on auto serp_sse2.cpp serp_sse2.h +serp_sse2_sbox.h diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_sse2/serp_sse2.cpp index 759f3e1d6..3e78f0bac 100644 --- a/src/block/serpent_sse2/serp_sse2.cpp +++ b/src/block/serpent_sse2/serp_sse2.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include @@ -13,29 +14,6 @@ namespace Botan { namespace { -#define SBoxE1(b0, b1, b2, b3, b4) \ - do { \ - b3 = _mm_xor_si128(b3, b0); \ - b4 = b1; \ - b1 = _mm_and_si128(b1, b3); \ - b4 = _mm_xor_si128(b4, b2); \ - b1 = _mm_xor_si128(b1, b0); \ - b0 = _mm_or_si128(b0, b3); \ - b0 = _mm_xor_si128(b0, b4); \ - b4 = _mm_xor_si128(b4, b3); \ - b3 = _mm_xor_si128(b3, b2); \ - b2 = _mm_or_si128(b2, b1); \ - b2 = _mm_xor_si128(b2, b4); \ - b4 = _mm_andnot_si128(b4, all_ones); \ - b4 = _mm_or_si128(b4, b1); \ - b1 = _mm_xor_si128(b1, b3); \ - b1 = _mm_xor_si128(b1, b4); \ - b3 = _mm_or_si128(b3, b0); \ - b1 = _mm_xor_si128(b1, b3); \ - b4 = _mm_xor_si128(b4, b3); \ - b3 = b0; b0 = b1; b1 = b4; \ - } while(0); - #define rotate_left_m128(vec, rot) \ _mm_or_si128(_mm_slli_epi32(vec, rot), _mm_srli_epi32(vec, 32-rot)) @@ -89,45 +67,84 @@ void serpent_encrypt_4(const byte in[64], convert.u32[1] = load_le(in, 4); convert.u32[2] = load_le(in, 8); convert.u32[3] = load_le(in, 12); - - __m128i b0 = convert.v; + __m128i B0 = convert.v; convert.u32[0] = load_le(in, 1); convert.u32[1] = load_le(in, 5); convert.u32[2] = load_le(in, 9); convert.u32[3] = load_le(in, 13); - - __m128i b1 = convert.v; + __m128i B1 = convert.v; convert.u32[0] = load_le(in, 2); convert.u32[1] = load_le(in, 6); convert.u32[2] = load_le(in, 10); convert.u32[3] = load_le(in, 14); - - __m128i b2 = convert.v; + __m128i B2 = convert.v; convert.u32[0] = load_le(in, 3); convert.u32[1] = load_le(in, 7); convert.u32[2] = load_le(in, 11); convert.u32[3] = load_le(in, 15); - - - __m128i b3 = convert.v; - - __m128i b4; // temp - - const __m128i all_ones = _mm_set1_epi8(0xFF); - - key_xor(0, b0, b1, b2, b3); - SBoxE1(b0, b1, b2, b3, b4); - transform(b0, b1, b2, b3); - - key_xor(b0, b1, b2, b3, 1); - - print_simd("b0", b0); - print_simd("b1", b1); - print_simd("b2", b2); - print_simd("b3", b3); + __m128i B3 = convert.v; + + key_xor(0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(1,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(2,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(3,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(4,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(5,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(6,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(7,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + + key_xor( 8,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 9,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(10,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(11,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(12,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(13,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(14,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(15,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(16,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(17,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(18,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(19,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(20,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(21,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(22,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(23,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(24,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(25,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(26,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(27,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(28,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(29,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(30,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(31,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); key_xor(32,B0,B1,B2,B3); + + // FIXME: figure out how to do this fast + union { __m128i v; u32bit u32[4]; } convert_B0; + union { __m128i v; u32bit u32[4]; } convert_B1; + union { __m128i v; u32bit u32[4]; } convert_B2; + union { __m128i v; u32bit u32[4]; } convert_B3; + convert_B0.v = B0; + convert_B1.v = B1; + convert_B2.v = B2; + convert_B3.v = B3; + store_le(out, + convert_B0.u32[0], convert_B1.u32[0], + convert_B2.u32[0], convert_B3.u32[0]); + + store_le(out + 16, + convert_B0.u32[1], convert_B1.u32[1], + convert_B2.u32[1], convert_B3.u32[1]); + + store_le(out + 32, + convert_B0.u32[2], convert_B1.u32[2], + convert_B2.u32[2], convert_B3.u32[2]); + + store_le(out + 48, + convert_B0.u32[3], convert_B1.u32[3], + convert_B2.u32[3], convert_B3.u32[3]); } } diff --git a/src/block/serpent_sse2/serp_sse2_sbox.h b/src/block/serpent_sse2/serp_sse2_sbox.h new file mode 100644 index 000000000..2c4d9d9cb --- /dev/null +++ b/src/block/serpent_sse2/serp_sse2_sbox.h @@ -0,0 +1,225 @@ +/* +* Serpent Sboxes in SSE2 form +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef SERPENT_SSE2_SBOXES_H__ +#define SERPENT_SSE2_SBOXES_H__ + +#define SBoxE1(b0, b1, b2, b3) \ + do { \ + b3 = _mm_xor_si128(b3, b0); \ + __m128i b4 = b1; \ + b1 = _mm_and_si128(b1, b3); \ + b4 = _mm_xor_si128(b4, b2); \ + b1 = _mm_xor_si128(b1, b0); \ + b0 = _mm_or_si128(b0, b3); \ + b0 = _mm_xor_si128(b0, b4); \ + b4 = _mm_xor_si128(b4, b3); \ + b3 = _mm_xor_si128(b3, b2); \ + b2 = _mm_or_si128(b2, b1); \ + b2 = _mm_xor_si128(b2, b4); \ + b4 = _mm_andnot_si128(b4, _mm_set1_epi8(0xFF)); \ + b4 = _mm_or_si128(b4, b1); \ + b1 = _mm_xor_si128(b1, b3); \ + b1 = _mm_xor_si128(b1, b4); \ + b3 = _mm_or_si128(b3, b0); \ + b1 = _mm_xor_si128(b1, b3); \ + b4 = _mm_xor_si128(b4, b3); \ + b3 = b0; \ + b0 = b1; \ + b1 = b4; \ + } while(0); + +#define SBoxE2(b0, b1, b2, b3) \ + do \ + { \ + b0 = _mm_andnot_si128(b0, _mm_set1_epi8(0xFF)); \ + b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ + __m128i b4 = b0; \ + b0 = _mm_and_si128(b0, b1); \ + b2 = _mm_xor_si128(b2, b0); \ + b0 = _mm_or_si128(b0, b3); \ + b3 = _mm_xor_si128(b3, b2); \ + b1 = _mm_xor_si128(b1, b0); \ + b0 = _mm_xor_si128(b0, b4); \ + b4 = _mm_or_si128(b4, b1); \ + b1 = _mm_xor_si128(b1, b3); \ + b2 = _mm_or_si128(b2, b0); \ + b2 = _mm_and_si128(b2, b4); \ + b0 = _mm_xor_si128(b0, b1); \ + b1 = _mm_and_si128(b1, b2); \ + b1 = _mm_xor_si128(b1, b0); \ + b0 = _mm_and_si128(b0, b2); \ + b4 = _mm_xor_si128(b4, b0); \ + b0 = b2; \ + b2 = b3; \ + b3 = b1; \ + b1 = b4; \ + } while(0); + +#define SBoxE3(b0, b1, b2, b3) \ + do \ + { \ + __m128i b4 = b0; \ + b0 = _mm_and_si128(b0, b2); \ + b0 = _mm_xor_si128(b0, b3); \ + b2 = _mm_xor_si128(b2, b1); \ + b2 = _mm_xor_si128(b2, b0); \ + b3 = _mm_or_si128(b3, b4); \ + b3 = _mm_xor_si128(b3, b1); \ + b4 = _mm_xor_si128(b4, b2); \ + b1 = b3; \ + b3 = _mm_or_si128(b3, b4); \ + b3 = _mm_xor_si128(b3, b0); \ + b0 = _mm_and_si128(b0, b1); \ + b4 = _mm_xor_si128(b4, b0); \ + b1 = _mm_xor_si128(b1, b3); \ + b1 = _mm_xor_si128(b1, b4); \ + b4 = _mm_andnot_si128(b4, _mm_set1_epi8(0xFF)); \ + b0 = b2; \ + b2 = b1; \ + b1 = b3; \ + b3 = b4; \ + } while(0); + +#define SBoxE4(b0, b1, b2, b3) \ + do \ + { \ + __m128i b4 = b0; \ + b0 = _mm_or_si128(b0, b3); \ + b3 = _mm_xor_si128(b3, b1); \ + b1 = _mm_and_si128(b1, b4); \ + b4 = _mm_xor_si128(b4, b2); \ + b2 = _mm_xor_si128(b2, b3); \ + b3 = _mm_and_si128(b3, b0); \ + b4 = _mm_or_si128(b4, b1); \ + b3 = _mm_xor_si128(b3, b4); \ + b0 = _mm_xor_si128(b0, b1); \ + b4 = _mm_and_si128(b4, b0); \ + b1 = _mm_xor_si128(b1, b3); \ + b4 = _mm_xor_si128(b4, b2); \ + b1 = _mm_or_si128(b1, b0); \ + b1 = _mm_xor_si128(b1, b2); \ + b0 = _mm_xor_si128(b0, b3); \ + b2 = b1; \ + b1 = _mm_or_si128(b1, b3); \ + b1 = _mm_xor_si128(b1, b0); \ + b0 = b1; \ + b1 = b2; \ + b2 = b3; \ + b3 = b4; \ + } while(0); + +#define SBoxE5(b0, b1, b2, b3) \ + do \ + { \ + b1 = _mm_xor_si128(b1, b3); \ + b3 = _mm_andnot_si128(b3, _mm_set1_epi8(0xFF)); \ + b2 = _mm_xor_si128(b2, b3); \ + b3 = _mm_xor_si128(b3, b0); \ + __m128i b4 = b1; \ + b1 = _mm_and_si128(b1, b3); \ + b1 = _mm_xor_si128(b1, b2); \ + b4 = _mm_xor_si128(b4, b3); \ + b0 = _mm_xor_si128(b0, b4); \ + b2 = _mm_and_si128(b2, b4); \ + b2 = _mm_xor_si128(b2, b0); \ + b0 = _mm_and_si128(b0, b1); \ + b3 = _mm_xor_si128(b3, b0); \ + b4 = _mm_or_si128(b4, b1); \ + b4 = _mm_xor_si128(b4, b0); \ + b0 = _mm_or_si128(b0, b3); \ + b0 = _mm_xor_si128(b0, b2); \ + b2 = _mm_and_si128(b2, b3); \ + b0 = _mm_andnot_si128(b0, _mm_set1_epi8(0xFF)); \ + b4 = _mm_xor_si128(b4, b2); \ + b2 = b0; \ + b0 = b1; \ + b1 = b4; \ + } while(0); + +#define SBoxE6(b0, b1, b2, b3) \ + do \ + { \ + b0 = _mm_xor_si128(b0, b1); \ + b1 = _mm_xor_si128(b1, b3); \ + b3 = _mm_andnot_si128(b3, _mm_set1_epi8(0xFF)); \ + __m128i b4 = b1; \ + b1 = _mm_and_si128(b1, b0); \ + b2 = _mm_xor_si128(b2, b3); \ + b1 = _mm_xor_si128(b1, b2); \ + b2 = _mm_or_si128(b2, b4); \ + b4 = _mm_xor_si128(b4, b3); \ + b3 = _mm_and_si128(b3, b1); \ + b3 = _mm_xor_si128(b3, b0); \ + b4 = _mm_xor_si128(b4, b1); \ + b4 = _mm_xor_si128(b4, b2); \ + b2 = _mm_xor_si128(b2, b0); \ + b0 = _mm_and_si128(b0, b3); \ + b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ + b0 = _mm_xor_si128(b0, b4); \ + b4 = _mm_or_si128(b4, b3); \ + b4 = _mm_xor_si128(b4, b2); \ + b2 = b0; \ + b0 = b1; \ + b1 = b3; \ + b3 = b4; \ + } while(0); + +#define SBoxE7(b0, b1, b2, b3) \ + do \ + { \ + b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ + __m128i b4 = b3; \ + b3 = _mm_and_si128(b3, b0); \ + b0 = _mm_xor_si128(b0, b4); \ + b3 = _mm_xor_si128(b3, b2); \ + b2 = _mm_or_si128(b2, b4); \ + b1 = _mm_xor_si128(b1, b3); \ + b2 = _mm_xor_si128(b2, b0); \ + b0 = _mm_or_si128(b0, b1); \ + b2 = _mm_xor_si128(b2, b1); \ + b4 = _mm_xor_si128(b4, b0); \ + b0 = _mm_or_si128(b0, b3); \ + b0 = _mm_xor_si128(b0, b2); \ + b4 = _mm_xor_si128(b4, b3); \ + b4 = _mm_xor_si128(b4, b0); \ + b3 = _mm_andnot_si128(b3, _mm_set1_epi8(0xFF)); \ + b2 = _mm_and_si128(b2, b4); \ + b3 = _mm_xor_si128(b3, b2); \ + b2 = b4; \ + } while(0); + +#define SBoxE8(b0, b1, b2, b3) \ + do \ + { \ + __m128i b4 = b1; \ + b1 = _mm_or_si128(b1, b2); \ + b1 = _mm_xor_si128(b1, b3); \ + b4 = _mm_xor_si128(b4, b2); \ + b2 = _mm_xor_si128(b2, b1); \ + b3 = _mm_or_si128(b3, b4); \ + b3 = _mm_and_si128(b3, b0); \ + b4 = _mm_xor_si128(b4, b2); \ + b3 = _mm_xor_si128(b3, b1); \ + b1 = _mm_or_si128(b1, b4); \ + b1 = _mm_xor_si128(b1, b0); \ + b0 = _mm_or_si128(b0, b4); \ + b0 = _mm_xor_si128(b0, b2); \ + b1 = _mm_xor_si128(b1, b4); \ + b2 = _mm_xor_si128(b2, b1); \ + b1 = _mm_and_si128(b1, b0); \ + b1 = _mm_xor_si128(b1, b4); \ + b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ + b2 = _mm_or_si128(b2, b0); \ + b4 = _mm_xor_si128(b4, b2); \ + b2 = b1; \ + b1 = b3; \ + b3 = b0; \ + b0 = b4; \ + } while(0); + +#endif -- cgit v1.2.3 From 89eb757b344d3605f3f8012079749f01ef23bb6b Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 13:49:19 +0000 Subject: Use SSE2 unpack instructions instead of unions for input/output conversion. About 10% faster than previous. Currently 112 MiB/s in ECB mode, versus about 40 MiB/s in scalar mode, on my 2.4 GHz Core2 --- src/block/serpent_sse2/serp_sse2.cpp | 162 ++++++------- src/block/serpent_sse2/serp_sse2_sbox.h | 401 ++++++++++++++++---------------- 2 files changed, 263 insertions(+), 300 deletions(-) (limited to 'src') diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_sse2/serp_sse2.cpp index 3e78f0bac..ea937c95a 100644 --- a/src/block/serpent_sse2/serp_sse2.cpp +++ b/src/block/serpent_sse2/serp_sse2.cpp @@ -14,88 +14,76 @@ namespace Botan { namespace { +#define key_xor(round, B0, B1, B2, B3) \ + do { \ + __m128i key = _mm_loadu_si128(keys + round); \ + B0 = _mm_xor_si128(B0, _mm_shuffle_epi32(key, _MM_SHUFFLE(0,0,0,0))); \ + B1 = _mm_xor_si128(B1, _mm_shuffle_epi32(key, _MM_SHUFFLE(1,1,1,1))); \ + B2 = _mm_xor_si128(B2, _mm_shuffle_epi32(key, _MM_SHUFFLE(2,2,2,2))); \ + B3 = _mm_xor_si128(B3, _mm_shuffle_epi32(key, _MM_SHUFFLE(3,3,3,3))); \ + } while(0); + +/* +* Serpent's linear transformation +*/ #define rotate_left_m128(vec, rot) \ _mm_or_si128(_mm_slli_epi32(vec, rot), _mm_srli_epi32(vec, 32-rot)) -#define key_xor(round, b0, b1, b2, b3) \ - do { \ - __m128i key = _mm_loadu_si128(keys + round); \ - b0 = _mm_xor_si128(b0, _mm_shuffle_epi32(key, _MM_SHUFFLE(0,0,0,0))); \ - b1 = _mm_xor_si128(b1, _mm_shuffle_epi32(key, _MM_SHUFFLE(1,1,1,1))); \ - b2 = _mm_xor_si128(b2, _mm_shuffle_epi32(key, _MM_SHUFFLE(2,2,2,2))); \ - b3 = _mm_xor_si128(b3, _mm_shuffle_epi32(key, _MM_SHUFFLE(3,3,3,3))); \ - } while(0); - -#define transform(b0, b1, b2, b3) \ - do \ - { \ - b0 = rotate_left_m128(b0, 13); \ - b2 = rotate_left_m128(b2, 3); \ - b1 = _mm_xor_si128(b1, _mm_xor_si128(b0, b2)); \ - b3 = _mm_xor_si128(b3, _mm_xor_si128(b2, _mm_slli_epi32(b0, 3))); \ - b1 = rotate_left_m128(b1, 1); \ - b3 = rotate_left_m128(b3, 7); \ - b0 = _mm_xor_si128(b0, _mm_xor_si128(b1, b3)); \ - b2 = _mm_xor_si128(b2, _mm_xor_si128(b3, _mm_slli_epi32(b1, 7))); \ - b0 = rotate_left_m128(b0, 5); \ - b2 = rotate_left_m128(b2, 22); \ - } while(0); - -void print_simd(const char* name, __m128i vec) - { - union { __m128i v; int32_t ints[4]; } u = { vec }; +#define transform(B0, B1, B2, B3) \ + do { \ + B0 = rotate_left_m128(B0, 13); \ + B2 = rotate_left_m128(B2, 3); \ + B1 = _mm_xor_si128(B1, _mm_xor_si128(B0, B2)); \ + B3 = _mm_xor_si128(B3, _mm_xor_si128(B2, _mm_slli_epi32(B0, 3))); \ + B1 = rotate_left_m128(B1, 1); \ + B3 = rotate_left_m128(B3, 7); \ + B0 = _mm_xor_si128(B0, _mm_xor_si128(B1, B3)); \ + B2 = _mm_xor_si128(B2, _mm_xor_si128(B3, _mm_slli_epi32(B1, 7))); \ + B0 = rotate_left_m128(B0, 5); \ + B2 = rotate_left_m128(B2, 22); \ + } while(0); - printf("%s: ", name); - for(u32bit i = 0; i != 4; ++i) - printf("%08X ", u.ints[i]); - printf("\n"); - } +/* +* 4x4 SSE2 integer matrix transpose +*/ +#define transpose(B0, B1, B2, B3) \ + do { \ + __m128i T0 = _mm_unpacklo_epi32(B0, B1); \ + __m128i T1 = _mm_unpacklo_epi32(B2, B3); \ + __m128i T2 = _mm_unpackhi_epi32(B0, B1); \ + __m128i T3 = _mm_unpackhi_epi32(B2, B3); \ + B0 = _mm_unpacklo_epi64(T0, T1); \ + B1 = _mm_unpackhi_epi64(T0, T1); \ + B2 = _mm_unpacklo_epi64(T2, T3); \ + B3 = _mm_unpackhi_epi64(T2, T3); \ + } while(0); +/* +* SSE2 Serpent Encryption of 4 blocks in parallel +*/ void serpent_encrypt_4(const byte in[64], byte out[64], const u32bit keys_32[132]) { const __m128i* keys = (const __m128i*)(keys_32); - - /* - FIXME: figure out a fast way to do this with 4 loads with - _mm_loadu_si128 plus shuffle/interleave ops - */ - union { __m128i v; u32bit u32[4]; } convert; - - convert.u32[0] = load_le(in, 0); - convert.u32[1] = load_le(in, 4); - convert.u32[2] = load_le(in, 8); - convert.u32[3] = load_le(in, 12); - __m128i B0 = convert.v; - - convert.u32[0] = load_le(in, 1); - convert.u32[1] = load_le(in, 5); - convert.u32[2] = load_le(in, 9); - convert.u32[3] = load_le(in, 13); - __m128i B1 = convert.v; - - convert.u32[0] = load_le(in, 2); - convert.u32[1] = load_le(in, 6); - convert.u32[2] = load_le(in, 10); - convert.u32[3] = load_le(in, 14); - __m128i B2 = convert.v; - - convert.u32[0] = load_le(in, 3); - convert.u32[1] = load_le(in, 7); - convert.u32[2] = load_le(in, 11); - convert.u32[3] = load_le(in, 15); - __m128i B3 = convert.v; - - key_xor(0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(1,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(2,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(3,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(4,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(5,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(6,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); - key_xor(7,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); - + __m128i* out_mm = (__m128i*)(out); + __m128i* in_mm = (__m128i*)(in); + + __m128i B0 = _mm_loadu_si128(in_mm); + __m128i B1 = _mm_loadu_si128(in_mm + 1); + __m128i B2 = _mm_loadu_si128(in_mm + 2); + __m128i B3 = _mm_loadu_si128(in_mm + 3); + + transpose(B0, B1, B2, B3); + + key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 1,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 2,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 3,B0,B1,B2,B3); SBoxE4(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 4,B0,B1,B2,B3); SBoxE5(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 5,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 6,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 7,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor( 8,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor( 9,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(10,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); @@ -121,30 +109,12 @@ void serpent_encrypt_4(const byte in[64], key_xor(30,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); key_xor(32,B0,B1,B2,B3); - // FIXME: figure out how to do this fast - union { __m128i v; u32bit u32[4]; } convert_B0; - union { __m128i v; u32bit u32[4]; } convert_B1; - union { __m128i v; u32bit u32[4]; } convert_B2; - union { __m128i v; u32bit u32[4]; } convert_B3; - convert_B0.v = B0; - convert_B1.v = B1; - convert_B2.v = B2; - convert_B3.v = B3; - store_le(out, - convert_B0.u32[0], convert_B1.u32[0], - convert_B2.u32[0], convert_B3.u32[0]); - - store_le(out + 16, - convert_B0.u32[1], convert_B1.u32[1], - convert_B2.u32[1], convert_B3.u32[1]); - - store_le(out + 32, - convert_B0.u32[2], convert_B1.u32[2], - convert_B2.u32[2], convert_B3.u32[2]); - - store_le(out + 48, - convert_B0.u32[3], convert_B1.u32[3], - convert_B2.u32[3], convert_B3.u32[3]); + transpose(B0, B1, B2, B3); + + _mm_storeu_si128(out_mm , B0); + _mm_storeu_si128(out_mm + 1, B1); + _mm_storeu_si128(out_mm + 2, B2); + _mm_storeu_si128(out_mm + 3, B3); } } diff --git a/src/block/serpent_sse2/serp_sse2_sbox.h b/src/block/serpent_sse2/serp_sse2_sbox.h index 2c4d9d9cb..bc8678a89 100644 --- a/src/block/serpent_sse2/serp_sse2_sbox.h +++ b/src/block/serpent_sse2/serp_sse2_sbox.h @@ -8,218 +8,211 @@ #ifndef SERPENT_SSE2_SBOXES_H__ #define SERPENT_SSE2_SBOXES_H__ -#define SBoxE1(b0, b1, b2, b3) \ +#define SBoxE1(B0, B1, B2, B3) \ do { \ - b3 = _mm_xor_si128(b3, b0); \ - __m128i b4 = b1; \ - b1 = _mm_and_si128(b1, b3); \ - b4 = _mm_xor_si128(b4, b2); \ - b1 = _mm_xor_si128(b1, b0); \ - b0 = _mm_or_si128(b0, b3); \ - b0 = _mm_xor_si128(b0, b4); \ - b4 = _mm_xor_si128(b4, b3); \ - b3 = _mm_xor_si128(b3, b2); \ - b2 = _mm_or_si128(b2, b1); \ - b2 = _mm_xor_si128(b2, b4); \ - b4 = _mm_andnot_si128(b4, _mm_set1_epi8(0xFF)); \ - b4 = _mm_or_si128(b4, b1); \ - b1 = _mm_xor_si128(b1, b3); \ - b1 = _mm_xor_si128(b1, b4); \ - b3 = _mm_or_si128(b3, b0); \ - b1 = _mm_xor_si128(b1, b3); \ - b4 = _mm_xor_si128(b4, b3); \ - b3 = b0; \ - b0 = b1; \ - b1 = b4; \ + B3 = _mm_xor_si128(B3, B0); \ + __m128i B4 = B1; \ + B1 = _mm_and_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B0 = _mm_xor_si128(B0, B4); \ + B4 = _mm_xor_si128(B4, B3); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = _mm_or_si128(B2, B1); \ + B2 = _mm_xor_si128(B2, B4); \ + B4 = _mm_andnot_si128(B4, _mm_set1_epi8(0xFF)); \ + B4 = _mm_or_si128(B4, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B4); \ + B3 = _mm_or_si128(B3, B0); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B3); \ + B3 = B0; \ + B0 = B1; \ + B1 = B4; \ } while(0); -#define SBoxE2(b0, b1, b2, b3) \ - do \ - { \ - b0 = _mm_andnot_si128(b0, _mm_set1_epi8(0xFF)); \ - b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ - __m128i b4 = b0; \ - b0 = _mm_and_si128(b0, b1); \ - b2 = _mm_xor_si128(b2, b0); \ - b0 = _mm_or_si128(b0, b3); \ - b3 = _mm_xor_si128(b3, b2); \ - b1 = _mm_xor_si128(b1, b0); \ - b0 = _mm_xor_si128(b0, b4); \ - b4 = _mm_or_si128(b4, b1); \ - b1 = _mm_xor_si128(b1, b3); \ - b2 = _mm_or_si128(b2, b0); \ - b2 = _mm_and_si128(b2, b4); \ - b0 = _mm_xor_si128(b0, b1); \ - b1 = _mm_and_si128(b1, b2); \ - b1 = _mm_xor_si128(b1, b0); \ - b0 = _mm_and_si128(b0, b2); \ - b4 = _mm_xor_si128(b4, b0); \ - b0 = b2; \ - b2 = b3; \ - b3 = b1; \ - b1 = b4; \ - } while(0); +#define SBoxE2(B0, B1, B2, B3) \ + do { \ + B0 = _mm_andnot_si128(B0, _mm_set1_epi8(0xFF)); \ + B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ + __m128i B4 = B0; \ + B0 = _mm_and_si128(B0, B1); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B3 = _mm_xor_si128(B3, B2); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_xor_si128(B0, B4); \ + B4 = _mm_or_si128(B4, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B2 = _mm_or_si128(B2, B0); \ + B2 = _mm_and_si128(B2, B4); \ + B0 = _mm_xor_si128(B0, B1); \ + B1 = _mm_and_si128(B1, B2); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_and_si128(B0, B2); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = B2; \ + B2 = B3; \ + B3 = B1; \ + B1 = B4; \ + } while(0); -#define SBoxE3(b0, b1, b2, b3) \ - do \ - { \ - __m128i b4 = b0; \ - b0 = _mm_and_si128(b0, b2); \ - b0 = _mm_xor_si128(b0, b3); \ - b2 = _mm_xor_si128(b2, b1); \ - b2 = _mm_xor_si128(b2, b0); \ - b3 = _mm_or_si128(b3, b4); \ - b3 = _mm_xor_si128(b3, b1); \ - b4 = _mm_xor_si128(b4, b2); \ - b1 = b3; \ - b3 = _mm_or_si128(b3, b4); \ - b3 = _mm_xor_si128(b3, b0); \ - b0 = _mm_and_si128(b0, b1); \ - b4 = _mm_xor_si128(b4, b0); \ - b1 = _mm_xor_si128(b1, b3); \ - b1 = _mm_xor_si128(b1, b4); \ - b4 = _mm_andnot_si128(b4, _mm_set1_epi8(0xFF)); \ - b0 = b2; \ - b2 = b1; \ - b1 = b3; \ - b3 = b4; \ - } while(0); +#define SBoxE3(B0, B1, B2, B3) \ + do { \ + __m128i B4 = B0; \ + B0 = _mm_and_si128(B0, B2); \ + B0 = _mm_xor_si128(B0, B3); \ + B2 = _mm_xor_si128(B2, B1); \ + B2 = _mm_xor_si128(B2, B0); \ + B3 = _mm_or_si128(B3, B4); \ + B3 = _mm_xor_si128(B3, B1); \ + B4 = _mm_xor_si128(B4, B2); \ + B1 = B3; \ + B3 = _mm_or_si128(B3, B4); \ + B3 = _mm_xor_si128(B3, B0); \ + B0 = _mm_and_si128(B0, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B1 = _mm_xor_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B4); \ + B4 = _mm_andnot_si128(B4, _mm_set1_epi8(0xFF)); \ + B0 = B2; \ + B2 = B1; \ + B1 = B3; \ + B3 = B4; \ + } while(0); -#define SBoxE4(b0, b1, b2, b3) \ - do \ - { \ - __m128i b4 = b0; \ - b0 = _mm_or_si128(b0, b3); \ - b3 = _mm_xor_si128(b3, b1); \ - b1 = _mm_and_si128(b1, b4); \ - b4 = _mm_xor_si128(b4, b2); \ - b2 = _mm_xor_si128(b2, b3); \ - b3 = _mm_and_si128(b3, b0); \ - b4 = _mm_or_si128(b4, b1); \ - b3 = _mm_xor_si128(b3, b4); \ - b0 = _mm_xor_si128(b0, b1); \ - b4 = _mm_and_si128(b4, b0); \ - b1 = _mm_xor_si128(b1, b3); \ - b4 = _mm_xor_si128(b4, b2); \ - b1 = _mm_or_si128(b1, b0); \ - b1 = _mm_xor_si128(b1, b2); \ - b0 = _mm_xor_si128(b0, b3); \ - b2 = b1; \ - b1 = _mm_or_si128(b1, b3); \ - b1 = _mm_xor_si128(b1, b0); \ - b0 = b1; \ - b1 = b2; \ - b2 = b3; \ - b3 = b4; \ - } while(0); +#define SBoxE4(B0, B1, B2, B3) \ + do { \ + __m128i B4 = B0; \ + B0 = _mm_or_si128(B0, B3); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_and_si128(B1, B4); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_xor_si128(B2, B3); \ + B3 = _mm_and_si128(B3, B0); \ + B4 = _mm_or_si128(B4, B1); \ + B3 = _mm_xor_si128(B3, B4); \ + B0 = _mm_xor_si128(B0, B1); \ + B4 = _mm_and_si128(B4, B0); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B1 = _mm_or_si128(B1, B0); \ + B1 = _mm_xor_si128(B1, B2); \ + B0 = _mm_xor_si128(B0, B3); \ + B2 = B1; \ + B1 = _mm_or_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = B1; \ + B1 = B2; \ + B2 = B3; \ + B3 = B4; \ + } while(0); -#define SBoxE5(b0, b1, b2, b3) \ - do \ - { \ - b1 = _mm_xor_si128(b1, b3); \ - b3 = _mm_andnot_si128(b3, _mm_set1_epi8(0xFF)); \ - b2 = _mm_xor_si128(b2, b3); \ - b3 = _mm_xor_si128(b3, b0); \ - __m128i b4 = b1; \ - b1 = _mm_and_si128(b1, b3); \ - b1 = _mm_xor_si128(b1, b2); \ - b4 = _mm_xor_si128(b4, b3); \ - b0 = _mm_xor_si128(b0, b4); \ - b2 = _mm_and_si128(b2, b4); \ - b2 = _mm_xor_si128(b2, b0); \ - b0 = _mm_and_si128(b0, b1); \ - b3 = _mm_xor_si128(b3, b0); \ - b4 = _mm_or_si128(b4, b1); \ - b4 = _mm_xor_si128(b4, b0); \ - b0 = _mm_or_si128(b0, b3); \ - b0 = _mm_xor_si128(b0, b2); \ - b2 = _mm_and_si128(b2, b3); \ - b0 = _mm_andnot_si128(b0, _mm_set1_epi8(0xFF)); \ - b4 = _mm_xor_si128(b4, b2); \ - b2 = b0; \ - b0 = b1; \ - b1 = b4; \ - } while(0); +#define SBoxE5(B0, B1, B2, B3) \ + do { \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_andnot_si128(B3, _mm_set1_epi8(0xFF)); \ + B2 = _mm_xor_si128(B2, B3); \ + B3 = _mm_xor_si128(B3, B0); \ + __m128i B4 = B1; \ + B1 = _mm_and_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B2); \ + B4 = _mm_xor_si128(B4, B3); \ + B0 = _mm_xor_si128(B0, B4); \ + B2 = _mm_and_si128(B2, B4); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_and_si128(B0, B1); \ + B3 = _mm_xor_si128(B3, B0); \ + B4 = _mm_or_si128(B4, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B0 = _mm_xor_si128(B0, B2); \ + B2 = _mm_and_si128(B2, B3); \ + B0 = _mm_andnot_si128(B0, _mm_set1_epi8(0xFF)); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B0; \ + B0 = B1; \ + B1 = B4; \ + } while(0); -#define SBoxE6(b0, b1, b2, b3) \ - do \ - { \ - b0 = _mm_xor_si128(b0, b1); \ - b1 = _mm_xor_si128(b1, b3); \ - b3 = _mm_andnot_si128(b3, _mm_set1_epi8(0xFF)); \ - __m128i b4 = b1; \ - b1 = _mm_and_si128(b1, b0); \ - b2 = _mm_xor_si128(b2, b3); \ - b1 = _mm_xor_si128(b1, b2); \ - b2 = _mm_or_si128(b2, b4); \ - b4 = _mm_xor_si128(b4, b3); \ - b3 = _mm_and_si128(b3, b1); \ - b3 = _mm_xor_si128(b3, b0); \ - b4 = _mm_xor_si128(b4, b1); \ - b4 = _mm_xor_si128(b4, b2); \ - b2 = _mm_xor_si128(b2, b0); \ - b0 = _mm_and_si128(b0, b3); \ - b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ - b0 = _mm_xor_si128(b0, b4); \ - b4 = _mm_or_si128(b4, b3); \ - b4 = _mm_xor_si128(b4, b2); \ - b2 = b0; \ - b0 = b1; \ - b1 = b3; \ - b3 = b4; \ - } while(0); +#define SBoxE6(B0, B1, B2, B3) \ + do { \ + B0 = _mm_xor_si128(B0, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_andnot_si128(B3, _mm_set1_epi8(0xFF)); \ + __m128i B4 = B1; \ + B1 = _mm_and_si128(B1, B0); \ + B2 = _mm_xor_si128(B2, B3); \ + B1 = _mm_xor_si128(B1, B2); \ + B2 = _mm_or_si128(B2, B4); \ + B4 = _mm_xor_si128(B4, B3); \ + B3 = _mm_and_si128(B3, B1); \ + B3 = _mm_xor_si128(B3, B0); \ + B4 = _mm_xor_si128(B4, B1); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_and_si128(B0, B3); \ + B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ + B0 = _mm_xor_si128(B0, B4); \ + B4 = _mm_or_si128(B4, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B0; \ + B0 = B1; \ + B1 = B3; \ + B3 = B4; \ + } while(0); -#define SBoxE7(b0, b1, b2, b3) \ - do \ - { \ - b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ - __m128i b4 = b3; \ - b3 = _mm_and_si128(b3, b0); \ - b0 = _mm_xor_si128(b0, b4); \ - b3 = _mm_xor_si128(b3, b2); \ - b2 = _mm_or_si128(b2, b4); \ - b1 = _mm_xor_si128(b1, b3); \ - b2 = _mm_xor_si128(b2, b0); \ - b0 = _mm_or_si128(b0, b1); \ - b2 = _mm_xor_si128(b2, b1); \ - b4 = _mm_xor_si128(b4, b0); \ - b0 = _mm_or_si128(b0, b3); \ - b0 = _mm_xor_si128(b0, b2); \ - b4 = _mm_xor_si128(b4, b3); \ - b4 = _mm_xor_si128(b4, b0); \ - b3 = _mm_andnot_si128(b3, _mm_set1_epi8(0xFF)); \ - b2 = _mm_and_si128(b2, b4); \ - b3 = _mm_xor_si128(b3, b2); \ - b2 = b4; \ - } while(0); +#define SBoxE7(B0, B1, B2, B3) \ + do { \ + B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ + __m128i B4 = B3; \ + B3 = _mm_and_si128(B3, B0); \ + B0 = _mm_xor_si128(B0, B4); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = _mm_or_si128(B2, B4); \ + B1 = _mm_xor_si128(B1, B3); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_or_si128(B0, B1); \ + B2 = _mm_xor_si128(B2, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B0 = _mm_xor_si128(B0, B2); \ + B4 = _mm_xor_si128(B4, B3); \ + B4 = _mm_xor_si128(B4, B0); \ + B3 = _mm_andnot_si128(B3, _mm_set1_epi8(0xFF)); \ + B2 = _mm_and_si128(B2, B4); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = B4; \ + } while(0); -#define SBoxE8(b0, b1, b2, b3) \ - do \ - { \ - __m128i b4 = b1; \ - b1 = _mm_or_si128(b1, b2); \ - b1 = _mm_xor_si128(b1, b3); \ - b4 = _mm_xor_si128(b4, b2); \ - b2 = _mm_xor_si128(b2, b1); \ - b3 = _mm_or_si128(b3, b4); \ - b3 = _mm_and_si128(b3, b0); \ - b4 = _mm_xor_si128(b4, b2); \ - b3 = _mm_xor_si128(b3, b1); \ - b1 = _mm_or_si128(b1, b4); \ - b1 = _mm_xor_si128(b1, b0); \ - b0 = _mm_or_si128(b0, b4); \ - b0 = _mm_xor_si128(b0, b2); \ - b1 = _mm_xor_si128(b1, b4); \ - b2 = _mm_xor_si128(b2, b1); \ - b1 = _mm_and_si128(b1, b0); \ - b1 = _mm_xor_si128(b1, b4); \ - b2 = _mm_andnot_si128(b2, _mm_set1_epi8(0xFF)); \ - b2 = _mm_or_si128(b2, b0); \ - b4 = _mm_xor_si128(b4, b2); \ - b2 = b1; \ - b1 = b3; \ - b3 = b0; \ - b0 = b4; \ - } while(0); +#define SBoxE8(B0, B1, B2, B3) \ + do { \ + __m128i B4 = B1; \ + B1 = _mm_or_si128(B1, B2); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_xor_si128(B2, B1); \ + B3 = _mm_or_si128(B3, B4); \ + B3 = _mm_and_si128(B3, B0); \ + B4 = _mm_xor_si128(B4, B2); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_or_si128(B1, B4); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_or_si128(B0, B4); \ + B0 = _mm_xor_si128(B0, B2); \ + B1 = _mm_xor_si128(B1, B4); \ + B2 = _mm_xor_si128(B2, B1); \ + B1 = _mm_and_si128(B1, B0); \ + B1 = _mm_xor_si128(B1, B4); \ + B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ + B2 = _mm_or_si128(B2, B0); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B1; \ + B1 = B3; \ + B3 = B0; \ + B0 = B4; \ + } while(0); #endif -- cgit v1.2.3 From 8d2ceae6d43ab1e21604e112f437b1494def5ef8 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 14:42:34 +0000 Subject: Small code cleanups in SSE2 Serpent --- src/block/serpent_sse2/serp_sse2.cpp | 6 +- src/block/serpent_sse2/serp_sse2_sbox.h | 381 ++++++++++++++++---------------- 2 files changed, 195 insertions(+), 192 deletions(-) (limited to 'src') diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_sse2/serp_sse2.cpp index ea937c95a..5ce7d8f47 100644 --- a/src/block/serpent_sse2/serp_sse2.cpp +++ b/src/block/serpent_sse2/serp_sse2.cpp @@ -65,6 +65,8 @@ void serpent_encrypt_4(const byte in[64], byte out[64], const u32bit keys_32[132]) { + const __m128i all_ones = _mm_set1_epi8(0xFF); + const __m128i* keys = (const __m128i*)(keys_32); __m128i* out_mm = (__m128i*)(out); __m128i* in_mm = (__m128i*)(in); @@ -84,6 +86,7 @@ void serpent_encrypt_4(const byte in[64], key_xor( 5,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor( 6,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor( 7,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor( 8,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor( 9,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(10,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); @@ -92,6 +95,7 @@ void serpent_encrypt_4(const byte in[64], key_xor(13,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(14,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(15,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(16,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(17,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(18,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); @@ -100,6 +104,7 @@ void serpent_encrypt_4(const byte in[64], key_xor(21,B0,B1,B2,B3); SBoxE6(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(22,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(23,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); transform(B0,B1,B2,B3); + key_xor(24,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(25,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(26,B0,B1,B2,B3); SBoxE3(B0,B1,B2,B3); transform(B0,B1,B2,B3); @@ -127,7 +132,6 @@ void Serpent_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const while(blocks >= 4) { serpent_encrypt_4(in, out, this->round_key); - //Serpent::encrypt_n(in, out, 4); in += 4 * BLOCK_SIZE; out += 4 * BLOCK_SIZE; blocks -= 4; diff --git a/src/block/serpent_sse2/serp_sse2_sbox.h b/src/block/serpent_sse2/serp_sse2_sbox.h index bc8678a89..1660643ad 100644 --- a/src/block/serpent_sse2/serp_sse2_sbox.h +++ b/src/block/serpent_sse2/serp_sse2_sbox.h @@ -8,211 +8,210 @@ #ifndef SERPENT_SSE2_SBOXES_H__ #define SERPENT_SSE2_SBOXES_H__ -#define SBoxE1(B0, B1, B2, B3) \ - do { \ - B3 = _mm_xor_si128(B3, B0); \ - __m128i B4 = B1; \ - B1 = _mm_and_si128(B1, B3); \ - B4 = _mm_xor_si128(B4, B2); \ - B1 = _mm_xor_si128(B1, B0); \ - B0 = _mm_or_si128(B0, B3); \ - B0 = _mm_xor_si128(B0, B4); \ - B4 = _mm_xor_si128(B4, B3); \ - B3 = _mm_xor_si128(B3, B2); \ - B2 = _mm_or_si128(B2, B1); \ - B2 = _mm_xor_si128(B2, B4); \ - B4 = _mm_andnot_si128(B4, _mm_set1_epi8(0xFF)); \ - B4 = _mm_or_si128(B4, B1); \ - B1 = _mm_xor_si128(B1, B3); \ - B1 = _mm_xor_si128(B1, B4); \ - B3 = _mm_or_si128(B3, B0); \ - B1 = _mm_xor_si128(B1, B3); \ - B4 = _mm_xor_si128(B4, B3); \ - B3 = B0; \ - B0 = B1; \ - B1 = B4; \ +#define SBoxE1(B0, B1, B2, B3) \ + do { \ + B3 = _mm_xor_si128(B3, B0); \ + __m128i B4 = B1; \ + B1 = _mm_and_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B0 = _mm_xor_si128(B0, B4); \ + B4 = _mm_xor_si128(B4, B3); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = _mm_or_si128(B2, B1); \ + B2 = _mm_xor_si128(B2, B4); \ + B4 = _mm_xor_si128(B4, all_ones); \ + B4 = _mm_or_si128(B4, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B4); \ + B3 = _mm_or_si128(B3, B0); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B3); \ + B3 = B0; \ + B0 = B1; \ + B1 = B4; \ } while(0); -#define SBoxE2(B0, B1, B2, B3) \ - do { \ - B0 = _mm_andnot_si128(B0, _mm_set1_epi8(0xFF)); \ - B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ - __m128i B4 = B0; \ - B0 = _mm_and_si128(B0, B1); \ - B2 = _mm_xor_si128(B2, B0); \ - B0 = _mm_or_si128(B0, B3); \ - B3 = _mm_xor_si128(B3, B2); \ - B1 = _mm_xor_si128(B1, B0); \ - B0 = _mm_xor_si128(B0, B4); \ - B4 = _mm_or_si128(B4, B1); \ - B1 = _mm_xor_si128(B1, B3); \ - B2 = _mm_or_si128(B2, B0); \ - B2 = _mm_and_si128(B2, B4); \ - B0 = _mm_xor_si128(B0, B1); \ - B1 = _mm_and_si128(B1, B2); \ - B1 = _mm_xor_si128(B1, B0); \ - B0 = _mm_and_si128(B0, B2); \ - B4 = _mm_xor_si128(B4, B0); \ - B0 = B2; \ - B2 = B3; \ - B3 = B1; \ - B1 = B4; \ +#define SBoxE2(B0, B1, B2, B3) \ + do { \ + B0 = _mm_xor_si128(B0, all_ones); \ + B2 = _mm_xor_si128(B2, all_ones); \ + __m128i B4 = B0; \ + B0 = _mm_and_si128(B0, B1); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B3 = _mm_xor_si128(B3, B2); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_xor_si128(B0, B4); \ + B4 = _mm_or_si128(B4, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B2 = _mm_or_si128(B2, B0); \ + B2 = _mm_and_si128(B2, B4); \ + B0 = _mm_xor_si128(B0, B1); \ + B1 = _mm_and_si128(B1, B2); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_and_si128(B0, B2); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = B2; \ + B2 = B3; \ + B3 = B1; \ + B1 = B4; \ } while(0); -#define SBoxE3(B0, B1, B2, B3) \ - do { \ - __m128i B4 = B0; \ - B0 = _mm_and_si128(B0, B2); \ - B0 = _mm_xor_si128(B0, B3); \ - B2 = _mm_xor_si128(B2, B1); \ - B2 = _mm_xor_si128(B2, B0); \ - B3 = _mm_or_si128(B3, B4); \ - B3 = _mm_xor_si128(B3, B1); \ - B4 = _mm_xor_si128(B4, B2); \ - B1 = B3; \ - B3 = _mm_or_si128(B3, B4); \ - B3 = _mm_xor_si128(B3, B0); \ - B0 = _mm_and_si128(B0, B1); \ - B4 = _mm_xor_si128(B4, B0); \ - B1 = _mm_xor_si128(B1, B3); \ - B1 = _mm_xor_si128(B1, B4); \ - B4 = _mm_andnot_si128(B4, _mm_set1_epi8(0xFF)); \ - B0 = B2; \ - B2 = B1; \ - B1 = B3; \ - B3 = B4; \ +#define SBoxE3(B0, B1, B2, B3) \ + do { \ + __m128i B4 = B0; \ + B0 = _mm_and_si128(B0, B2); \ + B0 = _mm_xor_si128(B0, B3); \ + B2 = _mm_xor_si128(B2, B1); \ + B2 = _mm_xor_si128(B2, B0); \ + B3 = _mm_or_si128(B3, B4); \ + B3 = _mm_xor_si128(B3, B1); \ + B4 = _mm_xor_si128(B4, B2); \ + B1 = B3; \ + B3 = _mm_or_si128(B3, B4); \ + B3 = _mm_xor_si128(B3, B0); \ + B0 = _mm_and_si128(B0, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B1 = _mm_xor_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B4); \ + B4 = _mm_xor_si128(B4, all_ones); \ + B0 = B2; \ + B2 = B1; \ + B1 = B3; \ + B3 = B4; \ } while(0); -#define SBoxE4(B0, B1, B2, B3) \ - do { \ - __m128i B4 = B0; \ - B0 = _mm_or_si128(B0, B3); \ - B3 = _mm_xor_si128(B3, B1); \ - B1 = _mm_and_si128(B1, B4); \ - B4 = _mm_xor_si128(B4, B2); \ - B2 = _mm_xor_si128(B2, B3); \ - B3 = _mm_and_si128(B3, B0); \ - B4 = _mm_or_si128(B4, B1); \ - B3 = _mm_xor_si128(B3, B4); \ - B0 = _mm_xor_si128(B0, B1); \ - B4 = _mm_and_si128(B4, B0); \ - B1 = _mm_xor_si128(B1, B3); \ - B4 = _mm_xor_si128(B4, B2); \ - B1 = _mm_or_si128(B1, B0); \ - B1 = _mm_xor_si128(B1, B2); \ - B0 = _mm_xor_si128(B0, B3); \ - B2 = B1; \ - B1 = _mm_or_si128(B1, B3); \ - B1 = _mm_xor_si128(B1, B0); \ - B0 = B1; \ - B1 = B2; \ - B2 = B3; \ - B3 = B4; \ +#define SBoxE4(B0, B1, B2, B3) \ + do { \ + __m128i B4 = B0; \ + B0 = _mm_or_si128(B0, B3); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_and_si128(B1, B4); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_xor_si128(B2, B3); \ + B3 = _mm_and_si128(B3, B0); \ + B4 = _mm_or_si128(B4, B1); \ + B3 = _mm_xor_si128(B3, B4); \ + B0 = _mm_xor_si128(B0, B1); \ + B4 = _mm_and_si128(B4, B0); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B1 = _mm_or_si128(B1, B0); \ + B1 = _mm_xor_si128(B1, B2); \ + B0 = _mm_xor_si128(B0, B3); \ + B2 = B1; \ + B1 = _mm_or_si128(B1, B3); \ + B0 = _mm_xor_si128(B0, B1); \ + B1 = B2; \ + B2 = B3; \ + B3 = B4; \ } while(0); -#define SBoxE5(B0, B1, B2, B3) \ - do { \ - B1 = _mm_xor_si128(B1, B3); \ - B3 = _mm_andnot_si128(B3, _mm_set1_epi8(0xFF)); \ - B2 = _mm_xor_si128(B2, B3); \ - B3 = _mm_xor_si128(B3, B0); \ - __m128i B4 = B1; \ - B1 = _mm_and_si128(B1, B3); \ - B1 = _mm_xor_si128(B1, B2); \ - B4 = _mm_xor_si128(B4, B3); \ - B0 = _mm_xor_si128(B0, B4); \ - B2 = _mm_and_si128(B2, B4); \ - B2 = _mm_xor_si128(B2, B0); \ - B0 = _mm_and_si128(B0, B1); \ - B3 = _mm_xor_si128(B3, B0); \ - B4 = _mm_or_si128(B4, B1); \ - B4 = _mm_xor_si128(B4, B0); \ - B0 = _mm_or_si128(B0, B3); \ - B0 = _mm_xor_si128(B0, B2); \ - B2 = _mm_and_si128(B2, B3); \ - B0 = _mm_andnot_si128(B0, _mm_set1_epi8(0xFF)); \ - B4 = _mm_xor_si128(B4, B2); \ - B2 = B0; \ - B0 = B1; \ - B1 = B4; \ +#define SBoxE5(B0, B1, B2, B3) \ + do { \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_xor_si128(B3, all_ones); \ + B2 = _mm_xor_si128(B2, B3); \ + B3 = _mm_xor_si128(B3, B0); \ + __m128i B4 = B1; \ + B1 = _mm_and_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B2); \ + B4 = _mm_xor_si128(B4, B3); \ + B0 = _mm_xor_si128(B0, B4); \ + B2 = _mm_and_si128(B2, B4); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_and_si128(B0, B1); \ + B3 = _mm_xor_si128(B3, B0); \ + B4 = _mm_or_si128(B4, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B0 = _mm_xor_si128(B0, B2); \ + B2 = _mm_and_si128(B2, B3); \ + B0 = _mm_xor_si128(B0, all_ones); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B0; \ + B0 = B1; \ + B1 = B4; \ } while(0); -#define SBoxE6(B0, B1, B2, B3) \ - do { \ - B0 = _mm_xor_si128(B0, B1); \ - B1 = _mm_xor_si128(B1, B3); \ - B3 = _mm_andnot_si128(B3, _mm_set1_epi8(0xFF)); \ - __m128i B4 = B1; \ - B1 = _mm_and_si128(B1, B0); \ - B2 = _mm_xor_si128(B2, B3); \ - B1 = _mm_xor_si128(B1, B2); \ - B2 = _mm_or_si128(B2, B4); \ - B4 = _mm_xor_si128(B4, B3); \ - B3 = _mm_and_si128(B3, B1); \ - B3 = _mm_xor_si128(B3, B0); \ - B4 = _mm_xor_si128(B4, B1); \ - B4 = _mm_xor_si128(B4, B2); \ - B2 = _mm_xor_si128(B2, B0); \ - B0 = _mm_and_si128(B0, B3); \ - B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ - B0 = _mm_xor_si128(B0, B4); \ - B4 = _mm_or_si128(B4, B3); \ - B4 = _mm_xor_si128(B4, B2); \ - B2 = B0; \ - B0 = B1; \ - B1 = B3; \ - B3 = B4; \ +#define SBoxE6(B0, B1, B2, B3) \ + do { \ + B0 = _mm_xor_si128(B0, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_xor_si128(B3, all_ones); \ + __m128i B4 = B1; \ + B1 = _mm_and_si128(B1, B0); \ + B2 = _mm_xor_si128(B2, B3); \ + B1 = _mm_xor_si128(B1, B2); \ + B2 = _mm_or_si128(B2, B4); \ + B4 = _mm_xor_si128(B4, B3); \ + B3 = _mm_and_si128(B3, B1); \ + B3 = _mm_xor_si128(B3, B0); \ + B4 = _mm_xor_si128(B4, B1); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_and_si128(B0, B3); \ + B2 = _mm_xor_si128(B2, all_ones); \ + B0 = _mm_xor_si128(B0, B4); \ + B4 = _mm_or_si128(B4, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B0; \ + B0 = B1; \ + B1 = B3; \ + B3 = B4; \ } while(0); -#define SBoxE7(B0, B1, B2, B3) \ - do { \ - B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ - __m128i B4 = B3; \ - B3 = _mm_and_si128(B3, B0); \ - B0 = _mm_xor_si128(B0, B4); \ - B3 = _mm_xor_si128(B3, B2); \ - B2 = _mm_or_si128(B2, B4); \ - B1 = _mm_xor_si128(B1, B3); \ - B2 = _mm_xor_si128(B2, B0); \ - B0 = _mm_or_si128(B0, B1); \ - B2 = _mm_xor_si128(B2, B1); \ - B4 = _mm_xor_si128(B4, B0); \ - B0 = _mm_or_si128(B0, B3); \ - B0 = _mm_xor_si128(B0, B2); \ - B4 = _mm_xor_si128(B4, B3); \ - B4 = _mm_xor_si128(B4, B0); \ - B3 = _mm_andnot_si128(B3, _mm_set1_epi8(0xFF)); \ - B2 = _mm_and_si128(B2, B4); \ - B3 = _mm_xor_si128(B3, B2); \ - B2 = B4; \ +#define SBoxE7(B0, B1, B2, B3) \ + do { \ + B2 = _mm_xor_si128(B2, all_ones); \ + __m128i B4 = B3; \ + B3 = _mm_and_si128(B3, B0); \ + B0 = _mm_xor_si128(B0, B4); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = _mm_or_si128(B2, B4); \ + B1 = _mm_xor_si128(B1, B3); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_or_si128(B0, B1); \ + B2 = _mm_xor_si128(B2, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = _mm_or_si128(B0, B3); \ + B0 = _mm_xor_si128(B0, B2); \ + B4 = _mm_xor_si128(B4, B3); \ + B4 = _mm_xor_si128(B4, B0); \ + B3 = _mm_xor_si128(B3, all_ones); \ + B2 = _mm_and_si128(B2, B4); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = B4; \ } while(0); -#define SBoxE8(B0, B1, B2, B3) \ - do { \ - __m128i B4 = B1; \ - B1 = _mm_or_si128(B1, B2); \ - B1 = _mm_xor_si128(B1, B3); \ - B4 = _mm_xor_si128(B4, B2); \ - B2 = _mm_xor_si128(B2, B1); \ - B3 = _mm_or_si128(B3, B4); \ - B3 = _mm_and_si128(B3, B0); \ - B4 = _mm_xor_si128(B4, B2); \ - B3 = _mm_xor_si128(B3, B1); \ - B1 = _mm_or_si128(B1, B4); \ - B1 = _mm_xor_si128(B1, B0); \ - B0 = _mm_or_si128(B0, B4); \ - B0 = _mm_xor_si128(B0, B2); \ - B1 = _mm_xor_si128(B1, B4); \ - B2 = _mm_xor_si128(B2, B1); \ - B1 = _mm_and_si128(B1, B0); \ - B1 = _mm_xor_si128(B1, B4); \ - B2 = _mm_andnot_si128(B2, _mm_set1_epi8(0xFF)); \ - B2 = _mm_or_si128(B2, B0); \ - B4 = _mm_xor_si128(B4, B2); \ - B2 = B1; \ - B1 = B3; \ - B3 = B0; \ - B0 = B4; \ +#define SBoxE8(B0, B1, B2, B3) \ + do { \ + __m128i B4 = B1; \ + B1 = _mm_or_si128(B1, B2); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_xor_si128(B2, B1); \ + B3 = _mm_or_si128(B3, B4); \ + B3 = _mm_and_si128(B3, B0); \ + B4 = _mm_xor_si128(B4, B2); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_or_si128(B1, B4); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_or_si128(B0, B4); \ + B0 = _mm_xor_si128(B0, B2); \ + B1 = _mm_xor_si128(B1, B4); \ + B2 = _mm_xor_si128(B2, B1); \ + B1 = _mm_and_si128(B1, B0); \ + B1 = _mm_xor_si128(B1, B4); \ + B2 = _mm_xor_si128(B2, all_ones); \ + B2 = _mm_or_si128(B2, B0); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B1; \ + B1 = B3; \ + B3 = B0; \ + B0 = B4; \ } while(0); #endif -- cgit v1.2.3 From fdba61bb05f26f8ed979543b8ee9cfab96295800 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 15:20:34 +0000 Subject: Add SSE2 Serpent decryption --- src/block/serpent_sse2/serp_sse2.cpp | 91 +++++++++++++- src/block/serpent_sse2/serp_sse2_sbox.h | 217 ++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_sse2/serp_sse2.cpp index 5ce7d8f47..a3319afec 100644 --- a/src/block/serpent_sse2/serp_sse2.cpp +++ b/src/block/serpent_sse2/serp_sse2.cpp @@ -24,11 +24,14 @@ namespace { } while(0); /* -* Serpent's linear transformation +* Serpent's linear transformations */ #define rotate_left_m128(vec, rot) \ _mm_or_si128(_mm_slli_epi32(vec, rot), _mm_srli_epi32(vec, 32-rot)) +#define rotate_right_m128(vec, rot) \ + _mm_or_si128(_mm_srli_epi32(vec, rot), _mm_slli_epi32(vec, 32-rot)) + #define transform(B0, B1, B2, B3) \ do { \ B0 = rotate_left_m128(B0, 13); \ @@ -43,6 +46,20 @@ namespace { B2 = rotate_left_m128(B2, 22); \ } while(0); +#define i_transform(B0, B1, B2, B3) \ + do { \ + B2 = rotate_right_m128(B2, 22); \ + B0 = rotate_right_m128(B0, 5); \ + B2 = _mm_xor_si128(B2, _mm_xor_si128(B3, _mm_slli_epi32(B1, 7))); \ + B0 = _mm_xor_si128(B0, _mm_xor_si128(B1, B3)); \ + B3 = rotate_right_m128(B3, 7); \ + B1 = rotate_right_m128(B1, 1); \ + B3 = _mm_xor_si128(B3, _mm_xor_si128(B2, _mm_slli_epi32(B0, 3))); \ + B1 = _mm_xor_si128(B1, _mm_xor_si128(B0, B2)); \ + B2 = rotate_right_m128(B2, 3); \ + B0 = rotate_right_m128(B0, 13); \ + } while(0); + /* * 4x4 SSE2 integer matrix transpose */ @@ -122,6 +139,70 @@ void serpent_encrypt_4(const byte in[64], _mm_storeu_si128(out_mm + 3, B3); } +/* +* SSE2 Serpent Decryption of 4 blocks in parallel +*/ +void serpent_decrypt_4(const byte in[64], + byte out[64], + const u32bit keys_32[132]) + { + const __m128i all_ones = _mm_set1_epi8(0xFF); + + const __m128i* keys = (const __m128i*)(keys_32); + __m128i* out_mm = (__m128i*)(out); + __m128i* in_mm = (__m128i*)(in); + + __m128i B0 = _mm_loadu_si128(in_mm); + __m128i B1 = _mm_loadu_si128(in_mm + 1); + __m128i B2 = _mm_loadu_si128(in_mm + 2); + __m128i B3 = _mm_loadu_si128(in_mm + 3); + + transpose(B0, B1, B2, B3); + + key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(30,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(29,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(28,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(27,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(26,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor(25,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor(24,B0,B1,B2,B3); + + i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(23,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(22,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(21,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(20,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(19,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(18,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor(17,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor(16,B0,B1,B2,B3); + + i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(15,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(14,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor(13,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor(12,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor(11,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor(10,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 9,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 8,B0,B1,B2,B3); + + i_transform(B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor( 7,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor( 6,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD6(B0,B1,B2,B3); key_xor( 5,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD5(B0,B1,B2,B3); key_xor( 4,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD4(B0,B1,B2,B3); key_xor( 3,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD3(B0,B1,B2,B3); key_xor( 2,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 1,B0,B1,B2,B3); + i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 0,B0,B1,B2,B3); + + transpose(B0, B1, B2, B3); + + _mm_storeu_si128(out_mm , B0); + _mm_storeu_si128(out_mm + 1, B1); + _mm_storeu_si128(out_mm + 2, B2); + _mm_storeu_si128(out_mm + 3, B3); + } + } /* @@ -150,6 +231,14 @@ void Serpent_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const */ void Serpent_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const { + while(blocks >= 4) + { + serpent_decrypt_4(in, out, this->round_key); + in += 4 * BLOCK_SIZE; + out += 4 * BLOCK_SIZE; + blocks -= 4; + } + for(u32bit i = 0; i != blocks; ++i) { Serpent::decrypt_n(in, out, 1); diff --git a/src/block/serpent_sse2/serp_sse2_sbox.h b/src/block/serpent_sse2/serp_sse2_sbox.h index 1660643ad..40c552e87 100644 --- a/src/block/serpent_sse2/serp_sse2_sbox.h +++ b/src/block/serpent_sse2/serp_sse2_sbox.h @@ -214,4 +214,221 @@ B0 = B4; \ } while(0); +#define SBoxD1(B0, B1, B2, B3) \ + do \ + { \ + B2 = _mm_xor_si128(B2, all_ones); \ + __m128i B4 = B1; \ + B1 = _mm_or_si128(B1, B0); \ + B4 = _mm_xor_si128(B4, all_ones); \ + B1 = _mm_xor_si128(B1, B2); \ + B2 = _mm_or_si128(B2, B4); \ + B1 = _mm_xor_si128(B1, B3); \ + B0 = _mm_xor_si128(B0, B4); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_and_si128(B0, B3); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = _mm_or_si128(B0, B1); \ + B0 = _mm_xor_si128(B0, B2); \ + B3 = _mm_xor_si128(B3, B4); \ + B2 = _mm_xor_si128(B2, B1); \ + B3 = _mm_xor_si128(B3, B0); \ + B3 = _mm_xor_si128(B3, B1); \ + B2 = _mm_and_si128(B2, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B1; \ + B1 = B4; \ + } while(0); + +#define SBoxD2(B0, B1, B2, B3) \ + do \ + { \ + __m128i B4 = B1; \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_and_si128(B3, B1); \ + B4 = _mm_xor_si128(B4, B2); \ + B3 = _mm_xor_si128(B3, B0); \ + B0 = _mm_or_si128(B0, B1); \ + B2 = _mm_xor_si128(B2, B3); \ + B0 = _mm_xor_si128(B0, B4); \ + B0 = _mm_or_si128(B0, B2); \ + B1 = _mm_xor_si128(B1, B3); \ + B0 = _mm_xor_si128(B0, B1); \ + B1 = _mm_or_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B0); \ + B4 = _mm_xor_si128(B4, all_ones); \ + B4 = _mm_xor_si128(B4, B1); \ + B1 = _mm_or_si128(B1, B0); \ + B1 = _mm_xor_si128(B1, B0); \ + B1 = _mm_or_si128(B1, B4); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = B0; \ + B0 = B4; \ + B4 = B2; \ + B2 = B3; \ + B3 = B4; \ + } while(0); + +#define SBoxD3(B0, B1, B2, B3) \ + do \ + { \ + B2 = _mm_xor_si128(B2, B3); \ + B3 = _mm_xor_si128(B3, B0); \ + __m128i B4 = B3; \ + B3 = _mm_and_si128(B3, B2); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_or_si128(B1, B2); \ + B1 = _mm_xor_si128(B1, B4); \ + B4 = _mm_and_si128(B4, B3); \ + B2 = _mm_xor_si128(B2, B3); \ + B4 = _mm_and_si128(B4, B0); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = _mm_and_si128(B2, B1); \ + B2 = _mm_or_si128(B2, B0); \ + B3 = _mm_xor_si128(B3, all_ones); \ + B2 = _mm_xor_si128(B2, B3); \ + B0 = _mm_xor_si128(B0, B3); \ + B0 = _mm_and_si128(B0, B1); \ + B3 = _mm_xor_si128(B3, B4); \ + B3 = _mm_xor_si128(B3, B0); \ + B0 = B1; \ + B1 = B4; \ + } while(0); + +#define SBoxD4(B0, B1, B2, B3) \ + do \ + { \ + __m128i B4 = B2; \ + B2 = _mm_xor_si128(B2, B1); \ + B0 = _mm_xor_si128(B0, B2); \ + B4 = _mm_and_si128(B4, B2); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = _mm_and_si128(B0, B1); \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_or_si128(B3, B4); \ + B2 = _mm_xor_si128(B2, B3); \ + B0 = _mm_xor_si128(B0, B3); \ + B1 = _mm_xor_si128(B1, B4); \ + B3 = _mm_and_si128(B3, B2); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_xor_si128(B1, B0); \ + B1 = _mm_or_si128(B1, B2); \ + B0 = _mm_xor_si128(B0, B3); \ + B1 = _mm_xor_si128(B1, B4); \ + B0 = _mm_xor_si128(B0, B1); \ + B4 = B0; \ + B0 = B2; \ + B2 = B3; \ + B3 = B4; \ + } while(0); + +#define SBoxD5(B0, B1, B2, B3) \ + do \ + { \ + __m128i B4 = B2; \ + B2 = _mm_and_si128(B2, B3); \ + B2 = _mm_xor_si128(B2, B1); \ + B1 = _mm_or_si128(B1, B3); \ + B1 = _mm_and_si128(B1, B0); \ + B4 = _mm_xor_si128(B4, B2); \ + B4 = _mm_xor_si128(B4, B1); \ + B1 = _mm_and_si128(B1, B2); \ + B0 = _mm_xor_si128(B0, all_ones); \ + B3 = _mm_xor_si128(B3, B4); \ + B1 = _mm_xor_si128(B1, B3); \ + B3 = _mm_and_si128(B3, B0); \ + B3 = _mm_xor_si128(B3, B2); \ + B0 = _mm_xor_si128(B0, B1); \ + B2 = _mm_and_si128(B2, B0); \ + B3 = _mm_xor_si128(B3, B0); \ + B2 = _mm_xor_si128(B2, B4); \ + B2 = _mm_or_si128(B2, B3); \ + B3 = _mm_xor_si128(B3, B0); \ + B2 = _mm_xor_si128(B2, B1); \ + B1 = B3; \ + B3 = B4; \ + } while(0); + +#define SBoxD6(B0, B1, B2, B3) \ + do \ + { \ + B1 = _mm_xor_si128(B1, all_ones); \ + __m128i B4 = B3; \ + B2 = _mm_xor_si128(B2, B1); \ + B3 = _mm_or_si128(B3, B0); \ + B3 = _mm_xor_si128(B3, B2); \ + B2 = _mm_or_si128(B2, B1); \ + B2 = _mm_and_si128(B2, B0); \ + B4 = _mm_xor_si128(B4, B3); \ + B2 = _mm_xor_si128(B2, B4); \ + B4 = _mm_or_si128(B4, B0); \ + B4 = _mm_xor_si128(B4, B1); \ + B1 = _mm_and_si128(B1, B2); \ + B1 = _mm_xor_si128(B1, B3); \ + B4 = _mm_xor_si128(B4, B2); \ + B3 = _mm_and_si128(B3, B4); \ + B4 = _mm_xor_si128(B4, B1); \ + B3 = _mm_xor_si128(B3, B4); \ + B4 = _mm_xor_si128(B4, all_ones); \ + B3 = _mm_xor_si128(B3, B0); \ + B0 = B1; \ + B1 = B4; \ + B4 = B3; \ + B3 = B2; \ + B2 = B4; \ + } while(0); + +#define SBoxD7(B0, B1, B2, B3) \ + do \ + { \ + B0 = _mm_xor_si128(B0, B2); \ + __m128i B4 = B2; \ + B2 = _mm_and_si128(B2, B0); \ + B4 = _mm_xor_si128(B4, B3); \ + B2 = _mm_xor_si128(B2, all_ones); \ + B3 = _mm_xor_si128(B3, B1); \ + B2 = _mm_xor_si128(B2, B3); \ + B4 = _mm_or_si128(B4, B0); \ + B0 = _mm_xor_si128(B0, B2); \ + B3 = _mm_xor_si128(B3, B4); \ + B4 = _mm_xor_si128(B4, B1); \ + B1 = _mm_and_si128(B1, B3); \ + B1 = _mm_xor_si128(B1, B0); \ + B0 = _mm_xor_si128(B0, B3); \ + B0 = _mm_or_si128(B0, B2); \ + B3 = _mm_xor_si128(B3, B1); \ + B4 = _mm_xor_si128(B4, B0); \ + B0 = B1; \ + B1 = B2; \ + B2 = B4; \ + } while(0); + +#define SBoxD8(B0, B1, B2, B3) \ + do \ + { \ + __m128i B4 = B2; \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_and_si128(B0, B3); \ + B4 = _mm_or_si128(B4, B3); \ + B2 = _mm_xor_si128(B2, all_ones); \ + B3 = _mm_xor_si128(B3, B1); \ + B1 = _mm_or_si128(B1, B0); \ + B0 = _mm_xor_si128(B0, B2); \ + B2 = _mm_and_si128(B2, B4); \ + B3 = _mm_and_si128(B3, B4); \ + B1 = _mm_xor_si128(B1, B2); \ + B2 = _mm_xor_si128(B2, B0); \ + B0 = _mm_or_si128(B0, B2); \ + B4 = _mm_xor_si128(B4, B1); \ + B0 = _mm_xor_si128(B0, B3); \ + B3 = _mm_xor_si128(B3, B4); \ + B4 = _mm_or_si128(B4, B0); \ + B3 = _mm_xor_si128(B3, B2); \ + B4 = _mm_xor_si128(B4, B2); \ + B2 = B1; \ + B1 = B0; \ + B0 = B3; \ + B3 = B4; \ + } while(0); + #endif -- cgit v1.2.3 From 1c9b4fda79951b1d0cd3c49ad8db8549cf9d9444 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 18:19:39 +0000 Subject: For handling the last few blocks in Serpent_SSE2, invoke encrypt_n with however many blocks remain, rather than looping calling encrypt_n with a block size of 1 each time. --- src/block/serpent_sse2/serp_sse2.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_sse2/serp_sse2.cpp index a3319afec..c51bb69ab 100644 --- a/src/block/serpent_sse2/serp_sse2.cpp +++ b/src/block/serpent_sse2/serp_sse2.cpp @@ -218,12 +218,7 @@ void Serpent_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const blocks -= 4; } - for(u32bit i = 0; i != blocks; ++i) - { - Serpent::encrypt_n(in, out, 1); - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } + Serpent::encrypt_n(in, out, blocks); } /* @@ -239,12 +234,7 @@ void Serpent_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const blocks -= 4; } - for(u32bit i = 0; i != blocks; ++i) - { - Serpent::decrypt_n(in, out, 1); - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } + Serpent::decrypt_n(in, out, blocks); } } -- cgit v1.2.3 From 690e9fc77872f253004c37d4c6a0707f1a3f1856 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 18:38:15 +0000 Subject: In benchmark.cpp, use encrypt_n when benchmarking block ciphers --- src/benchmark/benchmark.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp index 01e3b94f3..3bbc1f883 100644 --- a/src/benchmark/benchmark.cpp +++ b/src/benchmark/benchmark.cpp @@ -57,8 +57,7 @@ bench_block_cipher(BlockCipher* block_cipher, while(nanoseconds_used < nanoseconds_max) { - for(u32bit i = 0; i != in_blocks; ++i) - block_cipher->encrypt(buf + block_cipher->BLOCK_SIZE * i); + block_cipher->encrypt_n(buf, buf, in_blocks); ++reps; nanoseconds_used = timer.clock() - start; -- cgit v1.2.3 From 921ef0147666aca06693f04155e590e16dde9726 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 12 Aug 2009 20:44:09 +0000 Subject: Use a much faster counter increment system, noticable speedups (~15%) for both Serpent and AES-128 in CTR mode. --- src/modes/ctr/ctr.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/modes/ctr/ctr.cpp b/src/modes/ctr/ctr.cpp index a3476c474..d458d7848 100644 --- a/src/modes/ctr/ctr.cpp +++ b/src/modes/ctr/ctr.cpp @@ -65,21 +65,24 @@ std::string CTR_BE::name() const */ void CTR_BE::set_iv(const InitializationVector& iv) { - if(iv.length() != cipher->BLOCK_SIZE) + const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE; + + if(iv.length() != BLOCK_SIZE) throw Invalid_IV_Length(name(), iv.length()); enc_buffer.clear(); position = 0; - for(u32bit i = 0; i != PARALLEL_BLOCKS; ++i) + counter.copy(0, iv.begin(), iv.length()); + + for(u32bit i = 1; i != PARALLEL_BLOCKS; ++i) { - counter.copy(i*cipher->BLOCK_SIZE, iv.begin(), iv.length()); + counter.copy(i*BLOCK_SIZE, + counter.begin() + (i-1)*BLOCK_SIZE, BLOCK_SIZE); - // FIXME: this is stupid - for(u32bit j = 0; j != i; ++j) - for(s32bit k = cipher->BLOCK_SIZE - 1; k >= 0; --k) - if(++counter[i*cipher->BLOCK_SIZE+k]) - break; + for(s32bit j = BLOCK_SIZE - 1; j >= 0; --j) + if(++counter[i*BLOCK_SIZE+j]) + break; } cipher->encrypt_n(counter, enc_buffer, PARALLEL_BLOCKS); @@ -122,19 +125,17 @@ void CTR_BE::increment_counter() { for(u32bit i = 0; i != PARALLEL_BLOCKS; ++i) { - // FIXME: Can do it in a single loop - /* - for(u32bit j = 1; j != cipher->BLOCK_SIZE; ++j) - { - byte carry = 0; - byte z = counter[(i+1)*cipher->BLOCK_SIZE-1] + PARALLEL_BLOCKS; - - if( - */ - for(u32bit j = 0; j != PARALLEL_BLOCKS; ++j) - for(s32bit k = cipher->BLOCK_SIZE - 1; k >= 0; --k) - if(++counter[i*cipher->BLOCK_SIZE+k]) + byte* this_ctr = counter + i*cipher->BLOCK_SIZE; + + byte last_byte = this_ctr[cipher->BLOCK_SIZE-1]; + last_byte += PARALLEL_BLOCKS; + + if(this_ctr[cipher->BLOCK_SIZE-1] > last_byte) + for(s32bit j = cipher->BLOCK_SIZE - 2; j >= 0; --j) + if(++this_ctr[j]) break; + + this_ctr[cipher->BLOCK_SIZE-1] = last_byte; } cipher->encrypt_n(counter, enc_buffer, PARALLEL_BLOCKS); -- cgit v1.2.3 From 5a1329ff7d80349598e50a1ec63abb5334ddc2ac Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 13 Aug 2009 18:32:38 +0000 Subject: Include basefilt.h in filters.h --- src/filters/filters.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/filters/filters.h b/src/filters/filters.h index 26de6e63c..964be0bd8 100644 --- a/src/filters/filters.h +++ b/src/filters/filters.h @@ -14,8 +14,10 @@ #include #include +#include #include #include + #include #if defined(BOTAN_HAS_BASE64_CODEC) -- cgit v1.2.3 From 6897292463197ed6880d91e76c4ee13f624905c3 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 27 Aug 2009 18:14:55 +0000 Subject: Instead of each SSE2 implementation specifying which compilers + CPUs it works on, have sse2_eng rely on a specific compiler/arch; each sse2 impl depends on the engine anyway, so they will only be loaded if OK. --- src/block/serpent_sse2/info.txt | 12 ------------ src/engine/sse2_eng/info.txt | 9 ++++++++- src/hash/sha1_sse2/info.txt | 12 ------------ 3 files changed, 8 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/block/serpent_sse2/info.txt b/src/block/serpent_sse2/info.txt index 09733e98f..b00ab6e88 100644 --- a/src/block/serpent_sse2/info.txt +++ b/src/block/serpent_sse2/info.txt @@ -10,18 +10,6 @@ serp_sse2.h serp_sse2_sbox.h - -pentium-m -pentium4 -prescott -amd64 - - - -gcc -icc - - serpent sse2_eng diff --git a/src/engine/sse2_eng/info.txt b/src/engine/sse2_eng/info.txt index 6242c7fee..7595b8eb5 100644 --- a/src/engine/sse2_eng/info.txt +++ b/src/engine/sse2_eng/info.txt @@ -10,6 +10,13 @@ eng_sse2.h -ia32 +pentium-m +pentium4 +prescott amd64 + + +gcc +icc + diff --git a/src/hash/sha1_sse2/info.txt b/src/hash/sha1_sse2/info.txt index b8d693b70..995c2513e 100644 --- a/src/hash/sha1_sse2/info.txt +++ b/src/hash/sha1_sse2/info.txt @@ -10,18 +10,6 @@ sha1_sse2.cpp sha1_sse2.h - -pentium-m -pentium4 -prescott -amd64 - - - -gcc -icc - - sha1 sse2_eng -- cgit v1.2.3 From 7c35179056ef9f223eb3ad4c20e16ed8f8540bbb Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 27 Aug 2009 18:15:12 +0000 Subject: Remove unneeded include in xtea.cpp --- src/block/xtea/xtea.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/block/xtea/xtea.cpp b/src/block/xtea/xtea.cpp index 0dba5f2be..77543e1e8 100644 --- a/src/block/xtea/xtea.cpp +++ b/src/block/xtea/xtea.cpp @@ -7,7 +7,6 @@ #include #include -#include namespace Botan { -- cgit v1.2.3 From de705485bccc89a695488ebe69b744433388bf21 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 31 Aug 2009 18:19:09 +0000 Subject: Hoist creation of buffer in Lion encrypt loop --- src/block/lion/lion.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/block/lion/lion.cpp b/src/block/lion/lion.cpp index bfff64b67..83c1e3aa3 100644 --- a/src/block/lion/lion.cpp +++ b/src/block/lion/lion.cpp @@ -16,10 +16,10 @@ namespace Botan { */ void Lion::encrypt_n(const byte in[], byte out[], u32bit blocks) const { + SecureVector buffer(LEFT_SIZE); + for(u32bit i = 0; i != blocks; ++i) { - SecureVector buffer(LEFT_SIZE); - xor_buf(buffer, in, key1, LEFT_SIZE); cipher->set_key(buffer, LEFT_SIZE); cipher->encrypt(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE); @@ -42,10 +42,10 @@ void Lion::encrypt_n(const byte in[], byte out[], u32bit blocks) const */ void Lion::decrypt_n(const byte in[], byte out[], u32bit blocks) const { + SecureVector buffer(LEFT_SIZE); + for(u32bit i = 0; i != blocks; ++i) { - SecureVector buffer(LEFT_SIZE); - xor_buf(buffer, in, key2, LEFT_SIZE); cipher->set_key(buffer, LEFT_SIZE); cipher->encrypt(in + LEFT_SIZE, out + LEFT_SIZE, RIGHT_SIZE); -- cgit v1.2.3 From 74d860bb2b35ee5184f77a1e3e2bb1b5b92cacd6 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 31 Aug 2009 18:37:43 +0000 Subject: Combine the 4 sbox calculations in the key schedule so that all four are computed in parallel. Not a huge win but slightly faster (which affects things like Lion when using Turing), most likely due to more available ILP --- src/stream/turing/turing.cpp | 48 +++++++++++++++++++++++--------------------- src/stream/turing/turing.h | 2 -- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/stream/turing/turing.cpp b/src/stream/turing/turing.cpp index b988568c3..1e2203480 100644 --- a/src/stream/turing/turing.cpp +++ b/src/stream/turing/turing.cpp @@ -217,25 +217,6 @@ u32bit Turing::fixedS(u32bit W) return W; } -/* -* Generate the expanded Turing Sbox tables -*/ -void Turing::gen_sbox(MemoryRegion& S, u32bit which, - const MemoryRegion& K) - { - for(u32bit j = 0; j != 256; ++j) - { - u32bit W = 0, C = j; - - for(u32bit k = 0; k < K.size(); ++k) - { - C = SBOX[get_byte(which, K[k]) ^ C]; - W ^= rotate_left(Q_BOX[C], k + 8*which); - } - S[j] = (W & rotate_right(0x00FFFFFF, 8*which)) | (C << (24 - 8*which)); - } - } - /* * Turing Key Schedule */ @@ -250,10 +231,31 @@ void Turing::key_schedule(const byte key[], u32bit length) PHT(K); - gen_sbox(S0, 0, K); - gen_sbox(S1, 1, K); - gen_sbox(S2, 2, K); - gen_sbox(S3, 3, K); + for(u32bit i = 0; i != 256; ++i) + { + u32bit W0 = 0, C0 = i; + u32bit W1 = 0, C1 = i; + u32bit W2 = 0, C2 = i; + u32bit W3 = 0, C3 = i; + + for(u32bit j = 0; j < K.size(); ++j) + { + C0 = SBOX[get_byte(0, K[j]) ^ C0]; + C1 = SBOX[get_byte(1, K[j]) ^ C1]; + C2 = SBOX[get_byte(2, K[j]) ^ C2]; + C3 = SBOX[get_byte(3, K[j]) ^ C3]; + + W0 ^= rotate_left(Q_BOX[C0], j); + W1 ^= rotate_left(Q_BOX[C1], j + 8); + W2 ^= rotate_left(Q_BOX[C2], j + 16); + W3 ^= rotate_left(Q_BOX[C3], j + 24); + } + + S0[i] = (W0 & 0x00FFFFFF) | (C0 << 24); + S1[i] = (W1 & 0xFF00FFFF) | (C1 << 16); + S2[i] = (W2 & 0xFFFF00FF) | (C2 << 8); + S3[i] = (W3 & 0xFFFFFF00) | C3; + } resync(0, 0); } diff --git a/src/stream/turing/turing.h b/src/stream/turing/turing.h index d48c1d8a8..455d3c612 100644 --- a/src/stream/turing/turing.h +++ b/src/stream/turing/turing.h @@ -29,8 +29,6 @@ class BOTAN_DLL Turing : public StreamCipher void generate(); static u32bit fixedS(u32bit); - static void gen_sbox(MemoryRegion&, u32bit, - const MemoryRegion&); static const u32bit Q_BOX[256]; static const byte SBOX[256]; -- cgit v1.2.3 From 8381ceca38f0eee44e893921cbd74fdb3014f7ba Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 31 Aug 2009 18:40:51 +0000 Subject: Add Rivest's package transform --- doc/log.txt | 2 + src/aont/info.txt | 17 +++++++ src/aont/package.cpp | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/aont/package.h | 45 ++++++++++++++++++ 4 files changed, 192 insertions(+) create mode 100644 src/aont/info.txt create mode 100644 src/aont/package.cpp create mode 100644 src/aont/package.h (limited to 'src') diff --git a/doc/log.txt b/doc/log.txt index 992829b39..a84e72d62 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -2,6 +2,8 @@ * 1.9.0-pre, 2009-??-?? - Add support for parallel invocation of block ciphers where possible - Add SSE2 implementation of Serpent + - Add Rivest's package transform (an all or nothing transform) + - Minor speedups to the Turing key schedule * 1.8.6, 2009-08-13 - Add Cryptobox, a set of simple password-based encryption routines diff --git a/src/aont/info.txt b/src/aont/info.txt new file mode 100644 index 000000000..a0387f358 --- /dev/null +++ b/src/aont/info.txt @@ -0,0 +1,17 @@ +realname "All or Nothing Transforms" + +define PACKAGE_TRANSFORM + +load_on auto + + +package.cpp +package.h + + + +block +ctr +rng +filters + diff --git a/src/aont/package.cpp b/src/aont/package.cpp new file mode 100644 index 000000000..6c6b56865 --- /dev/null +++ b/src/aont/package.cpp @@ -0,0 +1,128 @@ +/* +* Rivest's Package Tranform +* +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include +#include +#include +#include + +namespace Botan { + +namespace AllOrNothingTransform { + +void package(RandomNumberGenerator& rng, + BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]) + { + if(!cipher->valid_keylength(cipher->BLOCK_SIZE)) + throw Invalid_Argument("AONT::package: Invalid cipher"); + + // The all-zero string which is used both as the CTR IV and as K0 + const std::string all_zeros(cipher->BLOCK_SIZE*2, '0'); + + SymmetricKey package_key(rng, cipher->BLOCK_SIZE); + + // takes ownership of cipher object + Keyed_Filter* ctr_mode = new CTR_BE(cipher, + package_key, + InitializationVector(all_zeros)); + + Pipe pipe(ctr_mode); + + pipe.process_msg(input, input_len); + pipe.read(output, pipe.remaining()); + + // Set K0 (the all zero key) + cipher->set_key(SymmetricKey(all_zeros)); + + SecureVector buf(cipher->BLOCK_SIZE); + + const u32bit blocks = + (input_len + cipher->BLOCK_SIZE - 1) / cipher->BLOCK_SIZE; + + byte* final_block = output + input_len; + clear_mem(final_block, cipher->BLOCK_SIZE); + + // XOR the hash blocks into the final block + for(u32bit i = 0; i != blocks; ++i) + { + u32bit left = std::min(cipher->BLOCK_SIZE, + input_len - cipher->BLOCK_SIZE * i); + + buf.clear(); + copy_mem(&buf[0], output + cipher->BLOCK_SIZE * i, left); + + for(u32bit j = 0; j != 4; ++j) + buf[cipher->BLOCK_SIZE - 1 - j] ^= get_byte(3-j, i); + + cipher->encrypt(buf); + + xor_buf(final_block, buf, cipher->BLOCK_SIZE); + } + + // XOR the random package key into the final block + xor_buf(final_block, package_key.begin(), cipher->BLOCK_SIZE); + } + +void unpackage(BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]) + { + if(!cipher->valid_keylength(cipher->BLOCK_SIZE)) + throw Invalid_Argument("AONT::unpackage: Invalid cipher"); + + if(input_len < cipher->BLOCK_SIZE) + throw Invalid_Argument("AONT::unpackage: Input too short"); + + // The all-zero string which is used both as the CTR IV and as K0 + const std::string all_zeros(cipher->BLOCK_SIZE*2, '0'); + + cipher->set_key(SymmetricKey(all_zeros)); + + SecureVector package_key(cipher->BLOCK_SIZE); + SecureVector buf(cipher->BLOCK_SIZE); + + // Copy the package key (masked with the block hashes) + copy_mem(&package_key[0], + input + (input_len - cipher->BLOCK_SIZE), + cipher->BLOCK_SIZE); + + const u32bit blocks = ((input_len - 1) / cipher->BLOCK_SIZE); + + // XOR the blocks into the package key bits + for(u32bit i = 0; i != blocks; ++i) + { + u32bit left = std::min(cipher->BLOCK_SIZE, + input_len - cipher->BLOCK_SIZE * (i+1)); + + buf.clear(); + copy_mem(&buf[0], input + cipher->BLOCK_SIZE * i, left); + + for(u32bit j = 0; j != 4; ++j) + buf[cipher->BLOCK_SIZE - 1 - j] ^= get_byte(3-j, i); + + cipher->encrypt(buf); + + xor_buf(&package_key[0], buf, cipher->BLOCK_SIZE); + } + + // takes ownership of cipher object + Pipe pipe(new CTR_BE(cipher, + SymmetricKey(package_key), + InitializationVector(all_zeros))); + + pipe.process_msg(input, input_len - cipher->BLOCK_SIZE); + + pipe.read(output, pipe.remaining()); + } + +} + +} diff --git a/src/aont/package.h b/src/aont/package.h new file mode 100644 index 000000000..35d2a23fc --- /dev/null +++ b/src/aont/package.h @@ -0,0 +1,45 @@ +/* +* Rivest's Package Tranform +* +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include + +namespace Botan { + +namespace AllOrNothingTransform { + +/** +* Rivest's Package Tranform +* @arg rng the random number generator to use +* @arg cipher the block cipher to use +* @arg input the input data buffer +* @arg input_len the length of the input data in bytes +* @arg output the output data buffer (must be at least +* input_len + cipher->BLOCK_SIZE bytes long) +*/ +void package(RandomNumberGenerator& rng, + BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]); + +/** +* Rivest's Package Tranform (Inversion) +* @arg rng the random number generator to use +* @arg cipher the block cipher to use +* @arg input the input data buffer +* @arg input_len the length of the input data in bytes +* @arg output the output data buffer (must be at least +* input_len - cipher->BLOCK_SIZE bytes long) +*/ +void unpackage(BlockCipher* cipher, + const byte input[], u32bit input_len, + byte output[]); + +} + +} -- cgit v1.2.3 From f7595eeae651ff36709793989fd1688303915f5a Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 4 Sep 2009 16:11:40 +0000 Subject: According to the Linux sources, S/390 and PowerPC can both do unaligned memory accesses. Since this can be a pretty big win, enable it for them. The m68k apparently also can, except in its (modern) Coldfire version, but it's always big endian so mark that as such. --- src/build-data/arch/m68k | 5 +++++ src/build-data/arch/ppc | 1 + src/build-data/arch/s390 | 3 +++ src/build-data/arch/s390x | 3 +++ 4 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/build-data/arch/m68k b/src/build-data/arch/m68k index 27f246abc..759a3dac1 100644 --- a/src/build-data/arch/m68k +++ b/src/build-data/arch/m68k @@ -2,6 +2,11 @@ realname "Motorola 680x0" default_submodel 68020 +endian big + +# Except for Coldfire +#unaligned ok + 680x0 68k diff --git a/src/build-data/arch/ppc b/src/build-data/arch/ppc index 16112f389..e2dfa6ea2 100644 --- a/src/build-data/arch/ppc +++ b/src/build-data/arch/ppc @@ -1,6 +1,7 @@ realname "PowerPC" endian big +unaligned ok default_submodel ppc604 diff --git a/src/build-data/arch/s390 b/src/build-data/arch/s390 index 392f51397..312b262c4 100644 --- a/src/build-data/arch/s390 +++ b/src/build-data/arch/s390 @@ -2,6 +2,9 @@ realname "S/390 31-bit" default_submodel s390 +endian big +unaligned ok + s390 diff --git a/src/build-data/arch/s390x b/src/build-data/arch/s390x index 49fb0bda7..9fe6bd615 100644 --- a/src/build-data/arch/s390x +++ b/src/build-data/arch/s390x @@ -2,6 +2,9 @@ realname "S/390 64-bit" default_submodel s390x +endian big +unaligned ok + s390x -- cgit v1.2.3 From 0a7e8ead1a85f7003b729742d795730f2b782116 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 8 Sep 2009 15:22:31 +0000 Subject: Add *s before comment lines in file headers --- src/algo_factory/algo_factory.cpp | 4 ++-- src/libstate/scan_name.cpp | 4 ++-- src/libstate/scan_name.h | 4 ++-- src/mac/mac.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index 269c58c3b..3523b19d4 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -1,6 +1,6 @@ /* -Algorithm Factory -(C) 2008 Jack Lloyd +* Algorithm Factory +* (C) 2008 Jack Lloyd * * Distributed under the terms of the Botan license */ diff --git a/src/libstate/scan_name.cpp b/src/libstate/scan_name.cpp index ef771871d..88992d66e 100644 --- a/src/libstate/scan_name.cpp +++ b/src/libstate/scan_name.cpp @@ -1,6 +1,6 @@ /** -SCAN Name Abstraction -(C) 2008 Jack Lloyd +* SCAN Name Abstraction +* (C) 2008 Jack Lloyd * * Distributed under the terms of the Botan license */ diff --git a/src/libstate/scan_name.h b/src/libstate/scan_name.h index 9e7af40d6..b3f2004e2 100644 --- a/src/libstate/scan_name.h +++ b/src/libstate/scan_name.h @@ -1,6 +1,6 @@ /** -SCAN Name Abstraction -(C) 2008 Jack Lloyd +* SCAN Name Abstraction +* (C) 2008 Jack Lloyd * * Distributed under the terms of the Botan license */ diff --git a/src/mac/mac.cpp b/src/mac/mac.cpp index 96df25503..04b259647 100644 --- a/src/mac/mac.cpp +++ b/src/mac/mac.cpp @@ -1,6 +1,6 @@ /** -Message Authentication Code base class -(C) 1999-2008 Jack Lloyd +* Message Authentication Code base class +* (C) 1999-2008 Jack Lloyd * * Distributed under the terms of the Botan license */ -- cgit v1.2.3 From 166e979eebe6e3f136df4deba626b584e1d735ae Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 8 Sep 2009 15:54:09 +0000 Subject: Throw Internal_Error instead of Algorithm_Not_Found if no usable RNG is enabled in the build. --- src/rng/auto_rng/auto_rng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rng/auto_rng/auto_rng.cpp b/src/rng/auto_rng/auto_rng.cpp index 171c83cca..07b2ddec2 100644 --- a/src/rng/auto_rng/auto_rng.cpp +++ b/src/rng/auto_rng/auto_rng.cpp @@ -140,7 +140,7 @@ AutoSeeded_RNG::AutoSeeded_RNG(u32bit poll_bits) #endif if(!rng) - throw Algorithm_Not_Found("No usable RNG found enabled in build"); + throw Internal_Error("No usable RNG found enabled in build"); /* If X9.31 is available, use it to wrap the other RNG as a failsafe */ #if defined(BOTAN_HAS_X931_RNG) -- cgit v1.2.3 From 1a0f377896cb88b9933b857579113283324d9464 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 9 Sep 2009 15:15:26 +0000 Subject: The first argument of Library_State::set_option was accidentally being passed as a 'const std::string' instead of a const reference. Can't fix in 1.8 since it is ABI breaking. --- src/libstate/libstate.cpp | 2 +- src/libstate/libstate.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 3275c6493..20e736868 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -212,7 +212,7 @@ std::string Library_State::deref_alias(const std::string& key) const /* * Set/Add an option */ -void Library_State::set_option(const std::string key, +void Library_State::set_option(const std::string& key, const std::string& value) { set("conf", key, value); diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h index 2493863a9..a0421953e 100644 --- a/src/libstate/libstate.h +++ b/src/libstate/libstate.h @@ -77,7 +77,7 @@ class BOTAN_DLL Library_State * @param key the key of the option to set * @param value the value to set */ - void set_option(const std::string key, const std::string& value); + void set_option(const std::string& key, const std::string& value); /** * Add a parameter value to the "alias" section. -- cgit v1.2.3 From d61103aada1e69598792addb026aa9f10137e586 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 10 Sep 2009 00:16:18 +0000 Subject: Add parallel block toggles for CBC and CFB (decrypt direction only) --- src/build-data/buildh.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index bd900d412..e0d8368ed 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -22,8 +22,14 @@ #define BOTAN_KARAT_SQR_THRESHOLD 32 #define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64 -/* Toggles for parallel block cipher mode processing */ +/* +* Toggles for parallel block cipher mode processing +* +* CBC and CFB can only use parallel processing in decryption mode +*/ #define BOTAN_PARALLEL_BLOCKS_ECB 8 +#define BOTAN_PARALLEL_BLOCKS_CBC 8 +#define BOTAN_PARALLEL_BLOCKS_CFB 8 #define BOTAN_PARALLEL_BLOCKS_CTR 8 #define BOTAN_PARALLEL_BLOCKS_EAX 8 #define BOTAN_PARALLEL_BLOCKS_XTS 8 -- cgit v1.2.3 From a10e163e3a557cbc2d5291ab45ad068158cff525 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sun, 13 Sep 2009 17:59:36 +0000 Subject: Make some changes to the SSE2 implementation of SHA-1 for compatability with Visual C++. --- src/hash/sha1_sse2/sha1_sse2_imp.cpp | 108 +++++++++++++++-------------------- 1 file changed, 46 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/hash/sha1_sse2/sha1_sse2_imp.cpp b/src/hash/sha1_sse2/sha1_sse2_imp.cpp index 90a8dccd5..57b287bdb 100644 --- a/src/hash/sha1_sse2/sha1_sse2_imp.cpp +++ b/src/hash/sha1_sse2/sha1_sse2_imp.cpp @@ -20,8 +20,10 @@ * on a Linux/Core2 system. */ + #include -#include +#include +#include namespace Botan { @@ -30,21 +32,13 @@ namespace { typedef union { u32bit u32[4]; __m128i u128; - } v4si __attribute__((aligned(16))); + } v4si; static const v4si K00_19 = { { 0x5a827999, 0x5a827999, 0x5a827999, 0x5a827999 } }; static const v4si K20_39 = { { 0x6ed9eba1, 0x6ed9eba1, 0x6ed9eba1, 0x6ed9eba1 } }; static const v4si K40_59 = { { 0x8f1bbcdc, 0x8f1bbcdc, 0x8f1bbcdc, 0x8f1bbcdc } }; static const v4si K60_79 = { { 0xca62c1d6, 0xca62c1d6, 0xca62c1d6, 0xca62c1d6 } }; -#define UNALIGNED 1 -#if UNALIGNED -#define load(p) _mm_loadu_si128(p) -#else -#define load(p) (*p) -#endif - - /* the first 16 bytes only need byte swapping @@ -57,19 +51,15 @@ and is overwritten with the swapped bytes __m128i r1, r2; \ \ r1 = (W); \ - if (1) { \ r1 = _mm_shufflehi_epi16(r1, _MM_SHUFFLE(2, 3, 0, 1)); \ r1 = _mm_shufflelo_epi16(r1, _MM_SHUFFLE(2, 3, 0, 1)); \ r2 = _mm_slli_epi16(r1, 8); \ r1 = _mm_srli_epi16(r1, 8); \ r1 = _mm_or_si128(r1, r2); \ (W) = r1; \ - } \ (prep).u128 = _mm_add_epi32(K00_19.u128, r1); \ } while(0) - - /* for each multiple of 4, t, we want to calculate this: @@ -115,45 +105,38 @@ W0 = W[t]..W[t+3] * efficeon, pentium-m, and opteron but shifts are available in * only one unit. */ -#define prep(prep, XW0, XW1, XW2, XW3, K) do { \ - __m128i r0, r1, r2, r3; \ - \ - /* load W[t-4] 16-byte aligned, and shift */ \ - r3 = _mm_srli_si128((XW3), 4); \ - r0 = (XW0); \ - /* get high 64-bits of XW0 into low 64-bits */ \ - r1 = _mm_shuffle_epi32((XW0), _MM_SHUFFLE(1,0,3,2)); \ - /* load high 64-bits of r1 */ \ - r1 = _mm_unpacklo_epi64(r1, (XW1)); \ - r2 = (XW2); \ - \ - r0 = _mm_xor_si128(r1, r0); \ - r2 = _mm_xor_si128(r3, r2); \ - r0 = _mm_xor_si128(r2, r0); \ - /* unrotated W[t]..W[t+2] in r0 ... still need W[t+3] */ \ - \ - r2 = _mm_slli_si128(r0, 12); \ - r1 = _mm_cmplt_epi32(r0, _mm_setzero_si128()); \ - r0 = _mm_add_epi32(r0, r0); /* shift left by 1 */ \ - r0 = _mm_sub_epi32(r0, r1); /* r0 has W[t]..W[t+2] */ \ - \ - r3 = _mm_srli_epi32(r2, 30); \ - r2 = _mm_slli_epi32(r2, 2); \ - \ - r0 = _mm_xor_si128(r0, r3); \ - r0 = _mm_xor_si128(r0, r2); /* r0 now has W[t+3] */ \ - \ - (XW0) = r0; \ - (prep).u128 = _mm_add_epi32(r0, (K).u128); \ - } while(0) - - -static inline u32bit rol(u32bit src, u32bit amt) - { - /* gcc and icc appear to turn this into a rotate */ - return (src << amt) | (src >> (32 - amt)); - } - +#define prep(prep, XW0, XW1, XW2, XW3, K) \ + do { \ + __m128i r0, r1, r2, r3; \ + \ + /* load W[t-4] 16-byte aligned, and shift */ \ + r3 = _mm_srli_si128((XW3), 4); \ + r0 = (XW0); \ + /* get high 64-bits of XW0 into low 64-bits */ \ + r1 = _mm_shuffle_epi32((XW0), _MM_SHUFFLE(1,0,3,2)); \ + /* load high 64-bits of r1 */ \ + r1 = _mm_unpacklo_epi64(r1, (XW1)); \ + r2 = (XW2); \ + \ + r0 = _mm_xor_si128(r1, r0); \ + r2 = _mm_xor_si128(r3, r2); \ + r0 = _mm_xor_si128(r2, r0); \ + /* unrotated W[t]..W[t+2] in r0 ... still need W[t+3] */ \ + \ + r2 = _mm_slli_si128(r0, 12); \ + r1 = _mm_cmplt_epi32(r0, _mm_setzero_si128()); \ + r0 = _mm_add_epi32(r0, r0); /* shift left by 1 */ \ + r0 = _mm_sub_epi32(r0, r1); /* r0 has W[t]..W[t+2] */ \ + \ + r3 = _mm_srli_epi32(r2, 30); \ + r2 = _mm_slli_epi32(r2, 2); \ + \ + r0 = _mm_xor_si128(r0, r3); \ + r0 = _mm_xor_si128(r0, r2); /* r0 now has W[t+3] */ \ + \ + (XW0) = r0; \ + (prep).u128 = _mm_add_epi32(r0, (K).u128); \ + } while(0) static inline u32bit f00_19(u32bit x, u32bit y, u32bit z) { @@ -184,11 +167,12 @@ static inline u32bit f60_79(u32bit x, u32bit y, u32bit z) return f20_39(x, y, z); } -#define step(nn_mm, xa, xb, xc, xd, xe, xt, input) do { \ - (xt) = (input) + f##nn_mm((xb), (xc), (xd)); \ - (xb) = rol((xb), 30); \ - (xt) += ((xe) + rol((xa), 5)); \ - } while(0) +#define step(nn_mm, xa, xb, xc, xd, xe, xt, input) \ + do { \ + (xt) = (input) + f##nn_mm((xb), (xc), (xd)); \ + (xb) = rotate_left((xb), 30); \ + (xt) += ((xe) + rotate_left((xa), 5)); \ + } while(0) } @@ -210,14 +194,14 @@ extern "C" void botan_sha1_sse2_compress(u32bit H[5], * steps ahead of the integer code. 12 steps ahead seems * to produce the best performance. -dean */ - W0 = load(&input[0]); + W0 = _mm_loadu_si128(&input[0]); prep00_15(prep0, W0); /* prepare for 00 through 03 */ - W1 = load(&input[1]); + W1 = _mm_loadu_si128(&input[1]); prep00_15(prep1, W1); /* prepare for 04 through 07 */ - W2 = load(&input[2]); + W2 = _mm_loadu_si128(&input[2]); prep00_15(prep2, W2); /* prepare for 08 through 11 */ - W3 = load(&input[3]); + W3 = _mm_loadu_si128(&input[3]); step(00_19, a, b, c, d, e, t, prep0.u32[0]); /* 00 */ step(00_19, t, a, b, c, d, e, prep0.u32[1]); /* 01 */ step(00_19, e, t, a, b, c, d, prep0.u32[2]); /* 02 */ -- cgit v1.2.3 From 02fc388212efa21a3f489a28e7b3738956a1358c Mon Sep 17 00:00:00 2001 From: lloyd Date: Sun, 13 Sep 2009 18:00:05 +0000 Subject: Enable SSE2 engine under VC++ --- src/engine/sse2_eng/info.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/engine/sse2_eng/info.txt b/src/engine/sse2_eng/info.txt index 7595b8eb5..7508b9874 100644 --- a/src/engine/sse2_eng/info.txt +++ b/src/engine/sse2_eng/info.txt @@ -19,4 +19,5 @@ amd64 gcc icc +msvc -- cgit v1.2.3 From 7f6a017a61fc6ef97d9d7b37236df52d6170e7d6 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 15 Sep 2009 14:14:32 +0000 Subject: Add an implementation of Blue Midnight Wish (512 bit version only) --- checks/algos.cpp | 2 +- checks/validate.dat | 1914 +++++++++++++++++++++++++++++++++ doc/examples/bench.cpp | 43 +- doc/log.txt | 1 + src/engine/def_engine/lookup_hash.cpp | 9 + src/hash/bmw/bmw_512.cpp | 174 +++ src/hash/bmw/bmw_512.h | 31 + src/hash/bmw/info.txt | 14 + 8 files changed, 2164 insertions(+), 24 deletions(-) create mode 100644 src/hash/bmw/bmw_512.cpp create mode 100644 src/hash/bmw/bmw_512.h create mode 100644 src/hash/bmw/info.txt (limited to 'src') diff --git a/checks/algos.cpp b/checks/algos.cpp index dff903e21..fd75bc463 100644 --- a/checks/algos.cpp +++ b/checks/algos.cpp @@ -74,10 +74,10 @@ std::vector get_algos() algos.push_back(algorithm("Hash", "Adler32")); algos.push_back(algorithm("Hash", "CRC24")); algos.push_back(algorithm("Hash", "CRC32")); + algos.push_back(algorithm("Hash", "BMW-512")); algos.push_back(algorithm("Hash", "FORK-256")); algos.push_back(algorithm("Hash", "GOST-34.11")); algos.push_back(algorithm("Hash", "HAS-160")); - algos.push_back(algorithm("Hash", "HAS-V")); algos.push_back(algorithm("Hash", "MD2")); algos.push_back(algorithm("Hash", "MD4")); algos.push_back(algorithm("Hash", "MD5")); diff --git a/checks/validate.dat b/checks/validate.dat index 524cc4b2f..19db5441f 100644 --- a/checks/validate.dat +++ b/checks/validate.dat @@ -30753,6 +30753,1920 @@ D8C1D4BD9C3086F1FDA0ECD33C4FFAFF:72D73FE9 # MARKER: Hash Functions # Hash function format is input:hash +[BMW-512] +:\ +73DB7B1DC6DEF4DDF2F94A22E1F6D2162B3123828369FF4FD750832AEDE94E52\ +D4D5C8B866860424991527175B6F62DBE0F764AC18290B92A26812D641CD5287 + +CC:\ +9840F373D940E19FB25945134874977D0A4562CA50F358013E72C9679B3C82BD\ +3988E1BF8FE495C7FBC7D5F2B5F1EEDFC65EB8E54A7D039FA51661C0D4733484 + +41FB:\ +92B5AD91B8F774D1BDA764B10658BFB714E742EE872E0AABC3E0456DB1A7A8AF\ +40768A8EDFFDC995C1F84151F94E3EFAB9978F03CCBCB29A2170AA291F22E0AC + +1F877C:\ +159F8BEE2626872E66E7378F9C9D814411630F47B5B2F5F76FAA2140517238BB\ +8781257F20C896F4FA4DFECBC4CB2D1E5932EDEDC5D35E0F3D1C1C93766881CB + +C1ECFDFC:\ +63F6DA9795970160FE9431D1046972B2815D9793AE146102FA8941FCC8B3D447\ +369DCC78E6EE054775DD081E59BA3E0D0653497993CDD413DA1BC099C48D75C0 + +21F134AC57:\ +042445884DCC2C42B7B6C463B402B0538AE18BB9BAE1D0A85F13FD2A6A6F2FD2\ +CB8B78D25D6A98C33848EEBC2D84513B54901A208812D629EBE354BDD6C978AE + +C6F50BB74E29:\ +05D923A6960DFF2151830FBCDB9C45E4FDD62B3CEB9CB1780787A07F7CAE5278\ +69D346707CFBAB8D0C853F609D7B494DCD6DCB0F911CD27DA11702D357DB5432 + +119713CC83EEEF:\ +EBAEDFE8FDFCC34ABE5939FD2A3F520263BA3C1103084C1F8B66180FCDB7264D\ +2384C6151791E72401A8AFF1000229EDF0ECAB8316F44C1F0D39616758951668 + +4A4F202484512526:\ +745995D3EEF74E331B94C791D96CE8A33716379E4D9DF744460ABE87F6495149\ +BD1B71DA2F884850F520866123FBEFB5D51F6330398A1E86380B622C437E4C9B + +1F66AB4185ED9B6375:\ +0551C3FE28BC3E0ADB52A201FEBD788B7F39DB7342934D10AC8FA87DBB52F2BD\ +B81F5BB316098D2236041083B37854720CD7A6B325405C58A9C690AEBBBC9630 + +EED7422227613B6F53C9:\ +6BABFCFDF2AD51C3BC23F3B5961375B0C5EF16A3E56628ACC052A86188FB94EB\ +0E0516187737BB716D9228E115219D5C5A64E608721952A8DC3506233E814DE4 + +EAEED5CDFFD89DECE455F1:\ +735E5418F3586FCF2DA76018A9B1816AB70031FB23A43D394B5DECD9953C1810\ +3DC129ACE0EF740B3C15B914921ED1EC4AA1078D8F5456F2A24B6109FCB5B2C6 + +5BE43C90F22902E4FE8ED2D3:\ +30F325A100BE24398ABB02FE6F86F9DCEE4D77873EFB5A4FD8EF89547D8143DC\ +B05067EE69015C915DD26889DD360C28D155CECABAE7852AB853125997602053 + +A746273228122F381C3B46E4F1:\ +CA08832D082A30BFC303C4854994B905EB5A115B76E1772EC5D3DD5576681121\ +A0ADF3DF365391E764AD0C0054CD0190F9BDFFAC6A4EE3C47139B6F2A550A365 + +3C5871CD619C69A63B540EB5A625:\ +9192799953AE4140D2D210DF6291C40F09F91B2D440EC81EB10FA06FA183A6D5\ +8C6D20F7B69365155E431323DFA8B52ACF23A0E5CA2392F5C606F8463567D793 + +FA22874BCC068879E8EF11A69F0722:\ +D760AE02DFB92518516BF94F16F366700BE7043DF94DFD6DE89E2773EAE7ECE4\ +E6CA64A82E29402550DE531A72CC74F9BD7E8DAEFA91D4B36E092D9C87D98117 + +52A608AB21CCDD8A4457A57EDE782176:\ +58B7F75E1F58C8235471511D88C4513FCB60C03C47E20D5FF198F5E0DD980A84\ +4C343598486573EF972198BA506BF2C07BDA6C83E71F6C42D290B9412A7F5118 + +82E192E4043DDCD12ECF52969D0F807EED:\ +B8E6C00BEEECE767393D959B3137CDB4F69EF82AFB8A6BFA99375B7BD33918C8\ +8D59197675612D7DC8D42947A3CE22F3A167B396B2E7F0E29C677369E4B7C937 + +75683DCB556140C522543BB6E9098B21A21E:\ +B578944870EC6AE4AF742DBD72EB2067772467ADDE3EE007CDE159C8BFAA7CE4\ +83FFDC7C89B2C73363823CA58949880A289C7B61EC0A1D207C3AE95B3CF5C183 + +06E4EFE45035E61FAAF4287B4D8D1F12CA97E5:\ +64D481A9BD15634C715EF3E8AF4FC94664FC380B51218E9786AFAC187B362B00\ +8DD54ADD1B62779A35A10A991C27F22A7A624B451DBEF425E3633B50EDE78835 + +E26193989D06568FE688E75540AEA06747D9F851:\ +7DBF6124910547C284FB8664B197DB48E1CA950A13DE136DF86EF41C6D9AF327\ +E493D0171C6D8426F938445B260B779F8F28667C7525067B55273B25AA553A9D + +D8DC8FDEFBDCE9D44E4CBAFE78447BAE3B5436102A:\ +76831676159CBC50D761800DE6C042D0CADD770840799F31970DE8B147D751AD\ +014A6D0E0ABA7441A4CCD3AADBB175923E33D1343AF83DB0AA943AFAA7DB5DAF + +57085FD7E14216AB102D8317B0CB338A786D5FC32D8F:\ +3F00ECD88535CF4EAD4644134C13473BAEF3F9223660C41E0B2BE8CE08DEF2B3\ +24DFED32E559880031A19DE2BAEF73296F980AC0B87B9620FB0CEBF5CC812016 + +A05404DF5DBB57697E2C16FA29DEFAC8AB3560D6126FA0:\ +A5DF86B0021E4028EC79AEE1DF59CEBBD071F041D82F10DE014BB19445C07E78\ +2DA69484F1F93CBA27264E83759DD54CB1D88DAF883862F0176F451702336C69 + +AECBB02759F7433D6FCB06963C74061CD83B5B3FFA6F13C6:\ +F3172A73831AD1596F920735786B83F6236BBCC121C805DC31067362C530CED0\ +304E8CAD619BC4162760AAF34353E581A5CA43CC74CEB6F11D72C4401CC48C7D + +AAFDC9243D3D4A096558A360CC27C8D862F0BE73DB5E88AA55:\ +B7A8160FACFA8A4110558796D99A793D714E128E5D3CEE5188FB2C85880498BC\ +884B0DA80AE65D1275EF5B8207FEEEF1ED55278B271571F64C63A37C822DBF5B + +7BC84867F6F9E9FDC3E1046CAE3A52C77ED485860EE260E30B15:\ +50A1BF96E0DE3CF9B9A7FC4C97E1BB02BC843113E731472FAE6970C6351F7E40\ +71F909435DA1707A52288252CABF2B46C0167A674C17159F053AFBF7008B2CBA + +FAC523575A99EC48279A7A459E98FF901918A475034327EFB55843:\ +C73850851A15D4B730D97773A82788B4486AAD26092EF29E980D5315BF0414E3\ +8FB300C5900B708B11D51F90124D603AF84C870594BC1DCD119E406F9BE92762 + +0F8B2D8FCFD9D68CFFC17CCFB117709B53D26462A3F346FB7C79B85E:\ +6B3491AEB10987090D570688DADAF9EB5F3A6A8131FAD207DC4505DBF3AEE8FF\ +0D81AA3D6D066AF9F64333226BB3FAC7F363D44C30BEADF623D3FF452EACB818 + +A963C3E895FF5A0BE4824400518D81412F875FA50521E26E85EAC90C04:\ +EC5930D611D58A2B87B8505256BDC24D150C238CCDE3C7AA9FA9A2470BEDDE29\ +591208BD924C474CD849B9B005BD4D930D0BACF87DB15D7395E68FBDF8FC0435 + +03A18688B10CC0EDF83ADF0A84808A9718383C4070C6C4F295098699AC2C:\ +7D2A97D59AF2707F481804C7A3BCC6D226941406CB1852A28475F3434B512F22\ +D5EE88E7FB47EB065745417CB8D5001FCD7072349090BCC1F8A5E8BED877886B + +84FB51B517DF6C5ACCB5D022F8F28DA09B10232D42320FFC32DBECC3835B29:\ +9429625B5A17F44E3B1B56436FE8348C4D3FD2CD634884A0DFBB24AF765FA415\ +DC223A6D6A7818CEB1557693A364434D363760D51266C067B5E22A4B07A7B643 + +9F2FCC7C90DE090D6B87CD7E9718C1EA6CB21118FC2D5DE9F97E5DB6AC1E9C10:\ +994F4F57EEAFC3C4CC9D5275906A15BFDBDA5EA71C4479FCD420AF19062A3651\ +2F1D4C3298F08BB23CEE9756CC0927249792948095E085B3EA98FC25346FE471 + +DE8F1B3FAA4B7040ED4563C3B8E598253178E87E4D0DF75E4FF2F2DEDD5A0BE0\ +46:\ +E589801B2213C47DD246602C5F018E5A53267FDF5D087092BAEF60BBBD878B7D\ +05C6247924C9E49B7BE22F578F245186B6E8275A3EA543FC0388DB167A4B0A67 + +62F154EC394D0BC757D045C798C8B87A00E0655D0481A7D2D9FB58D93AEDC676\ +B5A0:\ +535741C4D3702052B90129D720ED909A79398C9113566424DF9C25936C957DE4\ +13082F2B21DBB549D7A98C1DE017AB0BE217DD6FCA6FDFDBAB88DB95392A27ED + +B2DCFE9FF19E2B23CE7DA2A4207D3E5EC7C6112A8A22AEC9675A886378E14E5B\ +FBAD4E:\ +5D5E007A1CD5AD33EBD29FB0F54C025BB2A354865012463E05D644C90407E989\ +0CBE0314606BD215DEBABAAED4A01E498639DE7BAE3FC6EACA63007A3F4C4734 + +47F5697AC8C31409C0868827347A613A3562041C633CF1F1F86865A576E02835\ +ED2C2492:\ +AC05269EC62DAB42AE70ECC0C3FA98118C90C22A087124E26DD070B33E331E18\ +4F0BE667A97F041B8EA0274AC69E0F233D580F4CED044134F5C5F6FF06CFB253 + +512A6D292E67ECB2FE486BFE92660953A75484FF4C4F2ECA2B0AF0EDCDD4339C\ +6B2EE4E542:\ +7CEAF4D520D389D2C2F1A3496F350B73A7C524FA3B68C5034C9196B7A5B61184\ +26BC04E527317B0948328081529ED3E3DF94D3945D6DC8C7639C41F39C003403 + +973CF2B4DCF0BFA872B41194CB05BB4E16760A1840D8343301802576197EC19E\ +2A1493D8F4FB:\ +B0A5E7A2A632D2E860010A8526ACA19D028AFCD986213E8D92284173FB9FFD01\ +492B985A3142A9A5145EF823284F10E59CE4D96294A9F5C9344C2A2AF307C061 + +80BEEBCD2E3F8A9451D4499961C9731AE667CDC24EA020CE3B9AA4BBC0A7F79E\ +30A934467DA4B0:\ +AAA6227F450D3155AE0B7CE3177772958A5F62156B38154936EAB3DB4753D882\ +FBC6E2480277C6889EE3CEFB29E2A4AC51FCB9DE94C323BF222CB54061BAC061 + +7ABAA12EC2A7347674E444140AE0FB659D08E1C66DECD8D6EAE925FA451D65F3\ +C0308E29446B8ED3:\ +523FF9E4D5D00A01EF877EFB99BF5F8060943539D90A894D3C6CD132DE40EDA0\ +1BF41C8040B41C134F7A166FDF3C85A45D2B49F3EB584EEF73404B21F40B1393 + +C88DEE9927679B8AF422ABCBACF283B904FF31E1CAC58C7819809F65D5807D46\ +723B20F67BA610C2B7:\ +D129F5142CB0590FDF8C4F1EAA9FE01CDFCD605FF472C88BB93671F866D5C05B\ +5FBA76CC0BD92EDB88052829FFD12AFDF1C78A8B0216A8F8DFC6DD42C9BA0DEF + +01E43FE350FCEC450EC9B102053E6B5D56E09896E0DDD9074FE138E603821027\ +0C834CE6EADC2BB86BF6:\ +31C927D5EF8D6C7FF6ED7AEB3AA3BDC0EDBB7840351D3648DF4493C9BBDC3BC1\ +B9C5B16EA56D0AF05356C76915B9A99CD3A8E971428FEC18A855EDC8AD572BF1 + +337023370A48B62EE43546F17C4EF2BF8D7ECD1D49F90BAB604B839C2E6E5BD2\ +1540D29BA27AB8E309A4B7:\ +A95CF125F407B69A4C06E1C21887C12C9D8385A5989E9A18739EA444292135A2\ +D93A44CAF9506A033D1FA6389B345D2D5950D6611D496C0E6027689A81949456 + +6892540F964C8C74BD2DB02C0AD884510CB38AFD4438AF31FC912756F3EFEC6B\ +32B58EBC38FC2A6B913596A8:\ +7CBF30547921746CBE27FC5DEA6705A070631002447BDA20262CC5FCB0259083\ +9A2A3185443D502554296E7655F5CBB9EEED60C840E61E90A4DA3070B3FE63DF + +F5961DFD2B1FFFFDA4FFBF30560C165BFEDAB8CE0BE525845DEB8DC61004B7DB\ +38467205F5DCFB34A2ACFE96C0:\ +A1A9A9FBA7A83D85796E0800931A3044E48454C34542A6373DB9EC602C0760ED\ +816EC32028013FD9EA976A898081852A7E3C17FA7DA2F048492AC9539D92DD6D + +CA061A2EB6CEED8881CE2057172D869D73A1951E63D57261384B80CEB5451E77\ +B06CF0F5A0EA15CA907EE1C27EBA:\ +34825B3A2CBD58E217B7C76593B02479451B6C9A2C809FC289857F4CC70147DE\ +00F3104EDEE8B1CA54F712996D609D32C988AB70749D0868D4B690BAD1CFB1AD + +1743A77251D69242750C4F1140532CD3C33F9B5CCDF7514E8584D4A5F9FBD730\ +BCF84D0D4726364B9BF95AB251D9BB:\ +47BAF3BF878E7EE0D803457EB4C689A9CCFEB1C552382A36229615A8A46BE0AE\ +46D0F40F309D3BD9FAAECD123B60C43AC29909D77C8E20D886034B9A1E145DC4 + +D8FABA1F5194C4DB5F176FABFFF856924EF627A37CD08CF55608BBA8F1E324D7\ +C7F157298EABC4DCE7D89CE5162499F9:\ +052FE499E96A76C8D20BB911F9A819BC177159D54C30A697F7E0E97CFD0F2442\ +460A48BF5D6B5BE59C2317A84F10E6B19A0DFEEC2077C88787630E1E12A91589 + +BE9684BE70340860373C9C482BA517E899FC81BAAA12E5C6D7727975D1D41BA8\ +BEF788CDB5CF4606C9C1C7F61AED59F97D:\ +C51B893CE23BAF7018CBC69F9CA7C49697792C35845D542A3F2970F6E69072FA\ +22E9B81A78AD609BCACD890EB0B9ADFA8C88283735F406F1604277F87535588C + +7E15D2B9EA74CA60F66C8DFAB377D9198B7B16DEB6A1BA0EA3C7EE2042F89D37\ +86E779CF053C77785AA9E692F821F14A7F51:\ +01756CBD8188A16ECF85C24FFE017F202C6106DF941E043666E4285AFE2DD60F\ +BD19E86D95FBAFCABA45A26FF7FBF3DC82A72FFB803055346FE5F40F15E38D6A + +9A219BE43713BD578015E9FDA66C0F2D83CAC563B776AB9F38F3E4F7EF229CB4\ +43304FBA401EFB2BDBD7ECE939102298651C86:\ +51475D5155F7F33D25A1698B7A93093ADABF7CEB18D549BEE87BDD4F2117407B\ +ED4FD4310EBE8F378D7C9E0E2A1C627C1AAE16C4940E92B2F8E43289EFCE223F + +C8F2B693BD0D75EF99CAEBDC22ADF4088A95A3542F637203E283BBC3268780E7\ +87D68D28CC3897452F6A22AA8573CCEBF245972A:\ +9A7B45C8A0E0349CFE3A77A964EBA8858CE70DC7467BDCBEE97349A63E960732\ +D08E32F8CF33BE42B839777CA7F7217989A2E15022CEF55E418C7EAE6F5C125B + +EC0F99711016C6A2A07AD80D16427506CE6F441059FD269442BAAA28C6CA037B\ +22EEAC49D5D894C0BF66219F2C08E9D0E8AB21DE52:\ +D871B9BB85CF7910F49CAE84414F37A6C26034362E8267A4BCCA0E1A9269C6BF\ +7022B8EE03DBC5EDAFEF60ADF16012FF8AA939678614B383130F55A7A3780230 + +0DC45181337CA32A8222FE7A3BF42FC9F89744259CFF653504D6051FE84B1A7F\ +FD20CB47D4696CE212A686BB9BE9A8AB1C697B6D6A33:\ +93FB224AF201888068A73981DD63652F7600ADE60B22AE37EF9545702C8340B2\ +9F2CFB705D9421EE09449743E97D522037DBEC9DE50ADF91FD629663AEF116AC + +DE286BA4206E8B005714F80FB1CDFAEBDE91D29F84603E4A3EBC04686F99A46C\ +9E880B96C574825582E8812A26E5A857FFC6579F63742F:\ +2B6F8FBE583B60E750D3689CD6A681ECEBE6384BC6B444B8A9346D52A5826354\ +61C0E9CE40CCF8033BBF4F3A43C05D4313E5AB38A066DEDFD6CE8D46476AF6F5 + +EEBCC18057252CBF3F9C070F1A73213356D5D4BC19AC2A411EC8CDEEE7A571E2\ +E20EAF61FD0C33A0FFEB297DDB77A97F0A415347DB66BCAF:\ +A88163B4C6C5275B0A09069A3689EA208CBFF8687CFFBF799D209B248B9DC67D\ +11F32A18C4AACA6726874F8D2D0365EDFD17DB9A4AD24084CE2918B91F21D4B4 + +416B5CDC9FE951BD361BD7ABFC120A5054758EBA88FDD68FD84E39D3B09AC254\ +97D36B43CBE7B85A6A3CEBDA8DB4E5549C3EE51BB6FCB6AC1E:\ +BAAA6AD28EA720D8ADFD0466141B465F741992F9CCC35B4A281119F4CC654320\ +6C4C31D952FBE17B11F0E1A82653DBA16C35486CF8879E6C677F38A857C23523 + +5C5FAF66F32E0F8311C32E8DA8284A4ED60891A5A7E50FB2956B3CBAA79FC66C\ +A376460E100415401FC2B8518C64502F187EA14BFC9503759705:\ +108807312C29DEDA857D162A043427302A12E1CA38CB6A17665BE5D71223C258\ +21BE12FC18AB1CE23B2CAD9795F9DF0231DE8EE39E64111F912D257C00946F9E + +7167E1E02BE1A7CA69D788666F823AE4EEF39271F3C26A5CF7CEE05BCA831610\ +66DC2E217B330DF821103799DF6D74810EED363ADC4AB99F36046A:\ +23013C3939B713F4C410AE1D5BED0977D63F3403C9A1B2E176F13C13402A1CD1\ +58DA92045A605173B6BD46057B9E3F9E7891BC487EB7289D948452DBF72098C3 + +2FDA311DBBA27321C5329510FAE6948F03210B76D43E7448D1689A063877B6D1\ +4C4F6D0EAA96C150051371F7DD8A4119F7DA5C483CC3E6723C01FB7D:\ +2422F221BBA5965522072EA5CA8DF78D573484460B62BECDEB412AF92668EA7F\ +E4DE75B1C11DE0AE048BE00EE897C05BD9FD4E477E5AC3CDEFB1F01E090424E4 + +95D1474A5AAB5D2422ACA6E481187833A6212BD2D0F91451A67DD786DFC91DFE\ +D51B35F47E1DEB8A8AB4B9CB67B70179CC26F553AE7B569969CE151B8D:\ +83C62DC6985C154771320F9FF0E14AAD86D713D6AC56BCFD9BA445FD6C35A748\ +B89FDC7CC3AF80157F0F56FA48AA54181C1117276DC195E7A68C8942341F7D79 + +C71BD7941F41DF044A2927A8FF55B4B467C33D089F0988AA253D294ADDBDB325\ +30C0D4208B10D9959823F0C0F0734684006DF79F7099870F6BF53211A88D:\ +FCEF35C5CFDCB906711A24D5B3EA2D106E15A65B5E87BF7B438597A2A37E1BCD\ +08F8B8E6C3A2E493A47B439671724D38D2A42855411F32FCB13FFB5A21A86B2C + +F57C64006D9EA761892E145C99DF1B24640883DA79D9ED5262859DCDA8C3C32E\ +05B03D984F1AB4A230242AB6B78D368DC5AAA1E6D3498D53371E84B0C1D4BA:\ +8204F6D09AEB41690BBC4AEEB8437579EC8362A0CB2B5351014E99E3B7EBD80B\ +654E23F8EF938ADC7F31D17F78DD7582D178F6C3A89B8B7C603410381447A3CA + +E926AE8B0AF6E53176DBFFCC2A6B88C6BD765F939D3D178A9BDE9EF3AA131C61\ +E31C1E42CDFAF4B4DCDE579A37E150EFBEF5555B4C1CB40439D835A724E2FAE7:\ +926F142A64C9DE0CB07F1A35B635D9839B1DFB045B64AC087C47D533F1D62237\ +C18F9EDB76963A1D4683E3ED14E8792C1D2E9889EC37F2A42AC36CFBA9361ECD + +16E8B3D8F988E9BB04DE9C96F2627811C973CE4A5296B4772CA3EEFEB80A652B\ +DF21F50DF79F32DB23F9F73D393B2D57D9A0297F7A2F2E79CFDA39FA393DF1AC\ +00:\ +7F4CE24C8D7C8E19577E3C1ECA97ACAF15D280E312580C031845B1B40153EAD8\ +F55B9FFD6997C2C8EDE6879334ADD187F255C300240603452AAC651B4B901F31 + +FC424EEB27C18A11C01F39C555D8B78A805B88DBA1DC2A42ED5E2C0EC737FF68\ +B2456D80EB85E11714FA3F8EABFB906D3C17964CB4F5E76B29C1765DB03D91BE\ +37FC:\ +42659DFBA135041D8B9D8EB4FE57514236FA5F8CC63F6DC07258CA01AD9772AB\ +92EB6898B2B83F2B2977110D565F9ABA18FE1B1F3B7400AD69C05CB8AE578762 + +ABE3472B54E72734BDBA7D9158736464251C4F21B33FBBC92D7FAC9A35C4E332\ +2FF01D2380CBAA4EF8FB07D21A2128B7B9F5B6D9F34E13F39C7FFC2E72E47888\ +599BA5:\ +74E130CAE5866A10C53D7296A724BA1FD52F370FD01DDFFBE987D6D63AF90D11\ +3EB294E34871C1C753230C467B4E19ADD030A160499F7A84E15DFB33460E53A2 + +36F9F0A65F2CA498D739B944D6EFF3DA5EBBA57E7D9C41598A2B0E4380F3CF4B\ +479EC2348D015FFE6256273511154AFCF3B4B4BF09D6C4744FDD0F62D75079D4\ +40706B05:\ +D8837EE8E91BE8823EC9B792DDC180EA180DFEC7803083BB7EE86CF4B26FFB5E\ +1F27D2D13858201791ED4A15E30BB248280D5EAD0F798299BAFF961651949658 + +ABC87763CAE1CA98BD8C5B82CABA54AC83286F87E9610128AE4DE68AC95DF5E3\ +29C360717BD349F26B872528492CA7C94C2C1E1EF56B74DBB65C2AC351981FDB\ +31D06C77A4:\ +627C41B2215B346FD315F40073FCEB990D56A927C56ACF61EC5C6CA1C165C141\ +8030E12F83E24E8343ED0D12BBEE5E0328C21653AC1746B85D85451719EC499E + +94F7CA8E1A54234C6D53CC734BB3D3150C8BA8C5F880EAB8D25FED13793A9701\ +EBE320509286FD8E422E931D99C98DA4DF7E70AE447BAB8CFFD92382D8A77760\ +A259FC4FBD72:\ +8C7FDBF9EB06DFE9AD23BD461B67D75C7C4E450602812B496F3244D6FC30AC8E\ +1BB3A2F6761612DCB42F12AA1DD5C7CE14B7B2D375793A7BD6DE3DB593D81C27 + +13BD2811F6ED2B6F04FF3895ACEED7BEF8DCD45EB121791BC194A0F806206BFF\ +C3B9281C2B308B1A729CE008119DD3066E9378ACDCC50A98A82E20738800B6CD\ +DBE5FE9694AD6D:\ +25069EEB77DCA02E9FA7FE6B8B75A73BB54003DF9242050F8084626C32163189\ +5E5426D59AE5C89D2F6AE5B1B4883793E853C30718F0CFBBF4EEDB09949DFBC2 + +1EED9CBA179A009EC2EC5508773DD305477CA117E6D569E66B5F64C6BC64801C\ +E25A8424CE4A26D575B8A6FB10EAD3FD1992EDDDEEC2EBE7150DC98F63ADC323\ +7EF57B91397AA8A7:\ +10983820E5AC1F63D5F9155BB731FBEA51DC29C94A6C754ECE1DE4C15015E38B\ +5214446B64A8B1FC5C8D2071D0323A9179FD667E373B80DDB43E120DA70A7285 + +BA5B67B5EC3A3FFAE2C19DD8176A2EF75C0CD903725D45C9CB7009A900C0B0CA\ +7A2967A95AE68269A6DBF8466C7B6844A1D608AC661F7EFF00538E323DB5F2C6\ +44B78B2D48DE1A08AA:\ +7B8FFAB30873F60DA93EA5822843F3F47048B0B0B8B034A22FC7A2A63511A411\ +C4AE65E6370E5683B47A9AD1D25A53D1B6B08214019E60BD908DAA63529EA1BA + +0EFA26AC5673167DCACAB860932ED612F65FF49B80FA9AE65465E5542CB62075\ +DF1C5AE54FBA4DB807BE25B070033EFA223BDD5B1D3C94C6E1909C02B620D4B1\ +B3A6C9FED24D70749604:\ +C8C74FC231FC8A701FA4AD641028F7F59024330661CEA2907EA442A1BF961A88\ +F5A025E096CCB67BA8F3B8DC141AEA5C0B066393DA11CB9C3380368A86C5C13F + +BBFD933D1FD7BF594AC7F435277DC17D8D5A5B8E4D13D96D2F64E771ABBD51A5\ +A8AEA741BECCBDDB177BCEA05243EBD003CFDEAE877CCA4DA94605B67691919D\ +8B033F77D384CA01593C1B:\ +690B25D978A43A4DDFFCDE4240F18E95B388EF0CB3B0F4018E9F6B2BC3187EDD\ +75EBAD33FD75B3A6468666556E92695B5E494FB0D4DDAECD223144BEF702C36A + +90078999FD3C35B8AFBF4066CBDE335891365F0FC75C1286CDD88FA51FAB94F9\ +B8DEF7C9AC582A5DBCD95817AFB7D1B48F63704E19C2BAA4DF347F48D4A6D603\ +013C23F1E9611D595EBAC37C:\ +8DBFDF512CCFD357E6437640FEDCDCA8DAD285AA8E5A8AC08C4A5572AD653C60\ +7CFCB9049CFF6B7F4D3C9C3495B8C70A19DFEC8642639ABD54408F25EF55D475 + +64105ECA863515C20E7CFBAA0A0B8809046164F374D691CDBD6508AAABC1819F\ +9AC84B52BAFC1B0FE7CDDBC554B608C01C8904C669D8DB316A0953A4C68ECE32\ +4EC5A49FFDB59A1BD6A292AA0E:\ +D3F093F883036869820520A75D7F1C389474558B3E5742AD02B1E2AC6A380898\ +D3237BA3AE6D7738EA25AD0B925DBBF1BC825178BE80C1CFAFC35980A5B9700E + +D4654BE288B9F3B711C2D02015978A8CC57471D5680A092AA534F7372C71CEAA\ +B725A383C4FCF4D8DEAA57FCA3CE056F312961ECCF9B86F14981BA5BED6AB5B4\ +498E1F6C82C6CAE6FC14845B3C8A:\ +FC6E8BF596ACA6BF88A65B185BE195ADC1C53ABE3F2C485A28F4BC9A22E4A779\ +8731DB8BF26625CB3D04276910DB6465FBCA57641CE38389264889147E9E5144 + +12D9394888305AC96E65F2BF0E1B18C29C90FE9D714DD59F651F52B88B3008C5\ +88435548066EA2FC4C101118C91F32556224A540DE6EFDDBCA296EF1FB00341F\ +5B01FECFC146BDB251B3BDAD556CD2:\ +FAAF8737AFAEF553F042073BC8172F380A26780920DF3B12B5F42A76E8FE9324\ +B8146092BB8CA2ED014BD41704F4825605AB1EE7FA352A420E3E3DB5022CC43C + +871A0D7A5F36C3DA1DFCE57ACD8AB8487C274FAD336BC137EBD6FF4658B547C1\ +DCFAB65F037AA58F35EF16AFF4ABE77BA61F65826F7BE681B5B6D5A1EA8085E2\ +AE9CD5CF0991878A311B549A6D6AF230:\ +36C0947410D52F264BB450C77C0822B8C7F7DF5E425478919861CD90E0820BFB\ +3F24B30757040C1AB28EB2342368D315F2B5A5584A0CE735CEC219B4AACFC5B0 + +E90B4FFEF4D457BC7711FF4AA72231CA25AF6B2E206F8BF859D8758B89A7CD36\ +105DB2538D06DA83BAD5F663BA11A5F6F61F236FD5F8D53C5E89F183A3CEC615\ +B50C7C681E773D109FF7491B5CC22296C5:\ +82DC90329F774C2F54E86A04496DB2CA6ABE31C0C930499008227432C4B08875\ +FF26680BFF326D67DC1F16DE7ABFCA303ACAD9154E9D712A2FBC461E5613269F + +E728DE62D75856500C4C77A428612CD804F30C3F10D36FB219C5CA0AA30726AB\ +190E5F3F279E0733D77E7267C17BE27D21650A9A4D1E32F649627638DBADA970\ +2C7CA303269ED14014B2F3CF8B894EAC8554:\ +38EA632A13CAF8C0144C99755446235901233D8618DBD47DC13CAFA488E1006F\ +73794945AFF9C4AF418AD7EDCEAF76841775007080F0AFF4443189AB5F93AE1D + +6348F229E7B1DF3B770C77544E5166E081850FA1C6C88169DB74C76E42EB983F\ +ACB276AD6A0D1FA7B50D3E3B6FCD799EC97470920A7ABED47D288FF883E24CA2\ +1C7F8016B93BB9B9E078BDB9703D2B781B616E:\ +A58D6008392293665E8C9CDA03632471EE474F946FF29D2D03E5BA7ED7E574D9\ +C37346A0713004081872DDD37397665DAF634671C1123A539ABCEBB88A0CF3DF + +4B127FDE5DE733A1680C2790363627E63AC8A3F1B4707D982CAEA258655D9BF1\ +8F89AFE54127482BA01E08845594B671306A025C9A5C5B6F93B0A39522DC8774\ +37BE5C2436CBF300CE7AB6747934FCFC30AEAAF6:\ +FF7E839D9DF579713B7D9E02BCD979B2C24A25AB13BB6B8E80F170344F3C61C1\ +4D2532A993081F47EA9DAE2346EFF8A1CBEADEFA7BCE11D3CB547901D1354D64 + +08461F006CFF4CC64B752C957287E5A0FAABC05C9BFF89D23FD902D324C79903\ +B48FCB8F8F4B01F3E4DDB483593D25F000386698F5ADE7FAADE9615FDC50D327\ +85EA51D49894E45BAA3DC707E224688C6408B68B11:\ +42F2DA8296D7305DFF934BCC21AD52DAC181D937A840A739816ACD74300B4FFF\ +61A1486114DCD6EDC9E6101CCA43B3B5B2815AB8ACABE29CC71FF7F09940E9A3 + +68C8F8849B120E6E0C9969A5866AF591A829B92F33CD9A4A3196957A148C4913\ +8E1E2F5C7619A6D5EDEBE995ACD81EC8BB9C7B9CFCA678D081EA9E25A75D39DB\ +04E18D475920CE828B94E72241F24DB72546B352A0E4:\ +068CC9BECFAC3BEECC23A1767FF00238D2227B164EE5B22238A70953D2E34C6A\ +39F638F97BE9FE71BCD503497548B18F40951050D6828C0118FA4892252AE247 + +B8D56472954E31FB54E28FCA743F84D8DC34891CB564C64B08F7B71636DEBD64\ +CA1EDBDBA7FC5C3E40049CE982BBA8C7E0703034E331384695E9DE76B5104F2F\ +BC4535ECBEEBC33BC27F29F18F6F27E8023B0FBB6F563C:\ +1E2890C88D9FA31AC0952F2EE9309450DFC6391A241E2FAF55A7FA550FBBACF5\ +C6CDD85B0A95B5AB6117C38A85F9C82B7F7066FE1D7900CD8FC27DD1200ADEAA + +0D58AC665FA84342E60CEFEE31B1A4EACDB092F122DFC68309077AED1F3E528F\ +578859EE9E4CEFB4A728E946324927B675CD4F4AC84F64DB3DACFE850C1DD187\ +44C74CECCD9FE4DC214085108F404EAB6D8F452B5442A47D:\ +244B9AF6F4A80FAAE1F81E523BDCF3CC361AB27788FB4B6A2628B778F8B39513\ +C225BDCD1F814EAFF459C90DDC99D62A5BAFDB967E207350BC718FF7142657E3 + +1755E2D2E5D1C1B0156456B539753FF416651D44698E87002DCF61DCFA2B4E72\ +F264D9AD591DF1FDEE7B41B2EB00283C5AEBB3411323B672EAA145C512518510\ +4F20F335804B02325B6DEA65603F349F4D5D8B782DD3469CCD:\ +BBE9E91FACBA93DA63322E8B59BB1C64B881211194251C1237E997E551796DA5\ +2995C34B40036EDE7D15C597EC4431B5AB2E05EB03DF46A9086A48D58650722E + +B180DE1A611111EE7584BA2C4B020598CD574AC77E404E853D15A101C6F5A2E5\ +C801D7D85DC95286A1804C870BB9F00FD4DCB03AA8328275158819DCAD7253F3\ +E3D237AEAA7979268A5DB1C6CE08A9EC7C2579783C8AFC1F91A7:\ +EFB0D1C9E0EB8DD9B5A33E642FA4F93CBC8F62FF67003ADB42A58BE7B86AD308\ +19ED1A656C17D5D5A01FD442210F4EA1F7FC4D75F13560FB08504844350DFFA1 + +CF3583CBDFD4CBC17063B1E7D90B02F0E6E2EE05F99D77E24E560392535E47E0\ +5077157F96813544A17046914F9EFB64762A23CF7A49FE52A0A4C01C630CFE87\ +27B81FB99A89FF7CC11DCA5173057E0417B8FE7A9EFBA6D95C555F:\ +144639558BB4321A5968021BFA84F7241955BA9237773488BBBABBAB9286EE00\ +E6A8A6EFFBC21F217111510AAEE5EE0ED906D9EA5DEA52415F708CA0BC156B9D + +072FC02340EF99115BAD72F92C01E4C093B9599F6CFC45CB380EE686CB5EB019\ +E806AB9BD55E634AB10AA62A9510CC0672CD3EDDB589C7DF2B67FCD3329F61B1\ +A4441ECA87A33C8F55DA4FBBAD5CF2B2527B8E983BB31A2FADEC7523:\ +AB961D00600EBB3C3E3500547077C31C0F975D9A2CFF1519C013C48222700BA8\ +03ABBF23B967E0A082F00FB1DD3C520C38C7F5298A06F6CFEABEBB951DE9B364 + +76EECF956A52649F877528146DE33DF249CD800E21830F65E90F0F25CA9D6540\ +FDE40603230ECA6760F1139C7F268DEBA2060631EEA92B1FFF05F93FD5572FBE\ +29579ECD48BC3A8D6C2EB4A6B26E38D6C5FBF2C08044AEEA470A8F2F26:\ +6815226C40917DC69411050D38DC1A8F94BC99D095A7BB74529291E6CCD5E71A\ +405869F6E7E9111F54C9B2528E72B3BFFDDC2F9EB6FD02271B3786C1398049D8 + +7ADC0B6693E61C269F278E6944A5A2D8300981E40022F839AC644387BFAC9086\ +650085C2CDC585FEA47B9D2E52D65A2B29A7DC370401EF5D60DD0D21F9E2B90F\ +AE919319B14B8C5565B0423CEFB827D5F1203302A9D01523498A4DB10374:\ +F40CAB07D41D001D2EF64E5B2B590A8F1EB54A248B55D5BC8AC411A33CFC32CB\ +D5F30330EF9AD6DF62EE3DAF91EE282392BBD53D4E04686DA6A75944A8541259 + +E1FFFA9826CCE8B86BCCEFB8794E48C46CDF372013F782ECED1E378269B7BE2B\ +7BF51374092261AE120E822BE685F2E7A83664BCFBE38FE8633F24E633FFE198\ +8E1BC5ACF59A587079A57A910BDA60060E85B5F5B6F776F0529639D9CCE4BD:\ +BFA7856A28597491D01D1FE04F028779B6884ECCB14578E985AE43FE6F26DE55\ +D1484B87813B88D233EC8B8E1ADAFB7F2938051E4ED2A3B56B35012B9085E9E1 + +69F9ABBA65592EE01DB4DCE52DBAB90B08FC04193602792EE4DAA263033D5908\ +1587B09BBE49D0B49C9825D22840B2FF5D9C5155F975F8F2C2E7A90C75D2E4A8\ +040FE39F63BBAFB403D9E28CC3B86E04E394A9C9E8065BD3C85FA9F0C7891600:\ +C39F4A7E6B45DB2FDF146887FAD15CB83541A5BBD51367D9A0D971E312FFED28\ +5B380C0E4B3BBE8D492D259B713981600FBC62FECE7A904399857E41BB5AA574 + +38A10A352CA5AEDFA8E19C64787D8E9C3A75DBF3B8674BFAB29B5DBFC15A63D1\ +0FAE66CD1A6E6D2452D557967EAAD89A4C98449787B0B3164CA5B717A93F24EB\ +0B506CEB70CBBCB8D72B2A72993F909AAD92F044E0B5A2C9AC9CB16A0CA2F81F\ +49:\ +C86DBAFBCC87C1A9F23846B856FEB881FA1C663AA3A50E1B71F9E70E7FB4A21E\ +B8165F22505169B3F360876328D799F618175B29D26D650A804CD2926BDE6A05 + +6D8C6E449BC13634F115749C248C17CD148B72157A2C37BF8969EA83B4D6BA8C\ +0EE2711C28EE11495F43049596520CE436004B026B6C1F7292B9C436B055CBB7\ +2D530D860D1276A1502A5140E3C3F54A93663E4D20EDEC32D284E25564F62495\ +5B52:\ +BB59022C4426826788E09DE943EFE4D7FAE71BCDD31270FBCFA0385EFEF6BF96\ +5F7D49D3B296897DF0FAEA677E6D1E62417BD08198FF3C76FAC765F27E0B9AD6 + +6EFCBCAF451C129DBE00B9CEF0C3749D3EE9D41C7BD500ADE40CDC65DEDBBBAD\ +B885A5B14B32A0C0D087825201E303288A733842FA7E599C0C514E078F05C821\ +C7A4498B01C40032E9F1872A1C925FA17CE253E8935E4C3C71282242CB716B20\ +89CCC1:\ +80A11F3D809C269942F4E17D5A13FDB4A7E3EDBE1177ECC4816A883FD924A0F3\ +30A6E27286364464609B566A2D4951B6817BF5D828D24DECE963630FB06B3C94 + +433C5303131624C0021D868A30825475E8D0BD3052A022180398F4CA4423B982\ +14B6BEAAC21C8807A2C33F8C93BD42B092CC1B06CEDF3224D5ED1EC29784444F\ +22E08A55AA58542B524B02CD3D5D5F6907AFE71C5D7462224A3F9D9E53E7E084\ +6DCBB4CE:\ +506AE4A6B5F39DA18FAA39A6E110BD1B2889D739F4A56AFD9867A6948C063C7F\ +CC9DBE16FC804F387DD48510D39F07EF5C3FAD3B73C53AECE1D359D853D8FCC7 + +A873E0C67CA639026B6683008F7AA6324D4979550E9BCE064CA1E1FB97A30B14\ +7A24F3F666C0A72D71348EDE701CF2D17E2253C34D1EC3B647DBCEF2F879F4EB\ +881C4830B791378C901EB725EA5C172316C6D606E0AF7DF4DF7F76E490CD30B2\ +BADF45685F:\ +E8F6B97FF2429752891F69F91893B9AFEC04E931ECD58AF96AEF937233404F68\ +D83D111BD2AE642A960FC7365BDC820BC1FB686022E6C2BC0422577789A7507A + +006917B64F9DCDF1D2D87C8A6173B64F6587168E80FAA80F82D84F60301E561E\ +312D9FBCE62F39A6FB476E01E925F26BCC91DE621449BE6504C504830AAE3940\ +96C8FC7694651051365D4EE9070101EC9B68086F2EA8F8AB7B811EA8AD934D5C\ +9B62C60A4771:\ +36C1FF38C5F3BC8E642AFC2EDD8DC67A9B0F46F5A1A46AE970A94204FE0DB95E\ +540F46A5DE01F5C0D9E357A4FA7A8EB070F2BF98C9CF553B6D2AD2CD2ED0EC38 + +F13C972C52CB3CC4A4DF28C97F2DF11CE089B815466BE88863243EB318C2ADB1\ +A417CB1041308598541720197B9B1CB5BA2318BD5574D1DF2174AF14884149BA\ +9B2F446D609DF240CE335599957B8EC80876D9A085AE084907BC5961B20BF5F6\ +CA58D5DAB38ADB:\ +9715FA25210B31BA4E700755A8CE75992C0620ED22243A18F7F08F6240A3C09B\ +3ADAFC89C356DE6009507A532D435FE44785C9FC06A30F97C43C536848DBAAF6 + +E35780EB9799AD4C77535D4DDB683CF33EF367715327CF4C4A58ED9CBDCDD486\ +F669F80189D549A9364FA82A51A52654EC721BB3AAB95DCEB4A86A6AFA93826D\ +B923517E928F33E3FBA850D45660EF83B9876ACCAFA2A9987A254B137C6E140A\ +21691E1069413848:\ +D00A87501AEE7D7457E8B463B43604E9688440E83AC76D0601553E0E6281CF55\ +8A92ACBA1F90DADB84737C6851075B415CE5FBCE1DFC85EADAAEFD43765866B5 + +64EC021C9585E01FFE6D31BB50D44C79B6993D72678163DB474947A053674619\ +D158016ADB243F5C8D50AA92F50AB36E579FF2DABB780A2B529370DAA299207C\ +FBCDD3A9A25006D19C4F1FE33E4B1EAEC315D8C6EE1E730623FD1941875B924E\ +B57D6D0C2EDC4E78D6:\ +88FECE207FCEF6BA2DC893289E8FF4401175DF1D8CD00E2C44D31701F6C0BADE\ +386C94DFE91104D002E92B5F84DA89DC2AB2EA527D2877D319FAE51DA1F1D9AF + +5954BAB512CF327D66B5D9F296180080402624AD7628506B555EEA8382562324\ +CF452FBA4A2130DE3E165D11831A270D9CB97CE8C2D32A96F50D71600BB4CA26\ +8CF98E90D6496B0A6619A5A8C63DB6D8A0634DFC6C7EC8EA9C006B6C456F1B20\ +CD19E781AF20454AC880:\ +DBAF5302A755CC44F28B4E8083089E5D17810F9E1C191D97C862560327AE568D\ +1459058AE9343C8565A0AEC6D94C5E0F88982827A92CAB1CA551843DFD937E9F + +03D9F92B2C565709A568724A0AFF90F8F347F43B02338F94A03ED32E6F33666F\ +F5802DA4C81BDCE0D0E86C04AFD4EDC2FC8B4141C2975B6F07639B1994C973D9\ +A9AFCE3D9D365862003498513BFA166D2629E314D97441667B007414E739D7FE\ +BF0FE3C32C17AA188A8683:\ +88DB17A8B022D2E52A9A3B9BE7790C5E623CB0FEE52103FB5F3BC2715FF400FD\ +D1DE8093E95570253462693A1D4BD5B1B6867139FECF7AABF19DC6D7A89CF398 + +F31E8B4F9E0621D531D22A380BE5D9ABD56FAEC53CBD39B1FAB230EA67184440\ +E5B1D15457BD25F56204FA917FA48E669016CB48C1FFC1E1E45274B3B47379E0\ +0A43843CF8601A5551411EC12503E5AAC43D8676A1B2297EC7A0800DBFEE0429\ +2E937F21C005F17411473041:\ +1039453D77ACDD8719FE013FE904F49339574B64A28662A399A010DC6DFCF80F\ +B61A0D9CECDAD0FADCDD30480C8225CA3423746575C564EF6EA1DB7B557A5A66 + +758EA3FEA738973DB0B8BE7E599BBEF4519373D6E6DCD7195EA885FC991D8967\ +62992759C2A09002912FB08E0CB5B76F49162AEB8CF87B172CF3AD190253DF61\ +2F77B1F0C532E3B5FC99C2D31F8F65011695A087A35EE4EEE5E334C369D8EE5D\ +29F695815D866DA99DF3F79403:\ +4437B0252F715304BEE9B06B31EBB029D51BDA7C01E5EE614AB2F5B981AEFBF3\ +5F4C9A093C8F26672D77D08AAAA49F9C672C0F5AC8AD6ABB0AE30B4A098F2447 + +47C6E0C2B74948465921868804F0F7BD50DD323583DC784F998A93CD1CA4C6EF\ +84D41DC81C2C40F34B5BEE6A93867B3BDBA0052C5F59E6F3657918C382E771D3\ +3109122CC8BB0E1E53C4E3D13B43CE44970F5E0C079D2AD7D7A3549CD75760C2\ +1BB15B447589E86E8D76B1E9CED2:\ +72C9B767071710D37FEF19E7939F9A245615532E9D4FA643974B211A8D9E5A64\ +AF75A4A365F2503B8B2C71A7A9A6D65BA08E671A044B2E4FA4873DD4EA59154D + +F690A132AB46B28EDFA6479283D6444E371C6459108AFD9C35DBD235E0B6B6FF\ +4C4EA58E7554BD002460433B2164CA51E868F7947D7D7A0D792E4ABF0BE5F450\ +853CC40D85485B2B8857EA31B5EA6E4CCFA2F3A7EF3380066D7D8979FDAC618A\ +AD3D7E886DEA4F005AE4AD05E5065F:\ +01C1E76E50BDD370BCA1EEFFACF6E56F61AC91D193DDB738A75F062FBFAFED79\ +F5618EB34F3ACB06D7850A40CF5E10DE41F6F9D61F3F6A3DDA9C5CB8D63FD691 + +58D6A99BC6458824B256916770A8417040721CCCFD4B79EACD8B65A3767CE5BA\ +7E74104C985AC56B8CC9AEBD16FEBD4CDA5ADB130B0FF2329CC8D611EB14DAC2\ +68A2F9E633C99DE33997FEA41C52A7C5E1317D5B5DAED35EBA7D5A60E45D1FA7\ +EAABC35F5C2B0A0F2379231953322C4E:\ +AE45DDCA514264B8ACE8283E675AEAB6F75631FF5E0693DD4E798DB122D425C3\ +83CB8008CFAD1417755C6ECCEE33EB4979079A1BFB81E08D059D2F196E1935AB + +BEFAB574396D7F8B6705E2D5B58B2C1C820BB24E3F4BAE3E8FBCD36DBF734EE1\ +4E5D6AB972AEDD3540235466E825850EE4C512EA9795ABFD33F330D9FD7F79E6\ +2BBB63A6EA85DE15BEAEEA6F8D204A28956059E2632D11861DFB0E65BC07AC8A\ +159388D5C3277E227286F65FF5E5B5AEC1:\ +CCDA0F2420E7E550353D455172C7D96B3C73BA96154BA850FC316B65D2988B3C\ +2A88AFA619A0E325E61973A4F7D0B260CA3DC5288D21338E5691D775B9596186 + +8E58144FA9179D686478622CE450C748260C95D1BA43B8F9B59ABECA8D93488D\ +A73463EF40198B4D16FB0B0707201347E0506FF19D01BEA0F42B8AF9E71A1F1B\ +D168781069D4D338FDEF00BF419FBB003031DF671F4A37979564F69282DE9C65\ +407847DD0DA505AB1641C02DEA4F0D834986:\ +C86A3FC28768D1B12141216F2211F902CAA1F0FFFBE41710AA1186A8CE35CEED\ +23044C5F4464B79BE81E40B4C9903F9C6807958B440D059C5A9A6911CF600E43 + +B55C10EAE0EC684C16D13463F29291BF26C82E2FA0422A99C71DB4AF14DD9C7F\ +33EDA52FD73D017CC0F2DBE734D831F0D820D06D5F89DACC485739144F8CFD47\ +99223B1AFF9031A105CB6A029BA71E6E5867D85A554991C38DF3C9EF8C1E1E9A\ +7630BE61CAABCA69280C399C1FB7A12D12AEFC:\ +17DF80D04C1B2D4FAFCCDABFCC6E109261A61FF525F845FC5DCC354BC19984F7\ +4F94A6CA82C95055CCD22D9F70D0DC68AC306DA361C135E9B40764A936E6947F + +2EEEA693F585F4ED6F6F8865BBAE47A6908AECD7C429E4BEC4F0DE1D0CA0183F\ +A201A0CB14A529B7D7AC0E6FF6607A3243EE9FB11BCF3E2304FE75FFCDDD6C5C\ +2E2A4CD45F63C962D010645058D36571404A6D2B4F44755434D76998E83409C3\ +205AA1615DB44057DB991231D2CB42624574F545:\ +885461034C5ED300812411297256FA74CCA8D5D61858AEF4E3F5E3737643C5BD\ +B92E65626B685C810D901D33CE22C30072634C431F95EA76936068D686999DC3 + +DAB11DC0B047DB0420A585F56C42D93175562852428499F66A0DB811FCDDDAB2\ +F7CDFFED1543E5FB72110B64686BC7B6887A538AD44C050F1E42631BC4EC8A9F\ +2A047163D822A38989EE4AAB01B4C1F161B062D873B1CFA388FD301514F62224\ +157B9BEF423C7783B7AAC8D30D65CD1BBA8D689C2D:\ +EABFDA04298F0CCBB7DDD4318C98A6F4FFB749D8EFD902823511CF548C3DE032\ +E206F295FD9EC9FE44A05A4E1E7C5F01B19BBCBBE0A0AC142231B0860FAFA4CB + +42E99A2F80AEE0E001279A2434F731E01D34A44B1A8101726921C0590C30F312\ +0EB83059F325E894A5AC959DCA71CE2214799916424E859D27D789437B9D2724\ +0BF8C35ADBAFCECC322B48AA205B293962D858652ABACBD588BCF6CBC388D099\ +3BD622F96ED54614C25B6A9AA527589EAAFFCF17DDF7:\ +BAFFEB5AC8E9BB44791F112B5FA090EF60CB13D05F3F137DAD89E2AD70DC9FF1\ +5BD6C44075A7A4F979FCFAE0ED57A68151F81E68C65AEBA44BCC19057EA93E98 + +3C9B46450C0F2CAE8E3823F8BDB4277F31B744CE2EB17054BDDC6DFF36AF7F49\ +FB8A2320CC3BDF8E0A2EA29AD3A55DE1165D219ADEDDB5175253E2D1489E9B6F\ +DD02E2C3D3A4B54D60E3A47334C37913C5695378A669E9B72DEC32AF5434F93F\ +46176EBF044C4784467C700470D0C0B40C8A088C815816:\ +7197F27D300980CBFC230639E8DD20832A6CEF9E39EA54A2C9CD37C905134952\ +64B2BEF2393B5F2E0B3C14AF80BD63275EB4D653AAC91CFB805AF9C14B833C4B + +D1E654B77CB155F5C77971A64DF9E5D34C26A3CAD6C7F6B300D39DEB19100946\ +91ADAA095BE4BA5D86690A976428635D5526F3E946F7DC3BD4DBC78999E65344\ +1187A81F9ADCD5A3C5F254BC8256B0158F54673DCC1232F6E918EBFC6C51CE67\ +EAEB042D9F57EEC4BFE910E169AF78B3DE48D137DF4F2840:\ +88E837536AC03572D8A41E6F59E6F8530F581E4FF3DB097A849037DF26665CBA\ +B72241AF292A3DF1E738E39209A8B293B65ACB77E07F577A22DF24E8B5A58AD7 + +626F68C18A69A6590159A9C46BE03D5965698F2DAC3DE779B878B3D9C421E0F2\ +1B955A16C715C1EC1E22CE3EB645B8B4F263F60660EA3028981EEBD6C8C3A367\ +285B691C8EE56944A7CD1217997E1D9C21620B536BDBD5DE8925FF71DEC6FBC0\ +6624AB6B21E329813DE90D1E572DFB89A18120C3F606355D25:\ +4D6BD6E1B24AD612BBC238E64AB89084D2703007FD59C8B4718E65124DB8E926\ +70DEF8282470F0E78CDE6AC9A28E1BFA42BEB8442BDC5904082DEC9271995281 + +651A6FB3C4B80C7C68C6011675E6094EB56ABF5FC3057324EBC6477825061F9F\ +27E7A94633ABD1FA598A746E4A577CAF524C52EC1788471F92B8C37F23795CA1\ +9D559D446CAB16CBCDCE90B79FA1026CEE77BF4AB1B503C5B94C2256AD75B3EA\ +C6FD5DCB96ACA4B03A834BFB4E9AF988CECBF2AE597CB9097940:\ +502F271E81519BC7AAA67C4F7AB71BDECF7717C0F56A23539C969922977FA7BD\ +88922BA4BC556DC806672A1C734E4373F2E82FE605567E0EEC383EE6078360D3 + +8AAF072FCE8A2D96BC10B3C91C809EE93072FB205CA7F10ABD82ECD82CF040B1\ +BC49EA13D1857815C0E99781DE3ADBB5443CE1C897E55188CEAF221AA9681638\ +DE05AE1B322938F46BCE51543B57ECDB4C266272259D1798DE13BE90E10EFEC2\ +D07484D9B21A3870E2AA9E06C21AA2D0C9CF420080A80A91DEE16F:\ +47583501739DAC6F5A99D13719F6C5A44D88CA4A503EF2CFCFDEEA17D018CE03\ +345F75034F782450B67DEE9C27660DC6FD050FAED16F8630436EF5D87EBD7068 + +53F918FD00B1701BD504F8CDEA803ACCA21AC18C564AB90C2A17DA592C7D6968\ +8F6580575395551E8CD33E0FEF08CA6ED4588D4D140B3E44C032355DF1C53156\ +4D7F4835753344345A6781E11CD5E095B73DF5F82C8AE3AD00877936896671E9\ +47CC52E2B29DCD463D90A0C9929128DA222B5A211450BBC0E02448E2:\ +B4D44B02CFB3BF59A42E35B4263FF91BEEA9E978C71DBD5E1DA3E53730A1F7C1\ +A838D2AA5FA6F134A575F269C9677943F5CAC9D8D47CE0FB8157E4BF8E2BE416 + +A64599B8A61B5CCEC9E67AED69447459C8DA3D1EC6C7C7C82A7428B9B584FA67\ +E90F68E2C00FBBED4613666E5168DA4A16F395F7A3C3832B3B134BFC9CBAA95D\ +2A0FE252F44AC6681EB6D40AB91C1D0282FED6701C57463D3C5F2BB8C6A7301F\ +B4576AA3B5F15510DB8956FF77478C26A7C09BEA7B398CFC83503F538E:\ +46BA7F2CC804F2573AB08B3D4F152370DCD0299AA82D4E090DE6C69A07FC83B3\ +821905128838125F0BC4ABCDF41FB64AF63A5915842750DE768D2C5445DA1313 + +0E3AB0E054739B00CDB6A87BD12CAE024B54CB5E550E6C425360C2E87E59401F\ +5EC24EF0314855F0F56C47695D56A7FB1417693AF2A1ED5291F2FEE95F75EED5\ +4A1B1C2E81226FBFF6F63ADE584911C71967A8EB70933BC3F5D15BC91B5C2644\ +D9516D3C3A8C154EE48E118BD1442C043C7A0DBA5AC5B1D5360AAE5B9065:\ +48AEE486EFCBDF1979B9E59B54EC8117C6E00EB94307F642CA136CEC7354CC91\ +8700522477F80347A7E91CA4CEA327EEC390C975AF974F1A03474ACB7CF3B6D4 + +A62FC595B4096E6336E53FCDFC8D1CC175D71DAC9D750A6133D23199EAAC2882\ +07944CEA6B16D27631915B4619F743DA2E30A0C00BBDB1BBB35AB852EF3B9AEC\ +6B0A8DCC6E9E1ABAA3AD62AC0A6C5DE765DE2C3711B769E3FDE44A74016FFF82\ +AC46FA8F1797D3B2A726B696E3DEA5530439ACEE3A45C2A51BC32DD055650B:\ +A5FBFEB1FD1CED918FD189B7E8E49A2A26F99A9898B7469AD421F16DCF934E56\ +F17C68083F731F172FE9D6F26B141C8E7617A6369DB97CD31131B259ECE05C3A + +2B6DB7CED8665EBE9DEB080295218426BDAA7C6DA9ADD2088932CDFFBAA1C141\ +29BCCDD70F369EFB149285858D2B1D155D14DE2FDB680A8B027284055182A0CA\ +E275234CC9C92863C1B4AB66F304CF0621CD54565F5BFF461D3B461BD40DF281\ +98E3732501B4860EADD503D26D6E69338F4E0456E9E9BAF3D827AE685FB1D817:\ +FC79270DC468C4663FEC45C4581C49AB6C0631A77FFBBE8882C396A06C685231\ +CF91651BF810C765213D4160C6D64C36CD8B2EA0A87EACF31690B54BC8EB7636 + +10DB509B2CDCABA6C062AE33BE48116A29EB18E390E1BBADA5CA0A2718AFBCD2\ +3431440106594893043CC7F2625281BF7DE2655880966A23705F0C5155C2F5CC\ +A9F2C2142E96D0A2E763B70686CD421B5DB812DACED0C6D65035FDE558E94F26\ +B3E6DDE5BD13980CC80292B723013BD033284584BFF27657871B0CF07A849F4A\ +E2:\ +1C54E058E303ED843CEC563E57F5BC283085BCD6285C36F7C4AE124FF0F42C75\ +865689746B4C1119C54E0782AFAD3D507E0C0DED767B8937D87CB3A8A09416B7 + +9334DE60C997BDA6086101A6314F64E4458F5FF9450C509DF006E8C547983C65\ +1CA97879175AABA0C539E82D05C1E02C480975CBB30118121061B1EBAC4F8D9A\ +3781E2DB6B18042E01ECF9017A64A0E57447EC7FCBE6A7F82585F7403EE2223D\ +52D37B4BF426428613D6B4257980972A0ACAB508A7620C1CB28EB4E9D30FC413\ +61EC:\ +269AD5A2BCD1943138C9BC13A6E410559B4ABE511C357C1CDA3283AFD9DBA2A5\ +8DA526166041555D780610DD5C36BE7097258233949B8D42E4DF1E0908BBDCB4 + +E88AB086891693AA535CEB20E64C7AB97C7DD3548F3786339897A5F0C3903154\ +9CA870166E477743CCFBE016B4428D89738E426F5FFE81626137F17AECFF61B7\ +2DBEE2DC20961880CFE281DFAB5EE38B1921881450E16032DE5E4D55AD8D4FCA\ +609721B0692BAC79BE5A06E177FE8C80C0C83519FB3347DE9F43D5561CB8107B\ +9B5EDC:\ +6D49BBE0A468811E6068D4CEA22D9E5116D4F79E24584160647F8FFE460EA496\ +C47A9B47C8A5029BE941D02A739F89D594CD0BC312BD25FEB9CFC2B05925292E + +FD19E01A83EB6EC810B94582CB8FBFA2FCB992B53684FB748D2264F020D3B960\ +CB1D6B8C348C2B54A9FCEA72330C2AAA9A24ECDB00C436ABC702361A82BB8828\ +B85369B8C72ECE0082FE06557163899C2A0EFA466C33C04343A839417057399A\ +63A3929BE1EE4805D6CE3E5D0D0967FE9004696A5663F4CAC9179006A2CEB755\ +42D75D68:\ +8D327AAEF3FF05C0DE51B40347D11EC4D5ACB50ACC24B39C44273839D1878AC8\ +7939855B86B03195F67CF7D7FC7F41C74A4968C489A4ED7EFC4DFB199536BB8C + +59AE20B6F7E0B3C7A989AFB28324A40FCA25D8651CF1F46AE383EF6D8441587A\ +A1C04C3E3BF88E8131CE6145CFB8973D961E8432B202FA5AF3E09D625FAAD825\ +BC19DA9B5C6C20D02ABDA2FCC58B5BD3FE507BF201263F30543819510C12BC23\ +E2DDB4F711D087A86EDB1B355313363A2DE996B891025E147036087401CCF3CA\ +7815BF3C49:\ +786D18C6816FE5AF627CCCB692D79AC99825C57F76E63B93CC774FCAEA388D4A\ +354EE7D39651EB11BFE6DC96BED877E71DA5F7AE1BB5114795B96C1AE4B56173 + +77EE804B9F3295AB2362798B72B0A1B2D3291DCEB8139896355830F34B3B3285\ +61531F8079B79A6E9980705150866402FDC176C05897E359A6CB1A7AB067383E\ +B497182A7E5AEF7038E4C96D133B2782917417E391535B5E1B51F47D8ED7E4D4\ +025FE98DC87B9C1622614BFF3D1029E68E372DE719803857CA52067CDDAAD958\ +951CB2068CC6:\ +6ED0CEB2C0404260D2466A80FAA097C0BE4B68F537610474D3368224D4862CFC\ +C569294915E4E447645562BE785B9D2850BE8F4962D421AB7346D8E4C0DD02FC + +B771D5CEF5D1A41A93D15643D7181D2A2EF0A8E84D91812F20ED21F147BEF732\ +BF3A60EF4067C3734B85BC8CD471780F10DC9E8291B58339A677B960218F71E7\ +93F2797AEA349406512829065D37BB55EA796FA4F56FD8896B49B2CD19B43215\ +AD967C712B24E5032D065232E02C127409D2ED4146B9D75D763D52DB98D949D3\ +B0FED6A8052FBB:\ +87DDFDED0BAEBC090A82B8BAF67BECCF72E46D2D4C91A5C6A26583467D2A41E0\ +D04384A58BF9C5C209A82696AC54A760E571331D16A04F5D926CA104A3F42740 + +B32D95B0B9AAD2A8816DE6D06D1F86008505BD8C14124F6E9A163B5A2ADE55F8\ +35D0EC3880EF50700D3B25E42CC0AF050CCD1BE5E555B23087E04D7BF9813622\ +780C7313A1954F8740B6EE2D3F71F768DD417F520482BD3A08D4F222B4EE9DBD\ +015447B33507DD50F3AB4247C5DE9A8ABD62A8DECEA01E3B87C8B927F5B08BEB\ +37674C6F8E380C04:\ +9C32DFB92D2079F704C30734843B70B6670FDA53507DEAD248E644AB1CEDCF91\ +1BE16C04FE35FB861195A4EEEA9ED929D3249E0107DCB15BA76BFC6F534895AF + +04410E31082A47584B406F051398A6ABE74E4DA59BB6F85E6B49E8A1F7F2CA00\ +DFBA5462C2CD2BFDE8B64FB21D70C083F11318B56A52D03B81CAC5EEC29EB31B\ +D0078B6156786DA3D6D8C33098C5C47BB67AC64DB14165AF65B44544D806DDE5\ +F487D5373C7F9792C299E9686B7E5821E7C8E2458315B996B5677D926DAC57B3\ +F22DA873C601016A0D:\ +C0F684549025FB7AC404D5DCD997DC1E2392B3DD10A071CF17A1773D80877CC3\ +EA2A109263161D343C6B06BA6288D303A137647BB5A1992842FD97D1B200ECA9 + +8B81E9BADDE026F14D95C019977024C9E13DB7A5CD21F9E9FC491D716164BBAC\ +DC7060D882615D411438AEA056C340CDF977788F6E17D118DE55026855F93270\ +472D1FD18B9E7E812BAE107E0DFDE7063301B71F6CFE4E225CAB3B232905A56E\ +994F08EE2891BA922D49C3DAFEB75F7C69750CB67D822C96176C46BD8A29F170\ +1373FB09A1A6E3C7158F:\ +CE1BAF61F4215C7E4802AEDEB5FE0843868A173A005755CDC84D5E270AC0D127\ +6C53B72EFEA7A25D1090F32637B4582DD2D5E85D00C16B4A87F347E8267CB72F + +FA6EED24DA6666A22208146B19A532C2EC9BA94F09F1DEF1E7FC13C399A48E41\ +ACC2A589D099276296348F396253B57CB0E40291BD282773656B6E0D8BEA1CDA\ +084A3738816A840485FCF3FB307F777FA5FEAC48695C2AF4769720258C77943F\ +B4556C362D9CBA8BF103AEB9034BAA8EA8BFB9C4F8E6742CE0D52C49EA8E974F\ +339612E830E9E7A9C29065:\ +FAE974D0586C79EC9E5957B99EFDAF4DE4510D554D8F689EAA8841234B33BA2C\ +D75B62B5300BFFEB2E6C64007D363756E987183BB8779266E07BED49246C10DB + +9BB4AF1B4F09C071CE3CAFA92E4EB73CE8A6F5D82A85733440368DEE4EB1CBC7\ +B55AC150773B6FE47DBE036C45582ED67E23F4C74585DAB509DF1B8361056454\ +5642B2B1EC463E18048FC23477C6B2AA035594ECD33791AF6AF4CBC2A1166ABA\ +8D628C57E707F0B0E8707CAF91CD44BDB915E0296E0190D56D33D8DDE10B5B60\ +377838973C1D943C22ED335E:\ +EC6DED9C61223888BCD03EBF8E1037BDA52F94FF110B42524163010490B12204\ +37A68947D80FFE967B5317D2F8B1CE9C4ADB4FF2C6F89E4D54A7256C660106ED + +2167F02118CC62043E9091A647CADBED95611A521FE0D64E8518F16C808AB297\ +725598AE296880A773607A798F7C3CFCE80D251EBEC6885015F9ABF7EAABAE46\ +798F82CB5926DE5C23F44A3F9F9534B3C6F405B5364C2F8A8BDC5CA49C749BED\ +8CE4BA48897062AE8424CA6DDE5F55C0E42A95D1E292CA54FB46A84FBC9CD87F\ +2D0C9E7448DE3043AE22FDD229:\ +66C863F11E3149CAE8F0629FE48CAA35D7475812644286B2F9DF5598259FFCB2\ +46BB83919CA664CF9F5B0CF151BA8AECAEAB1938E69AB3B628770C0E93DB2444 + +94B7FA0BC1C44E949B1D7617D31B4720CBE7CA57C6FA4F4094D4761567E389EC\ +C64F6968E4064DF70DF836A47D0C713336B5028B35930D29EB7A7F9A5AF9AD5C\ +F441745BAEC9BB014CEEFF5A41BA5C1CE085FEB980BAB9CF79F2158E03EF7E63\ +E29C38D7816A84D4F71E0F548B7FC316085AE38A060FF9B8DEC36F91AD9EBC0A\ +5B6C338CBB8F6659D342A24368CF:\ +049A414B5A3DA568A5A9166CA7D9135FFA0E0B49DF43E4E796AF60D6613BDDCE\ +1006161AAC9BBCAB6B80199DCB52648B3CE998EA0AE27B37AADB3A9C914171CC + +EA40E83CB18B3A242C1ECC6CCD0B7853A439DAB2C569CFC6DC38A19F5C90ACBF\ +76AEF9EA3742FF3B54EF7D36EB7CE4FF1C9AB3BC119CFF6BE93C03E208783335\ +C0AB8137BE5B10CDC66FF3F89A1BDDC6A1EED74F504CBE7290690BB295A872B9\ +E3FE2CEE9E6C67C41DB8EFD7D863CF10F840FE618E7936DA3DCA5CA6DF933F24\ +F6954BA0801A1294CD8D7E66DFAFEC:\ +2B9131F248BE3B340BA45642E3DC9270543156FE2150700E36A7CE5887C60A35\ +5B4B055926888EAEF79743E1B038CA724F506366E8706176B382DBA414114FCB + +157D5B7E4507F66D9A267476D33831E7BB768D4D04CC3438DA12F9010263EA5F\ +CAFBDE2579DB2F6B58F911D593D5F79FB05FE3596E3FA80FF2F761D1B0E57080\ +055C118C53E53CDB63055261D7C9B2B39BD90ACC32520CBBDBDA2C4FD8856DBC\ +EE173132A2679198DAF83007A9B5C51511AE49766C792A29520388444EBEFE28\ +256FB33D4260439CBA73A9479EE00C63:\ +574A12CEEE655CBD90E3F3E483ACF5CE445D30029F34A5B364E73124AF129A7A\ +40D4BECD4233C83911D4E92E4FAF23DA979D11F3FCCC3BFC6F2E39B2FE0CBFFE + +836B34B515476F613FE447A4E0C3F3B8F20910AC89A3977055C960D2D5D2B72B\ +D8ACC715A9035321B86703A411DDE0466D58A59769672AA60AD587B8481DE4BB\ +A552A1645779789501EC53D540B904821F32B0BD1855B04E4848F9F8CFE9EBD8\ +911BE95781A759D7AD9724A7102DBE576776B7C632BC39B9B5E19057E226552A\ +5994C1DBB3B5C7871A11F5537011044C53:\ +FF04FF3D476E6B1E418B6C656DF2CA4577843B0F8300304F312E8DECE522D9AD\ +F994EBFEBD02050E7A622261B31875863DBEFFB50C07CFCBCE40D33FBC087110 + +CC7784A4912A7AB5AD3620AAB29BA87077CD3CB83636ADC9F3DC94F51EDF521B\ +2161EF108F21A0A298557981C0E53CE6CED45BDF782C1EF200D29BAB81DD6460\ +586964EDAB7CEBDBBEC75FD7925060F7DA2B853B2B089588FA0F8C16EC6498B1\ +4C55DCEE335CB3A91D698E4D393AB8E8EAC0825F8ADEBEEE196DF41205C01167\ +4E53426CAA453F8DE1CBB57932B0B741D4C6:\ +0427F9E924540E619A2E3CA21C1139A26529F032DB801389BB3B156F74662D59\ +114B6C65E800D554C88FB39F945D67446B2D56C36D882805EDD7F533CD5D726B + +7639B461FFF270B2455AC1D1AFCE782944AEA5E9087EB4A39EB96BB5C3BAAF0E\ +868C8526D3404F9405E79E77BFAC5FFB89BF1957B523E17D341D7323C302EA70\ +83872DD5E8705694ACDDA36D5A1B895AAA16ECA6104C82688532C8BFE1790B5D\ +C9F4EC5FE95BAED37E1D287BE710431F1E5E8EE105BC42ED37D74B1E55984BF1\ +C09FE6A1FA13EF3B96FAEAED6A2A1950A12153:\ +5CAB5FC3B20EDFAC061F3DE3434A42BCAFADBFE4BD7C15D2A5FA7FA7A81CA028\ +C8073E8A5BD54618CAA1C2AA22C7C636831D23227753BFF5CAE342C0DF86A840 + +EB6513FC61B30CFBA58D4D7E80F94D14589090CF1D80B1DF2E68088DC6104959\ +BA0D583D585E9578AB0AEC0CF36C48435EB52ED9AB4BBCE7A5ABE679C97AE2DB\ +E35E8CC1D45B06DDA3CF418665C57CBEE4BBB47FA4CAF78F4EE656FEC237FE4E\ +EBBAFA206E1EF2BD0EE4AE71BD0E9B2F54F91DAADF1FEBFD7032381D636B733D\ +CB3BF76FB14E23AFF1F68ED3DBCF75C9B99C6F26:\ +8CA096F3F386895CEDC7924785316E53585F0D9F6BD62687DDE376B12024DAC3\ +CFA860EAAC59ACEAE26FDC1FA92CDB81536E30BB89EF0B02C9DD5D6D1B0CB597 + +1594D74BF5DDE444265D4C04DAD9721FF3E34CBF622DAF341FE16B96431F6C4D\ +F1F760D34F296EB97D98D560AD5286FEC4DCE1724F20B54FD7DF51D4BF137ADD\ +656C80546FB1BF516D62EE82BAA992910EF4CC18B70F3F8698276FCFB44E0EC5\ +46C2C39CFD8EE91034FF9303058B4252462F86C823EB15BF481E6B79CC3A0221\ +8595B3658E8B37382BD5048EAED5FD02C37944E73B:\ +A7496CD71B2503BF3E61A50F269C639342A50C27A5474724919A56722B530EB6\ +F587265016003AEA5E89AFA8D5E4B825DF2AA20F2EE3B1D24A320F9E4FD79599 + +4CFA1278903026F66FEDD41374558BE1B585D03C5C55DAC94361DF286D4BD39C\ +7CB8037ED3B267B07C346626449D0CC5B0DD2CF221F7E4C3449A4BE99985D2D5\ +E67BFF2923357DDEAB5ABCB4619F3A3A57B2CF928A022EB27676C6CF80568900\ +4FCA4D41EA6C2D0A4789C7605F7BB838DD883B3AD3E6027E775BCF2628814280\ +99C7FFF95B14C095EA130E0B9938A5E22FC52650F591:\ +7DF2F4E99989DFCB586C604725C000AD32DA859247E422479A7629F3117E93D6\ +50F6A272F2CADE0F07B92382C5FC0D0E3B5313F16DF54FEA12D63BDDBA98FAB6 + +D3E65CB92CFA79662F6AF493D696A07CCF32AAADCCEFF06E73E8D9F6F909209E\ +66715D6E978788C49EFB9087B170ECF3AA86D2D4D1A065AE0EFC8924F365D676\ +B3CB9E2BEC918FD96D0B43DEE83727C9A93BF56CA2B2E59ADBA85696546A8150\ +67FC7A78039629D4948D157E7B0D826D1BF8E81237BAB7321312FDAA4D521744\ +F988DB6FDF04549D0FDCA393D639C729AF716E9C8BBA48:\ +1785ABB837E1EFB2EF35D2EE92250985380C702C700660FBCE71F0E962FA67C0\ +C525987A546F5310CE2489D7661229441A7D82BDFAB66D475826A21B95ADEDD8 + +842CC583504539622D7F71E7E31863A2B885C56A0BA62DB4C2A3F2FD12E79660\ +DC7205CA29A0DC0A87DB4DC62EE47A41DB36B9DDB3293B9AC4BAAE7DF5C6E720\ +1E17F717AB56E12CAD476BE49608AD2D50309E7D48D2D8DE4FA58AC3CFEAFEEE\ +48C0A9EEC88498E3EFC51F54D300D828DDDCCB9D0B06DD021A29CF5CB5B25069\ +15BEB8A11998B8B886E0F9B7A80E97D91A7D01270F9A7717:\ +C1383A968195C1A6796C5E53DC9756B9DEE39FB7116DCBFE2B5DB9CB9AD6A296\ +77C3F14A156D4D78B3C709DCD49CD247F676CCE0AD693EA208B8433D8C3F7BF6 + +6C4B0A0719573E57248661E98FEBE326571F9A1CA813D3638531AE28B4860F23\ +C3A3A8AC1C250034A660E2D71E16D3ACC4BF9CE215C6F15B1C0FC7E77D3D2715\ +7E66DA9CEEC9258F8F2BF9E02B4AC93793DD6E29E307EDE3695A0DF63CBDC0FC\ +66FB770813EB149CA2A916911BEE4902C47C7802E69E405FE3C04CEB5522792A\ +5503FA829F707272226621F7C488A7698C0D69AA561BE9F378:\ +44A8B042FC42ABDEB224A4FD7E934148BC86A30E5F2F94E713BFF7FC5BB414F3\ +66CE221316D2F79E5DE124BCC35585447E6B678FA02A5D947323D5C7E614072D + +51B7DBB7CE2FFEB427A91CCFE5218FD40F9E0B7E24756D4C47CD55606008BDC2\ +7D16400933906FD9F30EFFDD4880022D081155342AF3FB6CD53672AB7FB5B3A3\ +BCBE47BE1FD3A2278CAE8A5FD61C1433F7D350675DD21803746CADCA574130F0\ +1200024C6340AB0CC2CF74F2234669F34E9009EF2EB94823D62B31407F4BA46F\ +1A1EEC41641E84D77727B59E746B8A671BEF936F05BE820759FA:\ +8CD46B15C0F963EA6FF65FD4D3BD6597B3AFBCC7E7DD8C9FD54B93D02286040D\ +7426895B27BB21C9DCE2A99D307388AD54F2B10BC4030A044759A1378A3C5681 + +83599D93F5561E821BD01A472386BC2FF4EFBD4AED60D5821E84AAE74D807102\ +9810F5E286F8F17651CD27DA07B1EB4382F754CD1C95268783AD09220F550284\ +0370D494BEB17124220F6AFCE91EC8A0F55231F9652433E5CE3489B727716CF4\ +AEBA7DCDA20CD29AA9A859201253F948DD94395ABA9E3852BD1D60DDA7AE5DC0\ +45B283DA006E1CBAD83CC13292A315DB5553305C628DD091146597:\ +92DDE2B72137F776D310E1D5E85D83CB0BAA12496B21A850FA4A5E75AF17D510\ +D286C494400C999811B7992032D61B32098157085C8363850D4ADE61D4D9D2A9 + +2BE9BF526C9D5A75D565DD11EF63B979D068659C7F026C08BEA4AF161D85A462\ +D80E45040E91F4165C074C43AC661380311A8CBED59CC8E4C4518E80CD2C78AB\ +1CABF66BFF83EAB3A80148550307310950D034A6286C93A1ECE8929E6385C5E3\ +BB6EA8A7C0FB6D6332E320E71CC4EB462A2A62E2BFE08F0CCAD93E61BEDB5DD0\ +B786A728AB666F07E0576D189C92BF9FB20DCA49AC2D3956D47385E2:\ +BB878BE3D0F55077194E3B67B2E916324B1637B23AAEC1155E54A3146D7ED2B2\ +ED0D2AC5AEB816291FA89DD5FC11CD07ACDFF5D416F70D433BE262D6AF157C7E + +CA76D3A12595A817682617006848675547D3E8F50C2210F9AF906C0E7CE50B44\ +60186FE70457A9E879E79FD4D1A688C70A347361C847BA0DD6AA52936EAF8E58\ +A1BE2F5C1C704E20146D366AEB3853BED9DE9BEFE9569AC8AAEA37A9FB7139A1\ +A1A7D5C748605A8DEFB297869EBEDD71D615A5DA23496D11E11ABBB126B206FA\ +0A7797EE7DE117986012D0362DCEF775C2FE145ADA6BDA1CCB326BF644:\ +7F071AA99ABED8FD376C967FFF12CDF9926409131D3945A37F30F427C8C42899\ +2E6F1133F4211EDD38062445F5054D8D642C40E54935DBB937B96250D4A9D801 + +F76B85DC67421025D64E93096D1D712B7BAF7FB001716F02D33B2160C2C882C3\ +10EF13A576B1C2D30EF8F78EF8D2F465007109AAD93F74CB9E7D7BEF7C9590E8\ +AF3B267C89C15DB238138C45833C98CC4A471A7802723EF4C744A853CF80A0C2\ +568DD4ED58A2C9644806F42104CEE53628E5BDF7B63B0B338E931E31B87C24B1\ +46C6D040605567CEEF5960DF9E022CB469D4C787F4CBA3C544A1AC91F95F:\ +C176D062E50C7329273ED6A485B0A62FE18622E6A783108FAB8FBCBC645C4931\ +FF101A575368FBD65C06FAC22E72AD2FCCADA2AEB066B6649C531C1F74DD96B3 + +25B8C9C032EA6BCD733FFC8718FBB2A503A4EA8F71DEA1176189F694304F0FF6\ +8E862A8197B839957549EF243A5279FC2646BD4C009B6D1EDEBF24738197ABB4\ +C992F6B1DC9BA891F570879ACCD5A6B18691A93C7D0A8D38F95B639C1DAEB48C\ +4C2F15CCF5B9D508F8333C32DE78781B41850F261B855C4BEBCC125A380C54D5\ +01C5D3BD07E6B52102116088E53D76583B0161E2A58D0778F091206AABD5A1:\ +D5BF89C144445B9D3455C198D2630C643E4B51F35884EACB0B4F70864B2472B1\ +7AFD66DFBFAFF9482E34BDD6F6BF1EFDED5029EC7E74F80751384762BFC998E8 + +21CFDC2A7CCB7F331B3D2EEFFF37E48AD9FA9C788C3F3C200E0173D99963E1CB\ +CA93623B264E920394AE48BB4C3A5BB96FFBC8F0E53F30E22956ADABC2765F57\ +FB761E147ECBF8567533DB6E50C8A1F894310A94EDF806DD8CA6A0E141C0FA7C\ +9FAE6C6AE65F18C93A8529E6E5B553BF55F25BE2E80A9882BD37F145FECBEB3D\ +447A3C4E46C21524CC55CDD62F521AB92A8BA72B897996C49BB273198B7B1C9E:\ +AB3090870B65CA635BDAC16D1C2F877BDE48C3DE1DA17A88B89E86BE9DD9F4E3\ +A2D116CA899A4C4FE5494689D7BF8C1432276E4216DADB3011ABD058FCC56C70 + +4E452BA42127DCC956EF4F8F35DD68CB225FB73B5BC7E1EC5A898BBA2931563E\ +74FAFF3B67314F241EC49F4A7061E3BD0213AE826BAB380F1F14FAAB8B0EFDDD\ +5FD1BB49373853A08F30553D5A55CCBBB8153DE4704F29CA2BDEEF0419468E05\ +DD51557CCC80C0A96190BBCC4D77ECFF21C66BDF486459D427F986410F883A80\ +A5BCC32C20F0478BB9A97A126FC5F95451E40F292A4614930D054C851ACD019C\ +CF:\ +8C311A20F4BB608CE2D697A64C1029B6E000C16EA5D64538715EE0778D93EABA\ +708BAB844DF99EBABAE526639AE4435B74BE87A00128A1D5F227ABADB550B091 + +FA85671DF7DADF99A6FFEE97A3AB9991671F5629195049880497487867A6C446\ +B60087FAC9A0F2FCC8E3B24E97E42345B93B5F7D3691829D3F8CCD4BB36411B8\ +5FC2328EB0C51CB3151F70860AD3246CE0623A8DC8B3C49F958F8690F8E3860E\ +71EB2B1479A5CEA0B3F8BEFD87ACAF5362435EAECCB52F38617BC6C5C2C6E269\ +EAD1FBD69E941D4AD2012DA2C5B21BCFBF98E4A77AB2AF1F3FDA3233F046D38F\ +1DC8:\ +DB71A082A16BC8CE55235901A826E41D15016F26093C474086F2D0D3EE36FFD4\ +EDE1F75DCD811F74A7A64036969D53F20ADA190A2284E891C9F6CE98631EE2BC + +E90847AE6797FBC0B6B36D6E588C0A743D725788CA50B6D792352EA8294F5BA6\ +54A15366B8E1B288D84F5178240827975A763BC45C7B0430E8A559DF4488505E\ +009C63DA994F1403F407958203CEBB6E37D89C94A5EACF6039A327F6C4DBBC7A\ +2A307D976AA39E41AF6537243FC218DFA6AB4DD817B6A397DF5CA69107A91987\ +99ED248641B63B42CB4C29BFDD7975AC96EDFC274AC562D0474C60347A078CE4\ +C25E88:\ +B5219A12D02F6C17257BB2AC9911FBAA84FFA5E4BCD3351CE37D1D3E5E5CB9D1\ +72FD92DCD567C825DC86EB70C4F97ACE90324CDAA760E458C08B80E87A8B9858 + +F6D5C2B6C93954FC627602C00C4CA9A7D3ED12B27173F0B2C9B0E4A5939398A6\ +65E67E69D0B12FB7E4CEB253E8083D1CEB724AC07F009F094E42F2D6F2129489\ +E846EAFF0700A8D4453EF453A3EDDC18F408C77A83275617FABC4EA3A2833AA7\ +3406C0E966276079D38E8E38539A70E194CC5513AAA457C699383FD1900B1E72\ +BDFB835D1FD321B37BA80549B078A49EA08152869A918CA57F5B54ED71E4FD3A\ +C5C06729:\ +DF93616C367AF33B7D33B5F7FBD3332B9AA48FDF102F1D28767449EE4F8C3FC9\ +57BBFD94C7D52D98AEA7C2D5B4A0DC1ACE3DD878BD7F21D307403A3C5A2E57E6 + +CF8562B1BED89892D67DDAAF3DEEB28246456E972326DBCDB5CF3FB289ACA01E\ +68DA5D59896E3A6165358B071B304D6AB3D018944BE5049D5E0E2BB819ACF67A\ +6006111089E6767132D72DD85BEDDCBB2D64496DB0CC92955AB4C6234F1EEA24\ +F2D51483F2E209E4589BF9519FAC51B4D061E801125E605F8093BB6997BC163D\ +551596FE4AB7CFAE8FB9A90F6980480CE0C229FD1675409BD788354DAF316240\ +CFE0AF93EB:\ +899287D20D7D50E5B95308F1CFD16591DA081D5D1A65FE4EBECA519AF27298C8\ +2D4B9B8CBE92EFA03E3F7E856B20CA6E8CA9FF9388AB8F89A8CD96F2F36E03D3 + +2ACE31ABB0A2E3267944D2F75E1559985DB7354C6E605F18DC8470423FCA30B7\ +331D9B33C4A4326783D1CAAE1B4F07060EFF978E4746BF0C7E30CD61040BD5EC\ +2746B29863EB7F103EBDA614C4291A805B6A4C8214230564A0557BC7102E0BD3\ +ED23719252F7435D64D210EE2AAFC585BE903FA41E1968C50FD5D5367926DF7A\ +05E3A42CF07E656FF92DE73B036CF8B19898C0CB34557C0C12C2D8B84E91181A\ +F467BC75A9D1:\ +55B57907035DF0F13C09C2B87425A359281C39B37BE89DC62A7D3A9C91B42160\ +B96AF8C2A6BE6B1FC319970A4EC63A0365467A02D0F23DB67BF03681A0E38F7B + +0D8D09AED19F1013969CE5E7EB92F83A209AE76BE31C754844EA9116CEB39A22\ +EBB6003017BBCF26555FA6624185187DB8F0CB3564B8B1C06BF685D47F3286ED\ +A20B83358F599D2044BBF0583FAB8D78F854FE0A596183230C5EF8E54426750E\ +AF2CC4E29D3BDD037E734D863C2BD9789B4C243096138F7672C232314EFFDFC6\ +513427E2DA76916B5248933BE312EB5DDE4CF70804FB258AC5FB82D58D08177A\ +C6F4756017FFF5:\ +98E5DAC81EF43D68526A72206AEC6CB22C7381BEEB09B54761F5F979E0EC9675\ +32512D1864A1F8EABE6AEC3B0809B83217D654C8FF6EB2CA86E3CDF41AD348A1 + +C3236B73DEB7662BF3F3DAA58F137B358BA610560EF7455785A9BEFDB035A066\ +E90704F929BD9689CEF0CE3BDA5ACF4480BCEB8D09D10B098AD8500D9B6071DF\ +C3A14AF6C77511D81E3AA8844986C3BEA6F469F9E02194C92868CD5F51646256\ +798FF0424954C1434BDFED9FACB390B07D342E992936E0F88BFD0E884A0DDB67\ +9D0547CCDEC6384285A45429D115AC7D235A717242021D1DC35641F5F0A48E84\ +45DBA58E6CB2C8EA:\ +113A41F7819CA13ABC6D1E02906C5911006F407822821F32E55D808E51E15BCD\ +EA473E02F01B74F2E7EECBCD90448CC24D2363039E0FA99B769506F19CB38DC4 + +B39FEB8283EADC63E8184B51DF5AE3FD41AAC8A963BB0BE1CD08AA5867D8D910\ +C669221E73243360646F6553D1CA05A84E8DC0DE05B6419EC349CA994480193D\ +01C92525F3FB3DCEFB08AFC6D26947BDBBFD85193F53B50609C6140905C53A66\ +86B58E53A319A57B962331EDE98149AF3DE3118A819DA4D76706A0424B4E1D29\ +10B0ED26AF61D150EBCB46595D4266A0BD7F651BA47D0C7F179CA28545007D92\ +E8419D48FDFBD744CE:\ +D3CC7B4F7EF29FB4B1145F18C80D10F9568B7B597BED8C8FCA0D1E2F0A52EAA5\ +746C832AF9402DA8035FFCBB759A1B7078053E0A1148484FA31C0402B829D4B7 + +A983D54F503803E8C7999F4EDBBE82E9084F422143A932DDDDC47A17B0B7564A\ +7F37A99D0786E99476428D29E29D3C197A72BFAB1342C12A0FC4787FD7017D7A\ +6174049EA43B5779169EF7472BDBBD941DCB82FC73AAC45A8A94C9F2BD3477F6\ +1FD3B796F02A1B8264A214C6FEA74B7051B226C722099EC7883A462B83B6AFDD\ +4009248B8A237F605FE5A08FE7D8B45321421EBBA67BD70A0B00DDBF94BAAB7F\ +359D5D1EEA105F28DCFB:\ +9F064FDC60802C9382DA2875A370F3208EB36E192FA958995A586D1F735DBD55\ +E26A656942E5CC2050457E866371594D5928AFAE70F8C10DD31252B965D5FDCA + +E4D1C1897A0A866CE564635B74222F9696BF2C7F640DD78D7E2ACA66E1B61C64\ +2BB03EA7536AAE597811E9BF4A7B453EDE31F97B46A5F0EF51A071A2B3918DF1\ +6B152519AE3776F9F1EDAB4C2A377C3292E96408359D3613844D5EB393000283\ +D5AD3401A318B12FD1474B8612F2BB50FB6A8B9E023A54D7DDE28C43D6D8854C\ +8D9D1155935C199811DBFC87E9E0072E90EB88681CC7529714F8FB8A2C9D8856\ +7ADFB974EE205A9BF7B848:\ +9A04ECD9BB469A9501EBE71B9748128C4726019D76A4A3C1DE6A211902CA9C06\ +7979F2996501449188BE0A75244AB369E032F1D9C73DEA1882CC383DE8084E8F + +B10C59723E3DCADD6D75DF87D0A1580E73133A9B7D00CB95EC19F5547027323B\ +E75158B11F80B6E142C6A78531886D9047B08E551E75E6261E79785366D7024B\ +D7CD9CF322D9BE7D57FB661069F2481C7BB759CD71B4B36CA2BC2DF6D3A328FA\ +EBDB995A9794A8D72155ED551A1F87C80BF6059B43FC764900B18A1C2441F748\ +7743CF84E565F61F8DD2ECE6B6CCC9444049197AAAF53E926FBEE3BFCA8BE588\ +EC77F29D211BE89DE18B15F6:\ +F20C6D8BB06FBAEBFA3C2A9DF6E294D2CF64EF359973B438B7FA1192EBF607BC\ +0464CB53154A50291614FD094D9B60BDD27077898130C22CF4316B6176358EE5 + +DB11F609BABA7B0CA634926B1DD539C8CBADA24967D7ADD4D9876F77C2D80C0F\ +4DCEFBD7121548373582705CCA2495BD2A43716FE64ED26D059CFB566B3364BD\ +49EE0717BDD9810DD14D8FAD80DBBDC4CAFB37CC60FB0FE2A80FB4541B8CA9D5\ +9DCE457738A9D3D8F641AF8C3FD6DA162DC16FC01AAC527A4A0255B4D231C0BE\ +50F44F0DB0B713AF03D968FE7F0F61ED0824C55C4B5265548FEBD6AAD5C5EEDF\ +63EFE793489C39B8FD29D104CE:\ +2BC62B625A06D5F275FB633800AA00DB13AFC03DFBBE4CE287722BE3E7A55041\ +1A8FF84545CCEE032822FF43345C9841D6502914539C78038692628A143212E6 + +BEBD4F1A84FC8B15E4452A54BD02D69E304B7F32616AADD90537937106AE4E28\ +DE9D8AAB02D19BC3E2FDE1D651559E296453E4DBA94370A14DBBB2D1D4E20223\ +02EE90E208321EFCD8528AD89E46DC839EA9DF618EA8394A6BFF308E7726BAE0\ +C19BCD4BE52DA6258E2EF4E96AA21244429F49EF5CB486D7FF35CAC1BACB7E95\ +711944BCCB2AB34700D42D1EB38B5D536B947348A458EDE3DC6BD6EC547B1B0C\ +AE5B257BE36A7124E1060C170FFA:\ +248F4AEC829773B1E7525BD318960310B81316078474525BCEFD1AA71757FDE1\ +3483F9A30B0F53E538635FF9CABA15625F6DAF03478669EE60D054A90CB100DE + +5ACA56A03A13784BDC3289D9364F79E2A85C12276B49B92DB0ADAA4F206D5028\ +F213F678C3510E111F9DC4C1C1F8B6ACB17A6413AA227607C515C62A733817BA\ +5E762CC6748E7E0D6872C984D723C9BB3B117EB8963185300A80BFA65CDE495D\ +70A46C44858605FCCBED086C2B45CEF963D33294DBE9706B13AF22F1B7C4CD5A\ +001CFEC251FBA18E722C6E1C4B1166918B4F6F48A98B64B3C07FC86A6B17A6D0\ +480AB79D4E6415B520F1C484D675B1:\ +BA89BFC6C669413652B22BD2EB1E8C520FCE131FB9ADB84470E3163752EA7E6D\ +F663B3631E0629FA90BB05B738BD2BCBC1A83C4AE03E6845860BF027B73CBB20 + +A5AAD0E4646A32C85CFCAC73F02FC5300F1982FABB2F2179E28303E447854094\ +CDFC854310E5C0F60993CEFF54D84D6B46323D930ADB07C17599B35B505F09E7\ +84BCA5985E0172257797FB53649E2E9723EFD16865C31B5C3D5113B58BB0BFC8\ +920FABDDA086D7537E66D709D050BD14D0C960873F156FAD5B3D3840CDFCDC9B\ +E6AF519DB262A27F40896AB25CC39F96984D650611C0D5A3080D5B3A1BF186AB\ +D42956588B3B58CD948970D298776060:\ +011124D568ADA8413909D3E0C1BDB23EBF6389A80CC7EF03B9CA1556E70EC67C\ +81DE188C2DC900D4DF8DD7412ECEAAF91EB6495B4BC218B38722099D415D22A5 + +06CBBE67E94A978203EAD6C057A1A5B098478B4B4CBEF5A97E93C8E42F557271\ +3575FC2A884531D7622F8F879387A859A80F10EF02708CD8F7413AB385AFC357\ +678B9578C0EBF641EF076A1A30F1F75379E9DCB2A885BDD295905EE80C0168A6\ +2A9597D10CF12DD2D8CEE46645C7E5A141F6E0E23AA482ABE5661C16E69EF1E2\ +8371E2E236C359BA4E92C25626A7B7FF13F6EA4AE906E1CFE163E91719B1F750\ +A96CBDE5FBC953D9E576CD216AFC90323A:\ +8D03C8E3B207C306EB3BB093A4750176F3B458699731A7690FEC874363CF662A\ +2BD27C41FE86E4B410460C1581EC48A9D8F2AFB6C1BB91433AEC5C4147DC3F50 + +F1C528CF7739874707D4D8AD5B98F7C77169DE0B57188DF233B2DC8A5B31EDA5\ +DB4291DD9F68E6BAD37B8D7F6C9C0044B3BF74BBC3D7D1798E138709B0D75E7C\ +593D3CCCDC1B20C7174B4E692ADD820ACE262D45CCFAE2077E87879634716806\ +0A162ECCA8C38C1A88350BD63BB539134F700FD4ADDD5959E255337DAA06BC86\ +358FABCBEFDFB5BC889783D843C08AADC6C4F6C36F65F156E851C9A0F917E4A3\ +67B5AD93D874812A1DE6A7B93CD53AD97232:\ +14B3D36C24E80F3B0D7C69F01FCEDE9F109664541ED6E63C75271219BFFAD474\ +F130E984AC82B6B8DDF7F58D7FF93A931CFFEED7991F1FF7E07DEFD7E74F521D + +9D9F3A7ECD51B41F6572FD0D0881E30390DFB780991DAE7DB3B47619134718E6\ +F987810E542619DFAA7B505C76B7350C6432D8BF1CFEBDF1069B90A35F0D04CB\ +DF130B0DFC7875F4A4E62CDB8E525AADD7CE842520A482AC18F09442D78305FE\ +85A74E39E760A4837482ED2F437DD13B2EC1042AFCF9DECDC3E877E50FF4106A\ +D10A525230D11920324A81094DA31DEAB6476AA42F20C84843CFC1C58545EE80\ +352BDD3740DD6A16792AE2D86F11641BB717C2:\ +A2F336A9D8816018E4A1B8968D3BEF6800A3B390488AD2E2E119F18EA2B7522B\ +CF21DF4C5333BBCC5ECB3E9D9E8909DFC1733A417AF9F5B9FC4D8B9AABE7C650 + +5179888724819FBAD3AFA927D3577796660E6A81C52D98E9303261D5A4A83232\ +F6F758934D50AA83FF9E20A5926DFEBAAC49529D006EB923C5AE5048ED544EC4\ +71ED7191EDF46363383824F915769B3E688094C682B02151E5EE01E510B431C8\ +865AFF8B6B6F2F59CB6D129DA79E97C6D2B8FA6C6DA3F603199D2D1BCAB54768\ +2A81CD6CF65F6551121391D78BCC23B5BD0E922EC6D8BF97C952E84DD28AEF90\ +9ABA31EDB903B28FBFC33B7703CD996215A11238:\ +BED7C99B12478DE47C358637E8977FBC10FD763014196439611D1DE3D6479AED\ +20C5CB3897E70A4B9D428F689835A7E7C99177DD306333D12C5E6B7B88EAF5E4 + +576EF3520D30B7A4899B8C0D5E359E45C5189ADD100E43BE429A02FB3DE5FF4F\ +8FD0E79D9663ACCA72CD29C94582B19292A557C5B1315297D168FBB54E9E2ECD\ +13809C2B5FCE998EDC6570545E1499DBE7FB74D47CD7F35823B212B05BF3F5A7\ +9CAA34224FDD670D335FCB106F5D92C3946F44D3AFCBAE2E41AC554D8E6759F3\ +32B76BE89A0324AA12C5482D1EA3EE89DED4936F3E3C080436F539FA137E74C6\ +D3389BDF5A45074C47BC7B20B0948407A66D855E2F:\ +47F5829780E5F634981B4EA095F79CB05395B7FDC3430D4FE0316EDC20B7FCAC\ +81148B900AE95E356F2D194EB69FB6E6786FABC5BF8A6F13F56D881E2A4D6D27 + +0DF2152FA4F4357C8741529DD77E783925D3D76E95BAFA2B542A2C33F3D1D117\ +D159CF473F82310356FEE4C90A9E505E70F8F24859656368BA09381FA245EB6C\ +3D763F3093F0C89B972E66B53D59406D9F01AEA07F8B3B615CAC4EE4D05F542E\ +7D0DAB45D67CCCCD3A606CCBEB31EA1FA7005BA07176E60DAB7D78F6810EF086\ +F42F08E595F0EC217372B98970CC6321576D92CE38F7C397A403BADA1548D205\ +C343AC09DECA86325373C3B76D9F32028FEA8EB32515:\ +477AD92922C418C83FF158D20A806242D41670C1F8FD39315C6651D0D81E49FF\ +27D631892972C88D31FBF448EB135B2FCCA0873B2C37F2DDC0B0E71BAC857E8B + +3E15350D87D6EBB5C8AD99D42515CFE17980933C7A8F6B8BBBF0A63728CEFAAD\ +2052623C0BD5931839112A48633FB3C2004E0749C87A41B26A8B48945539D1FF\ +41A4B269462FD199BFECD45374756F55A9116E92093AC99451AEFB2AF9FD32D6\ +D7F5FBC7F7A540D5097C096EBC3B3A721541DE073A1CC02F7FB0FB1B9327FB0B\ +1218CA49C9487AB5396622A13AE546C97ABDEF6B56380DDA7012A8384091B665\ +6D0AB272D363CEA78163FF765CDD13AB1738B940D16CAE:\ +24ADD48203FC4772BE68A87FDEFEC3F762DD8945CF421697B70C6612BB19224F\ +EA974E3876FE3F2B745FA53F3A89E569989B735F63A46491E4627AFFD6B6CEFA + +C38D6B0B757CB552BE40940ECE0009EF3B0B59307C1451686F1A22702922800D\ +58BCE7A636C1727EE547C01B214779E898FC0E560F8AE7F61BEF4D75EAA696B9\ +21FD6B735D171535E9EDD267C192B99880C87997711002009095D8A7A437E258\ +104A41A505E5EF71E5613DDD2008195F0C574E6BA3FE40099CFA116E5F1A2FA8\ +A6DA04BADCB4E2D5D0DE31FDC4800891C45781A0AAC7C907B56D631FCA5CE8B2\ +CDE620D11D1777ED9FA603541DE794DDC5758FCD5FAD78C0:\ +8A7340C39AB7450164B915C02B6A6B5EE8361E4BF6EE43E931E3AD7EC3CCA66F\ +20558DF5EEAE5D56E9ABAD9A9F48F8ADC8646D55638993B27EA080226445E7EF + +8D2DE3F0B37A6385C90739805B170057F091CD0C7A0BC951540F26A5A75B3E69\ +4631BB64C7635EED316F51318E9D8DE13C70A2ABA04A14836855F35E480528B7\ +76D0A1E8A23B547C8B8D6A0D09B241D3BE9377160CCA4E6793D00A515DC2992C\ +B7FC741DACA171431DA99CCE6F7789F129E2AC5CF65B40D703035CD2185BB936\ +C82002DAF8CBC27A7A9E554B06196630446A6F0A14BA155ED26D95BD627B7205\ +C072D02B60DB0FD7E49EA058C2E0BA202DAFF0DE91E845CF79:\ +C18DA8AC3BD52C9C27AF65DDBB21C7DC87C65E5F6FE23C181CC2D76E6E35E0D6\ +DD8B2CE9C5B707D91459549F08FED2E28891658833818531829932372928FD4B + +C464BBDAD275C50DCD983B65AD1019B9FF85A1E71C807F3204BB2C921DC31FBC\ +D8C5FC45868AE9EF85B6C9B83BBA2A5A822201ED68586EC5EC27FB2857A5D1A2\ +D09D09115F22DCC39FE61F5E1BA0FF6E8B4ACB4C6DA748BE7F3F0839739394FF\ +7FA8E39F7F7E84A33C3866875C01BCB1263C9405D91908E9E0B50E7459FABB63\ +D8C6BBB73D8E3483C099B55BC30FF092FF68B6ADEDFD477D63570C9F5515847F\ +36E24BA0B705557130CEC57EBAD1D0B31A378E91894EE26E3A04:\ +F987CA0943562B86D5CB09CF4BDC06532B4BE5F4B349AFE31B50D1CC052E3638\ +79DBBD78C3D7F642F9A29E5DECB7888806811E9F2115132DABF6720F8EE42368 + +8B8D68BB8A75732FE272815A68A1C9C5AA31B41DEDC8493E76525D1D013D33CE\ +BD9E21A5BB95DB2616976A8C07FCF411F5F6BC6F7E0B57ACA78CC2790A6F9B89\ +8858AC9C79B165FF24E66677531E39F572BE5D81EB3264524181115F32780257\ +BFB9AEEC6AF12AF28E587CAC068A1A2953B59AD680F4C245B2E3EC36F59940D3\ +7E1D3DB38E13EDB29B5C0F404F6FF87F80FC8BE7A225FF22FBB9C8B6B1D7330C\ +57840D24BC75B06B80D30DAD6806544D510AF6C4785E823AC3E0B8:\ +A08812A778848BCC4CCDC27B297C2A39313EF0D2A3E490295C7AECC687163458\ +62768DD92EB7CB7F521AEEE5545A807ACCA74828AD13FF9AB9F7516FA76147FA + +6B018710446F368E7421F1BC0CCF562D9C1843846BC8D98D1C9BF7D9D6FCB48B\ +FC3BF83B36D44C4FA93430AF75CD190BDE36A7F92F867F58A803900DF8018150\ +384D85D82132F123006AC2AEBA58E02A037FE6AFBD65ECA7C44977DD3DC74F48\ +B6E7A1BFD5CC4DCF24E4D52E92BD4455848E4928B0EAC8B7476FE3CC03E862AA\ +4DFF4470DBFED6DE48E410F25096487ECFC32A27277F3F5023B2725ADE461B13\ +55889554A8836C9CF53BD767F5737D55184EEA1AB3F53EDD0976C485:\ +241EF5BC35C9FD842699C4BA03AFB4FED737CDBDE73B12CE0F7D118C92139C29\ +E9126AA81E3E06102BC3009043F0BEA6AE2E48C2D5D93A467991397F5E99D8FD + +C9534A24714BD4BE37C88A3DA1082EDA7CABD154C309D7BD670DCCD95AA53559\ +4463058A29F79031D6ECAA9F675D1211E9359BE82669A79C855EA8D89DD38C2C\ +761DDD0EC0CE9E97597432E9A1BEAE062CDD71EDFDFD464119BE9E69D18A7A7F\ +D7CE0E2106F0C8B0ABF4715E2CA48EF9F454DC203C96656653B727083513F8EF\ +B86E49C513BB758B3B052FE21F1C05BB33C37129D6CC81F1AEF6ADC45B0E8827\ +A830FE545CF57D0955802C117D23CCB55EA28F95C0D8C2F9C5A242B33F:\ +7F013A499D91DAD964C5D32F428EE352EBACD1B900F09186CA769A3B1C370D4F\ +CAC310C5F217DA581AC7B0202AE038AAE7E3F0CB484605C7F54CEE4FD3C3A272 + +07906C87297B867ABF4576E9F3CC7F82F22B154AFCBF293B9319F1B0584DA6A4\ +0C27B32E0B1B7F412C4F1B82480E70A9235B12EC27090A5A33175A2BB28D8ADC\ +475CEFE33F7803F8CE27967217381F02E67A3B4F84A71F1C5228E0C2AD971373\ +F6F672624FCEA8D1A9F85170FAD30FA0BBD25035C3B41A6175D467998BD1215F\ +6F3866F53847F9CF68EF3E2FBB54BC994DE2302B829C5EEA68EC441FCBAFD7D1\ +6AE4FE9FFF98BF00E5BC2AD54DD91FF9FDA4DD77B6C754A91955D1FBAAD0:\ +F9B6C3E55260AD9459E78CBF77EF9F46EE94658BEA13F31C34A1548355A4A301\ +7E11BFB20427F4A98B9ABFFB80C168FDCE3B58513D4E05B005B10B1CD41D1DAF + +588E94B9054ABC2189DF69B8BA34341B77CDD528E7860E5DEFCAA79B0C9A452A\ +D4B82AA306BE84536EB7CEDCBE058D7B84A6AEF826B028B8A0271B69AC3605A9\ +635EA9F5EA0AA700F3EB7835BC54611B922964300C953EFE7491E3677C2CEBE0\ +822E956CD16433B02C68C4A23252C3F9E151A416B4963257B783E038F6B4D5C9\ +F110F871652C7A649A7BCEDCBCCC6F2D0725BB903CC196BA76C76AA9F10A190B\ +1D1168993BAA9FFC96A1655216773458BEC72B0E39C9F2C121378FEAB4E76A:\ +41CAAC4E9A2258FE986991DE2FBDD35B0A44BFCD7E7AFB5826ABFD98407143B1\ +2661C4C5CC326A6A5002D4175B8CCC96CCFACA175671D67673E0E7A9B3A2EE43 + +08959A7E4BAAE874928813364071194E2939772F20DB7C3157078987C557C2A6\ +D5ABE68D520EEF3DC491692E1E21BCD880ADEBF63BB4213B50897FA005256ED4\ +1B5690F78F52855C8D9168A4B666FCE2DA2B456D7A7E7C17AB5F2FB1EE90B79E\ +698712E963715983FD07641AE4B4E9DC73203FAC1AE11FA1F8C7941FCC82EAB2\ +47ADDB56E2638447E9D609E610B60CE086656AAEBF1DA3C8A231D7D94E2FD0AF\ +E46B391FF14A72EAEB3F44AD4DF85866DEF43D4781A0B3578BC996C87970B132:\ +95B7B94203B6625E36BDF04A3F40E79209D5A8BF5B27C836068EB3E944F76FF7\ +6AC5086D1AA510F8CB560360E02FDE47C324DFA6412E31923BECF5B9A5CE74F7 + +CB2A234F45E2ECD5863895A451D389A369AAB99CFEF0D5C9FFCA1E6E63F763B5\ +C14FB9B478313C8E8C0EFEB3AC9500CF5FD93791B789E67EAC12FD038E2547CC\ +8E0FC9DB591F33A1E4907C64A922DDA23EC9827310B306098554A4A78F050262\ +DB5B545B159E1FF1DCA6EB734B872343B842C57EAFCFDA8405EEDBB48EF32E99\ +696D135979235C3A05364E371C2D76F1902F1D83146DF9495C0A6C57D7BF9EE7\ +7E80F9787AEE27BE1FE126CDC9EF893A4A7DCBBC367E40FE4E1EE90B42EA25AF\ +01:\ +9C212622F625449B5F09544816DE7792F99FDAE01405EB667210A8566E4A48FF\ +7948F1A8DA07CDB8ABE38660CA4D5D6E87B4D078493DA1A22574ECEA221E4FAA + +D16BEADF02AB1D4DC6F88B8C4554C51E866DF830B89C06E786A5F8757E890931\ +0AF51C840EFE8D20B35331F4355D80F73295974653DDD620CDDE4730FB6C8D0D\ +2DCB2B45D92D4FBDB567C0A3E86BD1A8A795AF26FBF29FC6C65941CDDB090FF7\ +CD230AC5268AB4606FCCBA9EDED0A2B5D014EE0C34F0B2881AC036E24E151BE8\ +9EEB6CD9A7A790AFCCFF234D7CB11B99EBF58CD0C589F20BDAC4F9F0E28F75E3\ +E04E5B3DEBCE607A496D848D67FA7B49132C71B878FD5557E082A18ECA1FBDA9\ +4D4B:\ +04EC35E912AF0ACB1914785EE00506E96D633E81ED6AD7B971CD0434EE61CCE6\ +F6FF3DC1BD1B1282E9A2A9D25D5480D4C6C47681212B24CDE68A632A0294ADEA + +8F65F6BC59A85705016E2BAE7FE57980DE3127E5AB275F573D334F73F8603106\ +EC3553016608EF2DD6E69B24BE0B7113BF6A760BA6E9CE1C48F9E186012CF96A\ +1D4849D75DF5BB8315387FD78E9E153E76F8BA7EC6C8849810F59FB4BB9B0043\ +18210B37F1299526866F44059E017E22E96CBE418699D014C6EA01C9F0038B10\ +299884DBEC3199BB05ADC94E955A1533219C1115FED0E5F21228B071F40DD57C\ +4240D98D37B73E412FE0FA4703120D7C0C67972ED233E5DEB300A22605472FA3\ +A3BA86:\ +177D4D8DAD1C6C05147B8D4FD8713E988CEF19B417810387B68B90DA075CDDDF\ +08C927328A69F4D21CD6E6CFF1B446F2980261BE7842ED07B7609D5FA23A13B9 + +84891E52E0D451813210C3FD635B39A03A6B7A7317B221A7ABC270DFA946C426\ +69AACBBBDF801E1584F330E28C729847EA14152BD637B3D0F2B38B4BD5BF9C79\ +1C58806281103A3EABBAEDE5E711E539E6A8B2CF297CF351C078B4FA8F7F35CF\ +61BEBF8814BF248A01D41E86C5715EA40C63F7375379A7EB1D78F27622FB468A\ +B784AAABA4E534A6DFD1DF6FA15511341E725ED2E87F98737CCB7B6A6DFAE416\ +477472B046BF1811187D151BFA9F7B2BF9ACDB23A3BE507CDF14CFDF517D2CB5\ +FB9E4AB6:\ +D109E4EA58F1E95BB67D4B4C33C23DCD91E8E659CCD2F71D63D63EF62445A4A0\ +029AF5F9B40280D8BD461DE3AAC765A8894568853B0E2146E407E1B31E5F7511 + +FDD7A9433A3B4AFABD7A3A5E3457E56DEBF78E84B7A0B0CA0E8C6D53BD0C2DAE\ +31B2700C6128334F43981BE3B213B1D7A118D59C7E6B6493A86F866A1635C128\ +59CFB9AD17460A77B4522A5C1883C3D6ACC86E6162667EC414E9A104AA892053\ +A2B1D72165A855BACD8FAF8034A5DD9B716F47A0818C09BB6BAF22AA503C06B4\ +CA261F557761989D2AFBD88B6A678AD128AF68672107D0F1FC73C5CA74045929\ +7B3292B281E93BCEB761BDE7221C3A55708E5EC84472CDDCAA84ECF23723CC09\ +91355C6280:\ +8973998BEF6F4971835BF108EC3A815AE1120557F39BA502979E963FC811D356\ +67B4614A09ADE41F9086166B614ACE97821EFB3E27F956E33FC1152905481E0A + +70A40BFBEF92277A1AAD72F6B79D0177197C4EBD432668CFEC05D099ACCB6510\ +62B5DFF156C0B27336687A94B26679CFDD9DAF7AD204338DD9C4D14114033A5C\ +225BD11F217B5F4732DA167EE3F939262D4043FC9CBA92303B7B5E96AEA12ADD\ +A64859DF4B86E9EE0B58E39091E6B188B408AC94E1294A8911245EE361E60E60\ +1EFF58D1D37639F3753BEC80EBB4EFDE25817436076623FC65415FE51D1B0280\ +366D12C554D86743F3C3B6572E400361A60726131441BA493A83FBE9AFDA90F7\ +AF1AE717238D:\ +537817B86EFAD56797435E4F81BF20791C52506554B550A14FEED4B8DE53A871\ +BB35D275D2C144B6A4F5626A8AEE56B6975F8B6D621C520E6DB30F710DEB7B73 + +74356E449F4BF8644F77B14F4D67CB6BD9C1F5AE357621D5B8147E562B65C665\ +85CAF2E491B48529A01A34D226D436959153815380D5689E30B35357CDAC6E08\ +D3F2B0E88E200600D62BD9F5EAF488DF86A4470EA227006182E44809009868C4\ +C280C43D7D64A5268FA719074960087B3A6ABC837882F882C837834535929389\ +A12B2C78187E2EA07EF8B8EEF27DC85002C3AE35F1A50BEE6A1C48BA7E175F33\ +16670B27983472AA6A61EED0A683A39EE323080620EA44A9F74411AE5CE99030\ +528F9AB49C79F2:\ +EB0B4CBCC5B846BF9342D74E6D555D7768A049F1CD4D98055BC3328C08477DA8\ +7CC9017215766F83CBF8E7C74204643F38741931672E178ECB6C33C6F97BD8A9 + +8C3798E51BC68482D7337D3ABB75DC9FFE860714A9AD73551E120059860DDE24\ +AB87327222B64CF774415A70F724CDF270DE3FE47DDA07B61C9EF2A3551F45A5\ +584860248FABDE676E1CD75F6355AA3EAEABE3B51DC813D9FB2EAA4F0F1D9F83\ +4D7CAD9C7C695AE84B329385BC0BEF895B9F1EDF44A03D4B410CC23A79A6B62E\ +4F346A5E8DD851C2857995DDBF5B2D717AEB847310E1F6A46AC3D26A7F9B4498\ +5AF656D2B7C9406E8A9E8F47DCB4EF6B83CAACF9AEFB6118BFCFF7E44BEF6937\ +EBDDC89186839B77:\ +75EDFA49C1995B191F5EE4689580A6C4A5AB9637C257AED28E8D9C0002EAB048\ +6E1AAA86FF81C8095EB21A7A04EAF33C8E637E771DB4EE970567870F0E0FFC00 + +FA56BF730C4F8395875189C10C4FB251605757A8FECC31F9737E3C2503B02608\ +E6731E85D7A38393C67DE516B85304824BFB135E33BF22B3A23B913BF6ACD2B7\ +AB85198B8187B2BCD454D5E3318CACB32FD6261C31AE7F6C54EF6A7A2A4C9F3E\ +CB81CE3555D4F0AD466DD4C108A90399D70041997C3B25345A9653F3C9A6711A\ +B1B91D6A9D2216442DA2C973CBD685EE7643BFD77327A2F7AE9CB283620A0871\ +6DFB462E5C1D65432CA9D56A90E811443CD1ECB8F0DE179C9CB48BA4F6FEC360\ +C66F252F6E64EDC96B:\ +689A1EE00FAA07E5CF96DA422ABE07962C42222B6B9928B761CFE7BA61762FE1\ +BE30267AD53B483E503B1EF21017C083DF32692C5D0CD65979B416F231A1F654 + +B6134F9C3E91DD8000740D009DD806240811D51AB1546A974BCB18D344642BAA\ +5CD5903AF84D58EC5BA17301D5EC0F10CCD0509CBB3FD3FFF9172D193AF0F782\ +252FD1338C7244D40E0E42362275B22D01C4C3389F19DD69BDF958EBE28E31A4\ +FFE2B5F18A87831CFB7095F58A87C9FA21DB72BA269379B2DC2384B3DA953C79\ +25761FED324620ACEA435E52B424A7723F6A2357374157A34CD8252351C25A1B\ +232826CEFE1BD3E70FFC15A31E7C0598219D7F00436294D11891B82497BC78AA\ +5363892A2495DF8C1EEF:\ +23A1FFD72251693480A286725193A64A83F11367DFB38F039F117FF7351934C9\ +009C83DB46BA13EE7C8CE2045C1F6E418963CDCD8FD051B8A71ADBC6481ECEAE + +C941CDB9C28AB0A791F2E5C8E8BB52850626AA89205BEC3A7E22682313D198B1\ +FA33FC7295381354858758AE6C8EC6FAC3245C6E454D16FA2F51C4166FAB51DF\ +272858F2D603770C40987F64442D487AF49CD5C3991CE858EA2A60DAB6A65A34\ +414965933973AC2457089E359160B7CDEDC42F29E10A91921785F6B7224EE0B3\ +49393CDCFF6151B50B377D609559923D0984CDA6000829B916AB6896693EF6A2\ +199B3C22F7DC5500A15B8258420E314C222BC000BC4E5413E6DD82C993F8330F\ +5C6D1BE4BC79F08A1A0A46:\ +3B8BF1BF8A10E06238CCF7CD7EF2694F942EF6C720381CDE80E0396F4560BB1B\ +B40FB6C3BF6CC08DF574C3EEEC1BEF8F27A1F9D33BA7344F502BCA40E7321636 + +4499EFFFAC4BCEA52747EFD1E4F20B73E48758BE915C88A1FFE5299B0B005837\ +A46B2F20A9CB3C6E64A9E3C564A27C0F1C6AD1960373036EC5BFE1A8FC6A435C\ +2185ED0F114C50E8B3E4C7ED96B06A036819C9463E864A58D6286F785E32A804\ +443A56AF0B4DF6ABC57ED5C2B185DDEE8489EA080DEEEE66AA33C2E6DAB36251\ +C402682B6824821F998C32163164298E1FAFD31BABBCFFB594C91888C6219079\ +D907FDB438ED89529D6D96212FD55ABE20399DBEFD342248507436931CDEAD49\ +6EB6E4A80358ACC78647D043:\ +25318513F5A4FFDF6CCB164F9A01286656B4F3F2F47CCCFCC9EBA895AB98C2BE\ +5EBE30BDD7573B471D3B952318BCD8D6D3BF8BD5427ABA6F039F7EB5031D3876 + +EECBB8FDFA4DA62170FD06727F697D81F83F601FF61E478105D3CB7502F2C89B\ +F3E8F56EDD469D049807A38882A7EEFBC85FC9A950952E9FA84B8AFEBD3CE782\ +D4DA598002827B1EB98882EA1F0A8F7AA9CE013A6E9BC462FB66C8D4A18DA214\ +01E1B93356EB12F3725B6DB1684F2300A98B9A119E5D27FF704AFFB618E12708\ +E77E6E5F34139A5A41131FD1D6336C272A8FC37080F041C71341BEE6AB550CB4\ +A20A6DDB6A8E0299F2B14BC730C54B8B1C1C487B494BDCCFD3A53535AB2F2315\ +90BF2C4062FD2AD58F906A2D0D:\ +093591FBF29F8D4D493F2F8890D2BA59A17C4D31F8D42288859365AF1B74E0CA\ +D8274493BFB2E0A0656EB09B447721E577BBBBB92E97A8CC32E6EEDDCDADAD58 + +E64F3E4ACE5C8418D65FEC2BC5D2A303DD458034736E3B0DF719098BE7A206DE\ +AF52D6BA82316CAF330EF852375188CDE2B39CC94AA449578A7E2A8E3F5A9D68\ +E816B8D16889FBC0EBF0939D04F63033AE9AE2BDAB73B88C26D6BD25EE460EE1\ +EF58FB0AFA92CC539F8C76D3D097E7A6A63EBB9B5887EDF3CF076028C5BBD5B9\ +DB3211371AD3FE121D4E9BF44229F4E1ECF5A0F9F0EBA4D5CEB72878AB22C3F0\ +EB5A625323AC66F7061F4A81FAC834471E0C59553F108475FE290D43E6A055AE\ +3EE46FB67422F814A68C4BE3E8C9:\ +2F911D4C83F7304E72E22E4412932D949654CC446EA5104F9BFA2AC82447B668\ +3097AA3E5E04615F1A1EF2A652CC2FCCAF1663B35ED33A711E37D14E520A2595 + +D2CB2D733033F9E91395312808383CC4F0CA974E87EC68400D52E96B3FA6984A\ +C58D9AD0938DDE5A973008D818C49607D9DE2284E7618F1B8AED8372FBD52ED5\ +4557AF4220FAC09DFA8443011699B97D743F8F2B1AEF3537EBB45DCC9E13DFB4\ +38428EE190A4EFDB3CAEB7F3933117BF63ABDC7E57BEB4171C7E1AD260AB0587\ +806C4D137B6316B50ABC9CCE0DFF3ACADA47BBB86BE777E617BBE578FF451984\ +4DB360E0A96C6701290E76BB95D26F0F804C8A4F2717EAC4E7DE9F2CFF3BBC55\ +A17E776C0D02856032A6CD10AD2838:\ +E1F645AB256B807E20C728F60F8594123359322355D32A42A559F0F7FDF873D2\ +15806C3E9375B70469FB0696246E396239DC0286815EB423026951A2CDA7AE0B + +F2998955613DD414CC111DF5CE30A995BB792E260B0E37A5B1D942FE90171A4A\ +C2F66D4928D7AD377F4D0554CBF4C523D21F6E5F379D6F4B028CDCB9B1758D3B\ +39663242FF3CB6EDE6A36A6F05DB3BC41E0D861B384B6DEC58BB096D0A422FD5\ +42DF175E1BE1571FB52AE66F2D86A2F6824A8CFAACBAC4A7492AD0433EEB1545\ +4AF8F312B3B2A577750E3EFBD370E8A8CAC1582581971FBA3BA4BD0D76E718DA\ +CF8433D33A59D287F8CC92234E7A271041B526E389EFB0E40B6A18B3AAF658E8\ +2ED1C78631FD23B4C3EB27C3FAEC8685:\ +7661221986EC665F0DE59D89DFE577A1489F1B92DAAF0D4AD3BCFE0F9551FB3F\ +F85AC4971B91787D06D0640941E303C054840AB3FE1EC8B2F2EFD650A11AD785 + +447797E2899B72A356BA55BF4DF3ACCA6CDB1041EB477BD1834A9F9ACBC340A2\ +94D729F2F97DF3A610BE0FF15EDB9C6D5DB41644B9874360140FC64F52AA03F0\ +286C8A640670067A84E017926A70438DB1BB361DEFEE7317021425F8821DEF26\ +D1EFD77FC853B818545D055ADC9284796E583C76E6FE74C9AC2587AA46AA8F88\ +04F2FEB5836CC4B3ABABAB8429A5783E17D5999F32242EB59EF30CD7ADABC16D\ +72DBDB097623047C98989F88D14EAF02A7212BE16EC2D07981AAA99949DDF89E\ +CD90333A77BC4E1988A82ABF7C7CAF3291:\ +62E8BC85C0BE0C756C0B8246D251D54B2680CC4C5F38B3748AB10C0DEED191A4\ +EFEB55A02A7177EFC1285801502758B2A865851F746347876DC20994911D2F0D + +9F2C18ADE9B380C784E170FB763E9AA205F64303067EB1BCEA93DF5DAC4BF5A2\ +E00B78195F808DF24FC76E26CB7BE31DC35F0844CDED1567BBA29858CFFC97FB\ +29010331B01D6A3FB3159CC1B973D255DA9843E34A0A4061CABDB9ED37F241BF\ +ABB3C20D32743F4026B59A4CCC385A2301F83C0B0A190B0F2D01ACB8F0D41111\ +E10F2F4E149379275599A52DC089B35FDD5234B0CFB7B6D8AEBD563CA1FA653C\ +5C021DFD6F5920E6F18BFAFDBECBF0AB00281333ED50B9A999549C1C8F8C63D7\ +626C48322E9791D5FF72294049BDE91E73F8:\ +EDB827225836DACAA2BAF1ACF153396E786722C78A67C8160B26C95068EA6FB0\ +2A95F3FAF9A2A25B4225C7347101C322A9F89059E11A01DAAD438BF9B47659A7 + +AE159F3FA33619002AE6BCCE8CBBDD7D28E5ED9D61534595C4C9F43C402A9BB3\ +1F3B301CBFD4A43CE4C24CD5C9849CC6259ECA90E2A79E01FFBAC07BA0E147FA\ +42676A1D668570E0396387B5BCD599E8E66AAED1B8A191C5A47547F61373021F\ +A6DEADCB55363D233C24440F2C73DBB519F7C9FA5A8962EFD5F6252C0407F190\ +DFEFAD707F3C7007D69FF36B8489A5B6B7C557E79DD4F50C06511F599F56C896\ +B35C917B63BA35C6FF8092BAF7D1658E77FC95D8A6A43EEB4C01F33F03877F92\ +774BE89C1114DD531C011E53A34DC248A2F0E6:\ +60EE213745C9CB94BC472F96E1BF9EF79C26BA3CEC017CC50A56DAE4E7C882D2\ +8E6425CC1DF5FEF68441AB13286E0407FA36C3280ED1E5ADDA4E33EE03F3D471 + +3B8E97C5FFC2D6A40FA7DE7FCEFC90F3B12C940E7AB415321E29EE692DFAC799\ +B009C99DCDDB708FCE5A178C5C35EE2B8617143EDC4C40B4D313661F49ABDD93\ +CEA79D117518805496FE6ACF292C4C2A1F76B403A97D7C399DAF85B46AD84E16\ +246C67D6836757BDE336C290D5D401E6C1386AB32797AF6BB251E9B2D8FE754C\ +47482B72E0B394EAB76916126FD68EA7D65EB93D59F5B4C5AC40F7C3B37E7F36\ +94F29424C24AF8C8F0EF59CD9DBF1D28E0E10F799A6F78CAD1D45B9DB3D7DEE4\ +A7059ABE99182714983B9C9D44D7F5643596D4F3:\ +FC1110441C703610FCF45C284C7232FC39E97D1EE83D44B4DC6D3EB0C3634184\ +804710E64CBEF1F6BEF193A6B903565C48AAEADB2B9EE9A66F370FF7D8A0621B + +3434EC31B10FAFDBFEEC0DD6BD94E80F7BA9DCA19EF075F7EB017512AF66D6A4\ +BCF7D16BA0819A1892A6372F9B35BCC7CA8155EE19E8428BC22D214856ED5FA9\ +374C3C09BDE169602CC219679F65A1566FC7316F4CC3B631A18FB4449FA6AFA1\ +6A3DB2BC4212EFF539C67CF184680826535589C7111D73BFFCE431B4C40492E7\ +63D9279560AAA38EB2DC14A212D723F994A1FE656FF4DD14551CE4E7C621B2AA\ +5604A10001B2878A897A28A08095C325E10A26D2FB1A75BFD64C250309BB55A4\ +4F23BBAC0D5516A1C687D3B41EF2FBBF9CC56D4739:\ +7AE06EEE293E04B371C06AAFF35F04549D87D36E8CF2B568EE3905B9EC11BCD6\ +EC62E2483BBCE0079AA9432FCAE99D67947ACCD4FFAA0DB1025392F1104E049A + +7C7953D81C8D208FD1C97681D48F49DD003456DE60475B84070EF4847C333B74\ +575B1FC8D2A186964485A3B8634FEAA3595AAA1A2F4595A7D6B6153563DEE31B\ +BAC443C8A33EED6D5D956A980A68366C2527B550EE950250DFB691EACBD5D56A\ +E14B970668BE174C89DF2FEA43AE52F13142639C884FD62A3683C0C3792F0F24\ +AB1318BCB27E21F4737FAB62C77EA38BC8FD1CF41F7DAB64C13FEBE7152BF5BB\ +7AB5A78F5346D43CC741CB6F72B7B8980F268B68BF62ABDFB1577A52438FE14B\ +591498CC95F071228460C7C5D5CEB4A7BDE588E7F21C:\ +91365C03B561AC61FDAE98ED1376AB5587AC1FF722155A873790B5165EF955BD\ +460434A838B15288B0B5EFC3D0CD0D8EDA5D6E09F87D731C873D22F35EAA392A + +7A6A4F4FDC59A1D223381AE5AF498D74B7252ECF59E389E49130C7EAEE626E7B\ +D9897EFFD92017F4CCDE66B0440462CDEDFD352D8153E6A4C8D7A0812F701CC7\ +37B5178C2556F07111200EB627DBC299CAA792DFA58F35935299FA3A3519E9B0\ +3166DFFA159103FFA35E8577F7C0A86C6B46FE13DB8E2CDD9DCFBA85BDDDCCE0\ +A7A8E155F81F712D8E9FE646153D3D22C811BD39F830433B2213DD46301941B5\ +9293FD0A33E2B63ADBD95239BC01315C46FDB678875B3C81E053A40F581CFBEC\ +24A1404B1671A1B88A6D06120229518FB13A74CA0AC5AE:\ +0B5816F638F9A1BB84B3CC174AC45D6A04015095906E399075099149429194A8\ +6E0E8BC6A8D699249EAB9D8A89A87C553D474F003C1222C721E295D1C1ACA5F0 + +D9FAA14CEBE9B7DE551B6C0765409A33938562013B5E8E0E1E0A6418DF7399D0\ +A6A771FB81C3CA9BD3BB8E2951B0BC792525A294EBD1083688806FE5E7F1E17F\ +D4E3A41D00C89E8FCF4A363CAEDB1ACB558E3D562F1302B3D83BB886ED27B760\ +33798131DAB05B4217381EAAA7BA15EC820BB5C13B516DD640EAEC5A27D05FDF\ +CA0F35B3A5312146806B4C0275BCD0AAA3B2017F346975DB566F9B4D137F4EE1\ +0644C2A2DA66DEECA5342E236495C3C6280528BFD32E90AF4CD9BB908F34012B\ +52B4BC56D48CC8A6B59BAB014988EABD12E1A0A1C2E170E7:\ +0A6F1F2ECA200D2191A4FA74AF69CD369A55574D96ECFB2EEAF6B51714925D5E\ +789B6926601776BF2F5F38D7189BF02ADB8E7F1BFD55B7D0E6188E9B6A81C01A + +2D8427433D0C61F2D96CFE80CF1E932265A191365C3B61AAA3D6DCC039F6BA2A\ +D52A6A8CC30FC10F705E6B7705105977FA496C1C708A277A124304F1FC40911E\ +7441D1B5E77B951AAD7B01FD5DB1B377D165B05BBF898042E39660CAF8B279FE\ +5229D1A8DB86C0999ED65E53D01CCBC4B43173CCF992B3A14586F6BA42F5FE30\ +AFA8AE40C5DF29966F9346DA5F8B35F16A1DE3AB6DE0F477D8D8660918060E88\ +B9B9E9CA6A4207033B87A812DBF5544D39E4882010F82B6CE005F8E8FF6FE3C3\ +806BC2B73C2B83AFB704345629304F9F86358712E9FAE3CA3E:\ +22E578997BB6985E3FFE451B513CBD38CA7A585F8EE89AFCBFE18F280C1A58FC\ +F748F148764DCBB732B8091606006A6D981EEF3311B0621ADF9F098F3DF72793 + +5E19D97887FCAAC0387E22C6F803C34A3DACD2604172433F7A8A7A526CA4A2A1\ +271ECFC5D5D7BE5AC0D85D921095350DFC65997D443C21C8094E0A3FEFD2961B\ +CB94AED03291AE310CCDA75D8ACE4BC7D89E7D3E5D1650BDA5D668B8B50BFC8E\ +608E184F4D3A9A2BADC4FF5F07E0C0BC8A9F2E0B2A26FD6D8C550008FAAAB75F\ +D71AF2A424BEC9A7CD9D83FAD4C8E9319115656A8717D3B523A68FF8004258B9\ +990ED362308461804BA3E3A7E92D8F2FFAE5C2FBA55BA5A3C27C0A2F71BD711D\ +2FE1799C2ADB31B200035481E9EE5C4ADF2AB9C0FA50B23975CF:\ +36F7E04B2CAD56BDDCAE84B77637F323CFF486B68359F271B6D91EA56D06CEC4\ +CED9BDF928A8ECC713F41D058250FACC1318F67743B8B40F354EBAAE351FDA86 + +C8E976AB4638909387CE3B8D4E510C3230E5690E02C45093B1D297910ABC481E\ +56EEA0F296F98379DFC9080AF69E73B2399D1C143BEE80AE1328162CE1BA7F6A\ +8374679B20AACD380EB4E61382C99998704D62701AFA914F9A2705CDB065885F\ +50D086C3EB5753700C387118BB142F3E6DA1E988DFB31AC75D7368931E45D139\ +1A274B22F83CEB072F9BCABC0B216685BFD789F5023971024B1878A205442522\ +F9EA7D8797A4102A3DF41703768251FD5E017C85D1200A464118AA35654E7CA3\ +9F3C375B8EF8CBE7534DBC64BC20BEFB417CF60EC92F63D9EE7397:\ +A4270E9F05E43A3F770AACA85020914A8B118B59297312B271B1AA4252BDE3BA\ +878EF3B3D0D33645A2847C6423279C478E7B1A7CE757F74E0128AD0D1C1966A4 + +7145FA124B7429A1FC2231237A949BA7201BCC1822D3272DE005B682398196C2\ +5F7E5CC2F289FBF44415F699CB7FE6757791B1443410234AE061EDF623359E2B\ +4E32C19BF88450432DD01CAA5EB16A1DC378F391CA5E3C4E5F356728BDDD4975\ +DB7C890DA8BBC84CC73FF244394D0D48954978765E4A00B593F70F2CA082673A\ +261ED88DBCEF1127728D8CD89BC2C597E9102CED6010F65FA75A14EBE467FA57\ +CE3BD4948B6867D74A9DF5C0EC6F530CBF2EE61CE6F06BC8F2864DFF5583776B\ +31DF8C7FFCB61428A56BF7BD37188B4A5123BBF338393AF46EDA85E6:\ +AD1A59ABE9786DBA20ECEA2CB6FB44A9EA5D8D89A220700508BB18CFCAD6ACCB\ +ACAC75A9E0882391F0FD2B5AD4274CCFB6277E7963A04D4E44A43161D7CCC30C + +7FDFADCC9D29BAD23AE038C6C65CDA1AEF757221B8872ED3D75FF8DF7DA0627D\ +266E224E812C39F7983E4558BFD0A1F2BEF3FEB56BA09120EF762917B9C09386\ +7948547AEE98600D10D87B20106878A8D22C64378BF634F7F75900C03986B077\ +B0BF8B740A82447B61B99FEE5376C5EB6680EC9E3088F0BDD0C56883413D60C1\ +357D3C811950E5890E7600103C916341B80C743C6A852B7B4FB60C3BA21F3BC1\ +5B8382437A68454779CF3CD7F9F90CCC8EF28D0B706535B1E4108EB5627BB45D\ +719CB046839AEE311CA1ABDC8319E050D67972CB35A6B1601B25DBF487:\ +696558AE97B276A78C5A32D9FC84BC068E369BB2471C2FD5DD30C3FE1D079557\ +090D0C10F83454A722A23681AC215B688C46C5EC2AB4BEC48A4A59F2686C29AE + +988638219FD3095421F826F56E4F09E356296B628C3CE6930C9F2E758FD1A80C\ +8273F2F61E4DAAE65C4F110D3E7CA0965AC7D24E34C0DC4BA2D6FF0BF5BBE93B\ +3585F354D7543CB542A1AA54674D375077F2D360A8F4D42F3DB131C3B7AB7306\ +267BA107659864A90C8C909460A73621D1F5D9D3FD95BEB19B23DB1CB6C0D0FB\ +A91D36891529B8BD8263CAA1BAB56A4AFFAED44962DF096D8D5B1EB845EF3118\ +8B3E10F1AF811A13F156BEB7A288AAE593EBD1471B624AA1A7C6ADF01E2200B3\ +D72D88A3AED3100C88231E41EFC376906F0B580DC895F080FDA5741DB1CB:\ +A199EF2227154794D6409C0439774B7127AC77E03E798AA4CADB21E95F19AAB4\ +429866C37711BE7527E42A966B344AA8F60415077E435FC3F87D7A4A4B309182 + +5AAB62756D307A669D146ABA988D9074C5A159B3DE85151A819B117CA1FF6597\ +F6156E80FDD28C9C3176835164D37DA7DA11D94E09ADD770B68A6E081CD22CA0\ +C004BFE7CD283BF43A588DA91F509B27A6584C474A4A2F3EE0F1F56447379240\ +A5AB1FB77FDCA49B305F07BA86B62756FB9EFB4FC225C86845F026EA542076B9\ +1A0BC2CDD136E122C659BE259D98E5841DF4C2F60330D4D8CDEE7BF1A0A24452\ +4EECC68FF2AEF5BF0069C9E87A11C6E519DE1A4062A10C83837388F7EF58598A\ +3846F49D499682B683C4A062B421594FAFBC1383C943BA83BDEF515EFCF10D:\ +FC2E7DE13ED475ED2A53102B46329134210FAD3938BDC20A5E6A8CDC325C6204\ +963D46AC350DBB626AD0FFBAB1A8B29C282DD5A6C3B1ADC38D9D8E1CC7100F0A + +47B8216AA0FBB5D67966F2E82C17C07AA2D6327E96FCD83E3DE7333689F3EE79\ +994A1BF45082C4D725ED8D41205CB5BCDF5C341F77FACB1DA46A5B9B2CBC49EA\ +DF786BCD881F371A95FA17DF73F606519AEA0FF79D5A11427B98EE7F13A5C006\ +37E2854134691059839121FEA9ABE2CD1BCBBBF27C74CAF3678E05BFB1C94989\ +7EA01F56FFA4DAFBE8644611685C617A3206C7A7036E4AC816799F693DAFE7F1\ +9F303CE4EBA09D21E03610201BFC665B72400A547A1E00FA9B7AD8D84F84B34A\ +EF118515E74DEF11B9188BD1E1F97D9A12C30132EC2806339BDADACDA2FD8B78:\ +6A7398EF52E606BFAEEADACC5031002265E9E5F279440E798A25461DF3335986\ +DBFACF54A484FFC20736796251B9474C8AA7CF6F70301900DABF1A572A1BCE7F + +8CFF1F67FE53C098896D9136389BD8881816CCAB34862BB67A656E3D98896F3C\ +E6FFD4DA73975809FCDF9666760D6E561C55238B205D8049C1CEDEEF374D1735\ +DAA533147BFA960B2CCE4A4F254176BB4D1BD1E89654432B8DBE1A135C42115B\ +394B024856A2A83DC85D6782BE4B444239567CCEC4B184D4548EAE3FF6A192F3\ +43292BA2E32A0F267F31CC26719EB85245D415FB897AC2DA433EE91A99424C9D\ +7F1766A44171D1651001C38FC79294ACCC68CEB5665D36218454D3BA169AE058\ +A831338C17743603F81EE173BFC0927464F9BD728DEE94C6AEAB7AAE6EE3A627\ +E8:\ +E7CD2794FACC6407A59E1F9630FE5728ED102CADD594D1504021D39A658634F2\ +5A5711F57CFDF5D69BC96A9AF8BD83EDFE2B4AD4297917B67582D211279CD9E6 + +EACD07971CFF9B9939903F8C1D8CBB5D4DB1B548A85D04E037514A583604E787\ +F32992BF2111B97AC5E8A938233552731321522AB5E8583561260B7D13EBEEF7\ +85B23A41FD8576A6DA764A8ED6D822D4957A545D5244756C18AA80E1AAD4D1F9\ +C20D259DEE1711E2CC8FD013169FB7CC4CE38B362F8E0936AE9198B7E838DCEA\ +4F7A5B9429BB3F6BBCF2DC92565E3676C1C5E6EB3DD2A0F86AA23EDD3D0891F1\ +97447692794B3DFA269611AD97F72B795602B4FDB198F3FD3EB41B415064256E\ +345E8D8C51C555DC8A21904A9B0F1AD0EFFAB7786AAC2DA3B196507E9F33CA35\ +6427:\ +CCDF5E0EEEA0CE7A7B56DF1AD74E9845384C747375C08DCF472698202A6BE369\ +6AD4A47A259FE195D863865BDD1DAB962721592CAD55A2F8AB42DF865D348709 + +23AC4E9A42C6EF45C3336CE6DFC2FF7DE8884CD23DC912FEF0F7756C09D335C1\ +89F3AD3A23697ABDA851A81881A0C8CCAFC980AB2C702564C2BE15FE4C4B9F10\ +DFB2248D0D0CB2E2887FD4598A1D4ACDA897944A2FFC580FF92719C95CF2AA42\ +DC584674CB5A9BC5765B9D6DDF5789791D15F8DD925AA12BFFAFBCE60827B490\ +BB7DF3DDA6F2A143C8BF96ABC903D83D59A791E2D62814A89B8080A28060568C\ +F24A80AE61179FE84E0FFAD00388178CB6A617D37EFD54CC01970A4A41D1A8D3\ +DDCE46EDBBA4AB7C90AD565398D376F431189CE8C1C33E132FEAE6A8CD17A61C\ +630012:\ +FA5AF2DDE57145CE00156176309499D6B4A801C806177B5A4CC972EF9D021376\ +76ABF467B2F74103DB1D97F555FD87DBE782C7A7E4EF7BC4D9A0BBBFAEC10CF0 + +0172DF732282C9D488669C358E3492260CBE91C95CFBC1E3FEA6C4B0EC129B45\ +F242ACE09F152FC6234E1BEE8AAB8CD56E8B486E1DCBA9C05407C2F95DA8D8F1\ +C0AF78EE2ED82A3A79EC0CB0709396EE62AADB84F8A4EE8A7CCCA3C1EE84E302\ +A09EA802204AFECF04097E67D0F8E8A9D2651126C0A598A37081E42D168B0AE8\ +A71951C524259E4E2054E535B779679BDADE566FE55700858618E626B4A0FAF8\ +95BCCE9011504A49E05FD56127EAE3D1F8917AFB548ECADABDA1020111FEC931\ +4C413498A360B08640549A22CB23C731ACE743252A8227A0D2689D4C60016066\ +78DFB921:\ +F09FA792B17868C35A49A69C75F1D6DF5A8A5273DBFDBCB904821401F3B71EC8\ +BCC96D28E9DC5B3B488B863C40235B1B9503845EF7614CB7A10B8839D907EC61 + +3875B9240CF3E0A8B59C658540F26A701CF188496E2C2174788B126FD29402D6\ +A75453BA0635284D08835F40051A2A9683DC92AFB9383719191231170379BA6F\ +4ADC816FECBB0F9C446B785BF520796841E58878B73C58D3EBB097CE4761FDEA\ +BE15DE2F319DFBAF1742CDEB389559C788131A6793E193856661376C81CE9568\ +DA19AA6925B47FFD77A43C7A0E758C37D69254909FF0FBD415EF8EB937BCD49F\ +91468B49974C07DC819ABD67395DB0E05874FF83DDDAB895344ABD0E7111B2DF\ +9E58D76D85AD98106B36295826BE04D435615595605E4B4BB824B33C4AFEB5E7\ +BB0D19F909:\ +32ABC489EBA1BCA1EDCB275224F9BEC0D1CF04ED2C33F518DB23EFCF0C64861F\ +B4FA2F28BDA1098588E2971B8CC39C9817B98A6D88E5748DB4B12DE8FDE6916D + +747CC1A59FEFBA94A9C75BA866C30DC5C1CB0C0F8E9361D98484956DD5D1A40F\ +6184AFBE3DAC9F76028D1CAECCFBF69199C6CE2B4C092A3F4D2A56FE5A33A007\ +57F4D7DEE5DFB0524311A97AE0668A47971B95766E2F6DD48C3F57841F91F04A\ +00AD5EA70F2D479A2620DC5CD78EAAB3A3B011719B7E78D19DDF70D9423798AF\ +77517EBC55392FCD01FC600D8D466B9E7A7A85BF33F9CC5419E9BD874DDFD609\ +81150DDAF8D7FEBAA4374F0872A5628D318000311E2F5655365AD4D407C20E5C\ +04DF17A222E7DEEC79C5AB1116D8572F91CD06E1CCC7CED53736FC867FD49ECE\ +BE6BF8082E8A:\ +21953763A36299B39B33610211A69F0F0AF1C74E3B11F392CA95E7B8E46987C0\ +BA31A11401EC3B781106024B4C07CCE4E738B06818B9D528FA1CEDA90D5A7E3A + +57AF971FCCAEC97435DC2EC9EF0429BCEDC6B647729EA168858A6E49AC1071E7\ +06F4A5A645CA14E8C7746D65511620682C906C8B86EC901F3DDED4167B3F00B0\ +6CBFAC6AEE3728051B3E5FF10B4F9ED8BD0B8DA94303C833755B3CA3AEDDF0B5\ +4BC8D6632138B5D25BAB03D17B3458A9D782108006F5BB7DE75B5C0BA854B423\ +D8BB801E701E99DC4FEAAD59BC1C7112453B04D33EA3635639FB802C73C2B71D\ +58A56BBD671B18FE34ED2E3DCA38827D63FDB1D4FB3285405004B2B3E26081A8\ +FF08CD6D2B08F8E7B7E90A2AB1ED7A41B1D0128522C2F8BFF56A7FE67969422C\ +E839A9D4608F03:\ +7E1821FB111387BFBED27202BDB87C9B6C97F4496BD3F36AD387644DA3902258\ +377BBAACF79EC3510C1381BFAE6F07BB71615DB43F5B3D67BDBE37D04235AE4C + +04E16DEDC1227902BAAF332D3D08923601BDD64F573FAA1BB7201918CFE16B1E\ +10151DAE875DA0C0D63C59C3DD050C4C6A874011B018421AFC4623AB0381831B\ +2DA2A8BA42C96E4F70864AC44E106F94311051E74C77C1291BF5DB9539E69567\ +BF6A11CF6932BBBAD33F8946BF5814C066D851633D1A513510039B349939BFD4\ +2B858C21827C8FF05F1D09B1B0765DC78A135B5CA4DFBA0801BCADDFA175623C\ +8B647EACFB4444B85A44F73890607D06D507A4F8393658788669F6EF4DEB58D0\ +8C50CA0756D5E2F49D1A7AD73E0F0B3D3B5F090ACF622B1878C59133E4A848E0\ +5153592EA81C6FBF:\ +47E3E3BEA0783D1938BE236D64A56E414E808A04FA8544908E958C00297B37C8\ +3F06766E4399F808DCAA746C3C0B26923810DF0FC01FFC5CBC514AD200EC9A4A + +7C815C384EEE0F288ECE27CCED52A01603127B079C007378BC5D1E6C5E9E6D1C\ +735723ACBBD5801AC49854B2B569D4472D33F40BBB8882956245C366DC3582D7\ +1696A97A4E19557E41E54DEE482A14229005F93AFD2C4A7D8614D10A97A9DFA0\ +7F7CD946FA45263063DDD29DB8F9E34DB60DAA32684F0072EA2A9426ECEBFA52\ +39FB67F29C18CBAA2AF6ED4BF4283936823AC1790164FEC5457A9CBA7C767CA5\ +9392D94CAB7448F50EB34E9A93A80027471CE59736F099C886DEA1AB4CBA4D89\ +F5FC7AE2F21CCD27F611ECA4626B2D08DC22382E92C1EFB2F6AFDC8FDC3D2172\ +604F5035C46B8197D3:\ +71888C037DB742E312F41B0C35A7DBF9251E2570434A572919618C5CBE5AE6A5\ +719991A7FE08AB8368B0E5FA1A4C2A69DBE5E102F2131BBE9256A30F83B13C93 + +E29D505158DBDD937D9E3D2145658EE6F5992A2FC790F4F608D9CDB44A091D5B\ +94B88E81FAC4FDF5C49442F13B911C55886469629551189EAFF62488F1A479B7\ +DB11A1560E198DDCCCCF50159093425FF7F1CB8D1D1246D0978764087D6BAC25\ +7026B090EFAE8CEC5F22B6F21C59ACE1AC7386F5B8837CA6A12B6FBF5534DD05\ +60EF05CA78104D3B943DDB220FEAEC89AA5E692A00F822A2AB9A2FE60350D75E\ +7BE16FF2526DC643872502D01F42F188ABED0A6E9A6F5FD0D1CE7D5755C9FFA6\ +6B0AF0B20BD806F08E06156690D81AC811778CA3DAC2C249B96002017FCE93E5\ +07E3B953ACF99964B847:\ +3A34914F60EF0640FD020D33511DD4702BB9D446DEEAC314DD69A29426A98707\ +A3EF3B568BD9BB4482B3C06E660BF247DCF4338469D46445FDE2E655DC8D5179 + +D85588696F576E65ECA0155F395F0CFACD83F36A99111ED5768DF2D116D2121E\ +32357BA4F54EDE927F189F297D3A97FAD4E9A0F5B41D8D89DD7FE20156799C2B\ +7B6BF9C957BA0D6763F5C3BC5129747BBB53652B49290CFF1C87E2CDF2C4B95D\ +8AAEE09BC8FBFA6883E62D237885810491BFC101F1D8C636E3D0EDE838AD05C2\ +07A3DF4FAD76452979EB99F29AFAECEDD1C63B8D36CF378454A1BB67A741C77A\ +C6B6B3F95F4F02B64DABC15438613EA49750DF42EE90101F115AA9ABB9FF6432\ +4DDE9DABBB01054E1BD6B4BCDC7930A44C2300D87CA78C06924D0323AD7887E4\ +6C90E8C4D100ACD9EED21E:\ +5544DC0EE3FF599ECB2886C96A7EBFE47673D03FA690666855F159F45861C57F\ +666EB0E5B57D1D211802861BDA5C283BF83CE9A8399748D576E2E0BF7DA083B9 + +3A12F8508B40C32C74492B66323375DCFE49184C78F73179F3314B79E63376B8\ +AC683F5A51F1534BD729B02B04D002F55CBD8E8FC9B5EC1EA6BBE6A0D0E74315\ +18E6BA45D124035F9D3DCE0A8BB7BF1430A9F657E0B4EA9F20EB20C786A58181\ +A1E20A96F1628F8728A13BDF7A4B4B32FC8AA7054CC4881AE7FA19AFA65C6C3E\ +E1B3ADE3192AF42054A8A911B8EC1826865D46D93F1E7C5E2B7813C92A506E53\ +886F3D4701BB93D2A681AD109C845904BB861AF8AF0646B6E399B38B614051D3\ +4F6842563A0F37EC00CB3D865FC5D746C4987DE2A65071100883A2A9C7A2BFE1\ +E2DD603D9EA24DC7C5FD06BE:\ +4875DBCB1EE61EDEBDA1F13D1AEEDF38995BB1C6BBA1440233B27367E251E75C\ +F5087EEC74F1FBA132D18FD4B6D6E72DE3E98943477783051ADDEEDDA3047C26 + +1861EDCE46FA5AD17E1FF1DEAE084DEC580F97D0A67885DFE834B9DFAC1AE076\ +742CE9E267512CA51F6DF5A455AF0C5FD6ABF94ACEA103A3370C354485A7846F\ +B84F3AC7C2904B5B2FBF227002CE512133BB7E1C4E50057BFD1E44DB33C7CDB9\ +69A99E284B184F50A14B068A1FC5009D9B298DBE92239572A7627AAC02ABE8F3\ +E3B473417F36D4D2505D16B7577F4526C9D94A270A2DFE450D06DA8F6FA95687\ +9A0A55CFE99E742EA555EA477BA3E9B44CCD508C375423611AF92E55345DC215\ +779B2D5119EBA49C71D49B9FE3F1569FA24E5CA3E332D042422A8B8158D3EC66\ +A80012976F31FFDF305F0C9C5E:\ +2D6A9F1D1BCF3FF53266A1E68CF2BBEB5EBA9B84534C36E8462471EE1CC14D5E\ +57123D6DD1FBE51EF6A2D111D97A332128044B122083498E132295F52DBCFCFD + +08D0FFDE3A6E4EF65608EA672E4830C12943D7187CCFF08F4941CFC13E545F3B\ +9C7AD5EEBBE2B01642B486CAF855C2C73F58C1E4E3391DA8E2D63D96E15FD849\ +53AE5C231911B00AD6050CD7AAFDAAC9B0F663AE6AAB45519D0F5391A541707D\ +479034E73A6AD805AE3598096AF078F1393301493D663DD71F83869CA27BA508\ +B7E91E81E128C1716DC3ACFE3084B2201E04CF8006617EECF1B640474A5D45CF\ +DE9F4D3EF92D6D055B909892194D8A8218DB6D8203A84261D200D71473D7488F\ +3427416B6896C137D455F231071CACBC86E0415AB88AEC841D96B7B8AF41E05B\ +B461A40645BF176601F1E760DE5F:\ +C709FCF02BF7DB2A73C6E8FAF1443FAB5E963C12C0BD5EC498FAD3BC5D769D42\ +8832AD6AB85B3299645993B7170685A3E2A25E8A3F8B822CDD31681A8BF1E180 + +D782ABB72A5BE3392757BE02D3E45BE6E2099D6F000D042C8A543F50ED6EBC05\ +5A7F133B0DD8E9BC348536EDCAAE2E12EC18E8837DF7A1B3C87EC46D50C241DE\ +E820FD586197552DC20BEEA50F445A07A38F1768A39E2B2FF05DDDEDF751F1DE\ +F612D2E4D810DAA3A0CC904516F9A43AF660315385178A529E51F8AAE141808C\ +8BC5D7B60CAC26BB984AC1890D0436EF780426C547E94A7B08F01ACBFC4A3825\ +EAE04F520A9016F2FB8BF5165ED12736FC71E36A49A73614739EAA3EC834069B\ +1B40F1350C2B3AB885C02C640B9F7686ED5F99527E41CFCD796FE4C256C91731\ +86C226169FF257954EBDA81C0E5F99:\ +EFAF0DD633F502AF10B5A14ABDC91D140892BBD5F3A6D7401099B2196FADF61E\ +9C6AA7123EC75AF0354FA1F55A3C1C68D9324368B2FB54CC6E370459B642B68D + +5FCE8109A358570E40983E1184E541833BB9091E280F258CFB144387B05D190E\ +431CB19BAA67273BA0C58ABE91308E1844DCD0B3678BAA42F335F2FA05267A02\ +40B3C718A5942B3B3E3BFA98A55C25A1466E8D7A603722CB2BBF03AFA54CD769\ +A99F310735EE5A05DAE2C22D397BD95635F58C48A67F90E1B73AAFCD3F82117F\ +0166657838691005B18DA6F341D6E90FC1CDB352B30FAE45D348294E501B6325\ +2DE14740F2B85AE5299DDEC3172DE8B6D0BA219A20A23BB5E10FF434D39DB3F5\ +83305E9F5C039D98569E377B75A70AB837D1DF269B8A4B566F40BB91B577455F\ +D3C356C914FA06B9A7CE24C7317A172D:\ +A9D32B2C3876DD44D5DA3FBBD12200B61D817834EA5E16E3487AAD3EFDF757D4\ +B11567232879F52FC6FC9A26F03595A2377A52D18872A71F6160111C5B1597F5 + +6172F1971A6E1E4E6170AFBAD95D5FEC99BF69B24B674BC17DD78011615E502D\ +E6F56B86B1A71D3F4348087218AC7B7D09302993BE272E4A591968AEF18A1262\ +D665610D1070EE91CC8DA36E1F841A69A7A682C580E836941D21D909A3AFC1F0\ +B963E1CA5AB193E124A1A53DF1C587470E5881FB54DAE1B0D840F0C8F9D1B04C\ +645BA1041C7D8DBF22030A623AA15638B3D99A2C400FF76F3252079AF88D2B37\ +F35EE66C1AD7801A28D3D388AC450B97D5F0F79E4541755356B3B1A5696B023F\ +39AB7AB5F28DF4202936BC97393B93BC915CB159EA1BD7A0A414CB4B7A1AC3AF\ +68F50D79F0C9C7314E750F7D02FAA58BFA:\ +18E8604561DA7971FA12B82807468750AC3177155BFD8EE32476CCA602BEDDDE\ +6FDE2DCEB474E5B69E7AE6CC4EA9CCF69A221D28AFE9002AF1B8DD03BB5166A3 + +5668ECD99DFBE215C4118398AC9C9EAF1A1433FAB4CCDD3968064752B625EA94\ +4731F75D48A27D047D67547F14DD0FFAA55FA5E29F7AF0D161D85EAFC4F2029B\ +717C918EAB9D304543290BDBA7158B68020C0BA4E079BC95B5BC0FC044A992B9\ +4B4CCD3BD66D0EABB5DBBAB904D62E00752C4E3B0091D773BCF4C14B4377DA3E\ +FFF824B1CB2FA01B32D1E46C909E626ED2DAE920F4C7DBEB635BC754FACBD8D4\ +9BEBA3F23C1C41CCBFCD0EE0C114E69737F5597C0BF1D859F0C767E18002AE8E\ +39C26261FFDE2920D3D0BAF0E906138696CFE5B7E32B600F45DF3AAA39932F3A\ +7DF95B60FA8712A2271FCAF3911CE7B511B1:\ +28282DCB2629E8F9EFEE080ABE51CEB7AFBE3A6E49FD3A2CAADEBAC24E12549B\ +7F0C20A71A03B52A96016CFAF31DD2C0237AA255BEAA867A1B53D31F7D8CAB15 + +03D625488354DF30E3F875A68EDFCF340E8366A8E1AB67F9D5C5486A96829DFA\ +C0578289082B2A62117E1CF418B43B90E0ADC881FC6AE8105C888E9ECD21AEA1\ +C9AE1A4038DFD17378FED71D02AE492087D7CDCD98F746855227967CB1AB4714\ +261EE3BEAD3F4DB118329D3EBEF4BC48A875C19BA763966DA0EBEA800E01B2F5\ +0B00E9DD4CACA6DCB314D00184EF71EA2391D760C950710DB4A70F9212FFC548\ +61F9DC752CE18867B8AD0C48DF8466EF7231E7AC567F0EB55099E622EBB86CB2\ +37520190A61C66AD34F1F4E289CB3282AE3EAAC6152ED24D2C92BAE5A7658252\ +A53C49B7B02DFE54FDB2E90074B6CF310AC661:\ +13D40918BED7651EB67B8AB70CC1C45A4B55070E898B1F3A462BD28CE20DBB24\ +FBEB0EBFDE934734ED1D7002094DD9D798CB9670E5423047DEDEA64A0B02DEF5 + +2EDC282FFB90B97118DD03AAA03B145F363905E3CBD2D50ECD692B37BF000185\ +C651D3E9726C690D3773EC1E48510E42B17742B0B0377E7DE6B8F55E00A8A4DB\ +4740CEE6DB0830529DD19617501DC1E9359AA3BCF147E0A76B3AB70C4984C13E\ +339E6806BB35E683AF8527093670859F3D8A0FC7D493BCBA6BB12B5F65E71E70\ +5CA5D6C948D66ED3D730B26DB395B3447737C26FAD089AA0AD0E306CB28BF0AC\ +F106F89AF3745F0EC72D534968CCA543CD2CA50C94B1456743254E358C1317C0\ +7A07BF2B0ECA438A709367FAFC89A57239028FC5FECFD53B8EF958EF10EE0608\ +B7F5CB9923AD97058EC067700CC746C127A61EE3:\ +68A370AC86CCE98209A9DB13174C27FD786820054FFDD09CA18B62112248A85D\ +A929A8E56F499D467DFB503AB5523C09317DD8E5C9D50BD4BE105086DAECA1DB + +90B28A6AA1FE533915BCB8E81ED6CACDC10962B7FF82474F845EEB86977600CF\ +70B07BA8E3796141EE340E3FCE842A38A50AFBE90301A3BDCC591F2E7D9DE53E\ +495525560B908C892439990A2CA2679C5539FFDF636777AD9C1CDEF809CDA9E8\ +DCDB451ABB9E9C17EFA4379ABD24B182BD981CAFC792640A183B61694301D04C\ +5B3EAAD694A6BD4CC06EF5DA8FA23B4FA2A64559C5A68397930079D250C51BCF\ +00E2B16A6C49171433B0AADFD80231276560B80458DD77089B7A1BBCC9E7E4B9\ +F881EACD6C92C4318348A13F4914EB27115A1CFC5D16D7FD94954C3532EFACA2\ +CAB025103B2D02C6FD71DA3A77F417D7932685888A:\ +CA5795E813341812738D01EDD488E424E7AD9B20AB6BDC119DD1FAA5C8FE81D8\ +08AF72F761EEA4FF6AADF4B676CEF23BD94E50DC750BDB95B1413BE258D3492F + +2969447D175490F2AA9BB055014DBEF2E6854C95F8D60950BFE8C0BE8DE254C2\ +6B2D31B9E4DE9C68C9ADF49E4EE9B1C2850967F29F5D08738483B417BB96B2A5\ +6F0C8ACA632B552059C59AAC3F61F7B45C966B75F1D9931FF4E596406378CEE9\ +1AAA726A3A84C33F37E9CDBE626B5745A0B06064A8A8D56E53AAF102D23DD9DF\ +0A3FDF7A638509A6761A33FA42FA8DDBD8E16159C93008B53765019C3F0E9F10\ +B144CE2AC57F5D7297F9C9949E4FF68B70D339F87501CE8550B772F32C6DA8AD\ +2CE2100A895D8B08FA1EEAD7C376B407709703C510B50F87E73E43F8E7348F87\ +C3832A547EF2BBE5799ABEDCF5E1F372EA809233F006:\ +AEBEA537873B9F4E686EA96CBA636DBB86C01E95C22998AA418478BE9F5C459D\ +125F0D50E1CB3046C09795E79FB2A2480F753BCF8A4A66B001FC37DB289CC7C0 + +721645633A44A2C78B19024EAECF58575AB23C27190833C26875DC0F0D50B46A\ +EA9C343D82EA7D5B3E50EC700545C615DAEAEA64726A0F05607576DCD396D812\ +B03FB6551C641087856D050B10E6A4D5577B82A98AFB89CEE8594C9DC19E79FE\ +FF0382FCFD127F1B803A4B9946F4AC9A4378E1E6E041B1389A53E3450CD32D9D\ +2941B0CBABDB50DA8EA2513145164C3AB6BCBD251C448D2D4B087AC57A59C228\ +5D564F16DA4ED5E607ED979592146FFB0EF3F3DB308FB342DF5EB5924A48256F\ +C763141A278814C82D6D6348577545870AE3A83C7230AC02A1540FE1798F7EF0\ +9E335A865A2AE0949B21E4F748FB8A51F44750E213A8FB:\ +AD29A31BB70BAA848D6837251D4892E7C9B1FDBB07B2DFB1F88158D76CA2C194\ +1924EE62EAD10C053EE0EC6CEA8BBC4F08EC4DEBB90B80AAA6AC91CE190078EC + +6B860D39725A14B498BB714574B4D37CA787404768F64C648B1751B353AC92BA\ +C2C3A28EA909FDF0423336401A02E63EC24325300D823B6864BB701F9D7C7A1F\ +8EC9D0AE3584AA6DD62EA1997CD831B4BABD9A4DA50932D4EFDA745C61E41308\ +90E156AEE6113716DAF95764222A91187DB2EFFEA49D5D0596102D619BD26A61\ +6BBFDA8335505FBB0D90B4C180D1A2335B91538E1668F9F9642790B4E55F9CAB\ +0FE2BDD2935D001EE6419ABAB5457880D0DBFF20ED8758F4C20FE759EFB33141\ +CF0E892587FE8187E5FBC57786B7E8B089612C936DFC03D27EFBBE7C8673F160\ +6BD51D5FF386F4A7AB68EDF59F385EB1291F117BFE717399:\ +918F9F10D39C9C75786958573AC487B3A66FAD5AF00C47FC359E1042EE01673B\ +C7DE432E34C84A84C8D7AAE9223B833348A8AEAB102D581A4D51EE5C9A554CEC + +6A01830AF3889A25183244DECB508BD01253D5B508AB490D3124AFBF42626B2E\ +70894E9B562B288D0A2450CFACF14A0DDAE5C04716E5A0082C33981F6037D23D\ +5E045EE1EF2283FB8B6378A914C5D9441627A722C282FF452E25A7EA608D69CE\ +E4393A0725D17963D0342684F255496D8A18C2961145315130549311FC07F031\ +2FB78E6077334F87EAA873BEE8AA95698996EB21375EB2B4EF53C14401207DEB\ +4568398E5DD9A7CF97E8C9663E23334B46912F8344C19EFCF8C2BA6F04325F1A\ +27E062B62A58D0766FC6DB4D2C6A1928604B0175D872D16B7908EBC041761187\ +CC785526C2A3873FEAC3A642BB39F5351550AF9770C328AF7B:\ +EA67ECB1057F745B90EDC6327F94320AD9B452889B079E9FC39F5440F795502C\ +3939DD7B393B54C608CF6519902F8D2B3E20629DF4CBF7BB54AEE5525F206489 + +B3C5E74B69933C2533106C563B4CA20238F2B6E675E8681E34A389894785BDAD\ +E59652D4A73D80A5C85BD454FD1E9FFDAD1C3815F5038E9EF432AAC5C3C4FE84\ +0CC370CF86580A6011778BBEDAF511A51B56D1A2EB68394AA299E26DA9ADA6A2\ +F39B9FAFF7FBA457689B9C1A577B2A1E505FDF75C7A0A64B1DF81B3A356001BF\ +0DF4E02A1FC59F651C9D585EC6224BB279C6BEBA2966E8882D68376081B98746\ +8E7AED1EF90EBD090AE825795CDCA1B4F09A979C8DFC21A48D8A53CDBB26C4DB\ +547FC06EFE2F9850EDD2685A4661CB4911F165D4B63EF25B87D0A96D3DFF6AB0\ +758999AAD214D07BD4F133A6734FDE445FE474711B69A98F7E2B:\ +86995F59B4D11D960E5A6DD3FFC513BE7659D1957159284477472B61504E1055\ +B51F07C253EE597426BF18308E5C807D8A8FDDA683FA8EE2A0556B8507B663F4 + +83AF34279CCB5430FEBEC07A81950D30F4B66F484826AFEE7456F0071A51E1BB\ +C55570B5CC7EC6F9309C17BF5BEFDD7C6BA6E968CF218A2B34BD5CF927AB846E\ +38A40BBD81759E9E33381016A755F699DF35D660007B5EADF292FEEFB735207E\ +BF70B5BD17834F7BFA0E16CB219AD4AF524AB1EA37334AA66435E5D397FC0A06\ +5C411EBBCE32C240B90476D307CE802EC82C1C49BC1BEC48C0675EC2A6C6F3ED\ +3E5B741D13437095707C565E10D8A20B8C20468FF9514FCF31B4249CD82DCEE5\ +8C0A2AF538B291A87E3390D737191A07484A5D3F3FB8C8F15CE056E5E5F8FEBE\ +5E1FB59D6740980AA06CA8A0C20F5712B4CDE5D032E92AB89F0AE1:\ +09B7DEB81713594A5938A41083F728DF3F0BF93BF0EBE61DB6982885D96B40A5\ +112E7440BBA919D259F6F8173FF0942BDFE95B65BB22BF62606FF49998AF4C0A + +A7ED84749CCC56BB1DFBA57119D279D412B8A986886D810F067AF349E8749E9E\ +A746A60B03742636C464FC1EE233ACC52C1983914692B64309EDFDF29F1AB912\ +EC3E8DA074D3F1D231511F5756F0B6EEAD3E89A6A88FE330A10FACE267BFFBFC\ +3E3090C7FD9A850561F363AD75EA881E7244F80FF55802D5EF7A1A4E7B89FCFA\ +80F16DF54D1B056EE637E6964B9E0FFD15B6196BDD7DB270C56B47251485348E\ +49813B4EB9ED122A01B3EA45AD5E1A929DF61D5C0F3E77E1FDC356B63883A60E\ +9CBB9FC3E00C2F32DBD469659883F690C6772E335F617BC33F161D6F6984252E\ +E12E62B6000AC5231E0C9BC65BE223D8DFD94C5004A101AF9FD6C0FB:\ +4B0469116292A76D4767F4FAAA420BDB66F8578D39390E65E5858ACE28715944\ +A394AA7903F2BC1B466A5F3E1EFD8EE56EFB42D71D877C4BD9666B24D677D9E9 + +A6FE30DCFCDA1A329E82AB50E32B5F50EB25C873C5D2305860A835AECEE6264A\ +A36A47429922C4B8B3AFD00DA16035830EDB897831C4E7B00F2C23FC0B15FDC3\ +0D85FB70C30C431C638E1A25B51CAF1D7E8B050B7F89BFB30F59F0F20FECFF3D\ +639ABC4255B3868FC45DD81E47EB12AB40F2AAC735DF5D1DC1AD997CEFC4D836\ +B854CEE9AC02900036F3867FE0D84AFFF37BDE3308C2206C62C4743375094108\ +877C73B87B2546FE05EA137BEDFC06A2796274099A0D554DA8F7D7223A48CBF3\ +1B7DECAA1EBC8B145763E3673168C1B1B715C1CD99ECD3DDB238B06049885ECA\ +D9347C2436DFF32C771F34A38587A44A82C5D3D137A03CAA27E66C8FF6:\ +B4FF987CD5FB38C70E24DF63FC1EE4C237E992028E92F6470C721501E5761380\ +C89E590538C3EF9060DE9D957CBC18CB4E0F2AE429E934FE433725EDD6C3F4FA + +83167FF53704C3AA19E9FB3303539759C46DD4091A52DDAE9AD86408B6933598\ +9E61414BC20AB4D01220E35241EFF5C9522B079FBA597674C8D716FE441E5661\ +10B6211531CECCF8FD06BC8E511D00785E57788ED9A1C5C73524F01830D2E114\ +8C92D0EDC97113E3B7B5CD3049627ABDB8B39DD4D6890E0EE91993F92B03354A\ +88F52251C546E64434D9C3D74544F23FB93E5A2D2F1FB15545B4E1367C97335B\ +0291944C8B730AD3D4789273FA44FB98D78A36C3C3764ABEEAC7C569C1E43A35\ +2E5B770C3504F87090DEE075A1C4C85C0C39CF421BDCC615F9EFF6CB4FE64680\ +04AECE5F30E1ECC6DB22AD9939BB2B0CCC96521DFBF4AE008B5B46BC006E:\ +36CE68F98A2A0910E1030C58EAA78631A6509BBA62A524E3B59AE3562B66CFB3\ +42DE8155AA9899205FD8005BF1535A986F84CB16BBBE309C33855C85721CA09F + +3A3A819C48EFDE2AD914FBF00E18AB6BC4F14513AB27D0C178A188B61431E7F5\ +623CB66B23346775D386B50E982C493ADBBFC54B9A3CD383382336A1A0B2150A\ +15358F336D03AE18F666C7573D55C4FD181C29E6CCFDE63EA35F0ADF5885CFC0\ +A3D84A2B2E4DD24496DB789E663170CEF74798AA1BBCD4574EA0BBA40489D764\ +B2F83AADC66B148B4A0CD95246C127D5871C4F11418690A5DDF01246A0C80A43\ +C70088B6183639DCFDA4125BD113A8F49EE23ED306FAAC576C3FB0C1E256671D\ +817FC2534A52F5B439F72E424DE376F4C565CCA82307DD9EF76DA5B7C4EB7E08\ +5172E328807C02D011FFBF33785378D79DC266F6A5BE6BB0E4A92ECEEBAEB1:\ +E47D7A2CA60627F7A1416FF0E0CC9F9E6CE06A1E01A4F6D58F516927032AC757\ +1CA29BB3299430E48AFF05FF0C025BE561002C9FBA30E63B24A3E35469F904D1 + # FORK-256 vectors generated by the implementation in Botan; there is only one # test vector, and it only covers the compression function, not the entire # hash. The implementation of FORK-256 used to generate these vectors did pass diff --git a/doc/examples/bench.cpp b/doc/examples/bench.cpp index 37ef1104d..5bb8e27bf 100644 --- a/doc/examples/bench.cpp +++ b/doc/examples/bench.cpp @@ -7,26 +7,6 @@ using namespace Botan; #include -double best_speed(const std::string& algorithm, - u32bit milliseconds, - RandomNumberGenerator& rng, - Timer& timer) - { - std::map speeds = - algorithm_benchmark(algorithm, milliseconds, - timer, rng, - global_state().algorithm_factory()); - - double best_time = 0; - - for(std::map::const_iterator i = speeds.begin(); - i != speeds.end(); ++i) - if(i->second > best_time) - best_time = i->second; - - return best_time; - } - const std::string algos[] = { "AES-128", "AES-192", @@ -62,7 +42,6 @@ const std::string algos[] = { "FORK-256", "GOST-34.11", "HAS-160", - "HAS-V", "MD2", "MD4", "MD5", @@ -89,10 +68,28 @@ int main() AutoSeeded_RNG rng; Default_Benchmark_Timer timer; + Algorithm_Factory& af = global_state().algorithm_factory(); + + std::vector providers = af.providers_of("Serpent"); + for(size_t i = 0; i != providers.size(); ++i) + std::cout << providers[i].c_str() << "\n"; + + + for(u32bit i = 0; algos[i] != ""; ++i) { std::string algo = algos[i]; - std::cout << algo << ' ' - << best_speed(algo, milliseconds, rng, timer) << "\n"; + + std::map speeds = + algorithm_benchmark(algos[i], milliseconds, timer, rng, af); + + std::cout << algo << ":"; + + for(std::map::const_iterator i = speeds.begin(); + i != speeds.end(); ++i) + { + std::cout << " " << i->second << " [" << i->first << "]"; + } + std::cout << "\n"; } } diff --git a/doc/log.txt b/doc/log.txt index 4fa9da368..df48d532c 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -1,6 +1,7 @@ * 1.9.1-pre, 2009-??-?? - Enable SSE2 optimizations under Visual C++ + - Add an implementation of Blue Midnight Wish (BMW-512) - Alter Skein-512 to match the tweaked 1.2 specification * 1.9.0, 2009-09-09 diff --git a/src/engine/def_engine/lookup_hash.cpp b/src/engine/def_engine/lookup_hash.cpp index 58136fc5a..9b2018736 100644 --- a/src/engine/def_engine/lookup_hash.cpp +++ b/src/engine/def_engine/lookup_hash.cpp @@ -22,6 +22,10 @@ #include #endif +#if defined(BOTAN_HAS_BMW_512) + #include +#endif + #if defined(BOTAN_HAS_FORK_256) #include #endif @@ -103,6 +107,11 @@ Default_Engine::find_hash(const SCAN_Name& request, return new CRC32; #endif +#if defined(BOTAN_HAS_BMW_512) + if(request.algo_name() == "BMW-512") + return new BMW_512; +#endif + #if defined(BOTAN_HAS_FORK_256) if(request.algo_name() == "FORK-256") return new FORK_256; diff --git a/src/hash/bmw/bmw_512.cpp b/src/hash/bmw/bmw_512.cpp new file mode 100644 index 000000000..42389beea --- /dev/null +++ b/src/hash/bmw/bmw_512.cpp @@ -0,0 +1,174 @@ +/* +* Blue Midnight Wish 512 +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include +#include + +#include + +namespace Botan { + +namespace { + +inline u64bit S0(u64bit X) + { + return (X >> 1) ^ (X << 3) ^ rotate_left(X, 4) ^ rotate_left(X, 37); + } + +inline u64bit S1(u64bit X) + { + return (X >> 1) ^ (X << 2) ^ rotate_left(X, 13) ^ rotate_left(X, 43); + } + +inline u64bit S2(u64bit X) + { + return (X >> 2) ^ (X << 1) ^ rotate_left(X, 19) ^ rotate_left(X, 53); + } + +inline u64bit S3(u64bit X) + { + return (X >> 2) ^ (X << 2) ^ rotate_left(X, 28) ^ rotate_left(X, 59); + } + +inline u64bit S4(u64bit X) + { + return (X >> 1) ^ X; + } +} + +void BMW_512::compress_n(const byte input[], u32bit blocks) + { + for(u32bit i = 0; i != blocks; ++i) + { + u64bit Q[32] = { 0 }; + u64bit M[16] = { 0 }; + + for(u32bit j = 0; j != 16; ++j) + H[j] ^= M[j] = load_le(input, j); + input += HASH_BLOCK_SIZE; + + Q[ 0] = H[ 5] - H[ 7] + H[10] + H[13] + H[14]; + Q[ 1] = H[ 6] - H[ 8] + H[11] + H[14] - H[15]; + Q[ 2] = H[ 0] + H[ 7] + H[ 9] - H[12] + H[15]; + Q[ 3] = H[ 0] - H[ 1] + H[ 8] - H[10] + H[13]; + Q[ 4] = H[ 1] + H[ 2] + H[ 9] - H[11] - H[14]; + Q[ 5] = H[ 3] - H[ 2] + H[10] - H[12] + H[15]; + Q[ 6] = H[ 4] - H[ 0] - H[ 3] - H[11] + H[13]; + Q[ 7] = H[ 1] - H[ 4] - H[ 5] - H[12] - H[14]; + Q[ 8] = H[ 2] - H[ 5] - H[ 6] + H[13] - H[15]; + Q[ 9] = H[ 0] - H[ 3] + H[ 6] - H[ 7] + H[14]; + Q[10] = H[ 8] - H[ 1] - H[ 4] - H[ 7] + H[15]; + Q[11] = H[ 8] - H[ 0] - H[ 2] - H[ 5] + H[ 9]; + Q[12] = H[ 1] + H[ 3] - H[ 6] - H[ 9] + H[10]; + Q[13] = H[ 2] + H[ 4] + H[ 7] + H[10] + H[11]; + Q[14] = H[ 3] - H[ 5] + H[ 8] - H[11] - H[12]; + Q[15] = H[12] - H[ 4] - H[ 6] - H[ 9] + H[13]; + + Q[ 0] = S0(Q[ 0]); + Q[ 1] = S1(Q[ 1]); + Q[ 2] = S2(Q[ 2]); + Q[ 3] = S3(Q[ 3]); + Q[ 4] = S4(Q[ 4]); + Q[ 5] = S0(Q[ 5]); + Q[ 6] = S1(Q[ 6]); + Q[ 7] = S2(Q[ 7]); + Q[ 8] = S3(Q[ 8]); + Q[ 9] = S4(Q[ 9]); + Q[10] = S0(Q[10]); + Q[11] = S1(Q[11]); + Q[12] = S2(Q[12]); + Q[13] = S3(Q[13]); + Q[14] = S4(Q[14]); + Q[15] = S0(Q[15]); + + for(u32bit j = 16; j != 18; ++j) + { + Q[j] = S1(Q[j-16]) + S2(Q[j-15]) + S3(Q[j-14]) + S0(Q[j-13]) + + S1(Q[j-12]) + S2(Q[j-11]) + S3(Q[j-10]) + S0(Q[j- 9]) + + S1(Q[j- 8]) + S2(Q[j- 7]) + S3(Q[j- 6]) + S0(Q[j- 5]) + + S1(Q[j- 4]) + S2(Q[j- 3]) + S3(Q[j- 2]) + S0(Q[j- 1]) + + M[j-16] + M[j-13] - M[j-6] + + (0x0555555555555555 * j); + } + + for(u32bit j = 18; j != 32; ++j) + { + Q[j] = Q[j-16] + rotate_left(Q[j-15], 5) + + Q[j-14] + rotate_left(Q[j-13], 11) + + Q[j-12] + rotate_left(Q[j-11], 27) + + Q[j-10] + rotate_left(Q[j- 9], 32) + + Q[j- 8] + rotate_left(Q[j- 7], 37) + + Q[j- 6] + rotate_left(Q[j- 5], 43) + + Q[j- 4] + rotate_left(Q[j- 3], 53) + + (Q[j- 2] >> 2 ^ Q[j- 2]) + S4(Q[j- 1]) + + M[j-16] + M[(j-13) % 16] - M[(j-6) % 16] + + (0x0555555555555555 * j); + } + + u64bit XL = Q[16] ^ Q[17] ^ Q[18] ^ Q[19] ^ + Q[20] ^ Q[21] ^ Q[22] ^ Q[23]; + + u64bit XH = Q[24] ^ Q[25] ^ Q[26] ^ Q[27] ^ + Q[28] ^ Q[29] ^ Q[30] ^ Q[31]; + + XH ^= XL; + + H[ 0] = ((XH << 5) ^ (Q[16] >> 5) ^ M[0]) + (XL ^ Q[24] ^ Q[0]); + H[ 1] = ((XH >> 7) ^ (Q[17] << 8) ^ M[1]) + (XL ^ Q[25] ^ Q[1]); + H[ 2] = ((XH >> 5) ^ (Q[18] << 5) ^ M[2]) + (XL ^ Q[26] ^ Q[2]); + H[ 3] = ((XH >> 1) ^ (Q[19] << 5) ^ M[3]) + (XL ^ Q[27] ^ Q[3]); + H[ 4] = ((XH >> 3) ^ (Q[20] ) ^ M[4]) + (XL ^ Q[28] ^ Q[4]); + H[ 5] = ((XH << 6) ^ (Q[21] >> 6) ^ M[5]) + (XL ^ Q[29] ^ Q[5]); + H[ 6] = ((XH >> 4) ^ (Q[22] << 6) ^ M[6]) + (XL ^ Q[30] ^ Q[6]); + H[ 7] = ((XH >> 11) ^ (Q[23] << 2) ^ M[7]) + (XL ^ Q[31] ^ Q[7]); + + H[ 8] = rotate_left(H[4], 9) + (XH ^ Q[24] ^ M[ 8]) + ((XL << 8) ^ Q[23] ^ Q[ 8]); + H[ 9] = rotate_left(H[5], 10) + (XH ^ Q[25] ^ M[ 9]) + ((XL >> 6) ^ Q[16] ^ Q[ 9]); + H[10] = rotate_left(H[6], 11) + (XH ^ Q[26] ^ M[10]) + ((XL << 6) ^ Q[17] ^ Q[10]); + H[11] = rotate_left(H[7], 12) + (XH ^ Q[27] ^ M[11]) + ((XL << 4) ^ Q[18] ^ Q[11]); + H[12] = rotate_left(H[0], 13) + (XH ^ Q[28] ^ M[12]) + ((XL >> 3) ^ Q[19] ^ Q[12]); + H[13] = rotate_left(H[1], 14) + (XH ^ Q[29] ^ M[13]) + ((XL >> 4) ^ Q[20] ^ Q[13]); + H[14] = rotate_left(H[2], 15) + (XH ^ Q[30] ^ M[14]) + ((XL >> 7) ^ Q[21] ^ Q[14]); + H[15] = rotate_left(H[3], 16) + (XH ^ Q[31] ^ M[15]) + ((XL >> 2) ^ Q[22] ^ Q[15]); + } + } + +/* +* Copy out the digest +*/ +void BMW_512::copy_out(byte output[]) + { + for(u32bit i = 0; i != OUTPUT_LENGTH; i += 8) + store_le(H[8 + i/8], output + i); + } + +/* +* Clear memory of sensitive data +*/ +void BMW_512::clear() throw() + { + MDx_HashFunction::clear(); + H[ 0] = 0x8081828384858687; + H[ 1] = 0x88898A8B8C8D8E8F; + H[ 2] = 0x9091929394959697; + H[ 3] = 0x98999A9B9C9D9E9F; + H[ 4] = 0xA0A1A2A3A4A5A6A7; + H[ 5] = 0xA8A9AAABACADAEAF; + H[ 6] = 0xB0B1B2B3B4B5B6B7; + H[ 7] = 0xB8B9BABBBCBDBEBF; + H[ 8] = 0xC0C1C2C3C4C5C6C7; + H[ 9] = 0xC8C9CACBCCCDCECF; + H[10] = 0xD0D1D2D3D4D5D6D7; + H[11] = 0xD8D9DADBDCDDDEDF; + H[12] = 0xE0E1E2E3E4E5E6E7; + H[13] = 0xE8E9EAEBECEDEEEF; + H[14] = 0xF0F1F2F3F4F5F6F7; + H[15] = 0xF8F9FAFBFCFDFEFF; + } + +} diff --git a/src/hash/bmw/bmw_512.h b/src/hash/bmw/bmw_512.h new file mode 100644 index 000000000..da4b42598 --- /dev/null +++ b/src/hash/bmw/bmw_512.h @@ -0,0 +1,31 @@ +/* +* Blue Midnight Wish 512 +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BMW_512_H__ +#define BOTAN_BMW_512_H__ + +#include + +namespace Botan { + +class BMW_512 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "BMW512"; } + HashFunction* clone() const { return new BMW_512; } + BMW_512() : MDx_HashFunction(64, 128, false, true) { clear(); } + private: + void compress_n(const byte input[], u32bit blocks); + void copy_out(byte output[]); + + SecureBuffer H; + }; + +} + +#endif diff --git a/src/hash/bmw/info.txt b/src/hash/bmw/info.txt new file mode 100644 index 000000000..3e7e04b31 --- /dev/null +++ b/src/hash/bmw/info.txt @@ -0,0 +1,14 @@ +realname "Blue Midnight Wish" + +define BMW_512 + +load_on auto + + +bmw_512.cpp +bmw_512.h + + + +mdx_hash + -- cgit v1.2.3 From 34f9ef45565ed4052b3a50026827c5171a8dad2f Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 15 Sep 2009 14:30:25 +0000 Subject: In BMW-512, don't use the stack, instead use class SecureBuffers to reduce info leakage. --- src/hash/bmw/bmw_512.cpp | 137 +++++++++++++++++++++++------------------------ src/hash/bmw/bmw_512.h | 3 +- 2 files changed, 70 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/hash/bmw/bmw_512.cpp b/src/hash/bmw/bmw_512.cpp index 42389beea..4019c0ff2 100644 --- a/src/hash/bmw/bmw_512.cpp +++ b/src/hash/bmw/bmw_512.cpp @@ -45,96 +45,93 @@ void BMW_512::compress_n(const byte input[], u32bit blocks) { for(u32bit i = 0; i != blocks; ++i) { - u64bit Q[32] = { 0 }; - u64bit M[16] = { 0 }; - for(u32bit j = 0; j != 16; ++j) H[j] ^= M[j] = load_le(input, j); input += HASH_BLOCK_SIZE; - Q[ 0] = H[ 5] - H[ 7] + H[10] + H[13] + H[14]; - Q[ 1] = H[ 6] - H[ 8] + H[11] + H[14] - H[15]; - Q[ 2] = H[ 0] + H[ 7] + H[ 9] - H[12] + H[15]; - Q[ 3] = H[ 0] - H[ 1] + H[ 8] - H[10] + H[13]; - Q[ 4] = H[ 1] + H[ 2] + H[ 9] - H[11] - H[14]; - Q[ 5] = H[ 3] - H[ 2] + H[10] - H[12] + H[15]; - Q[ 6] = H[ 4] - H[ 0] - H[ 3] - H[11] + H[13]; - Q[ 7] = H[ 1] - H[ 4] - H[ 5] - H[12] - H[14]; - Q[ 8] = H[ 2] - H[ 5] - H[ 6] + H[13] - H[15]; - Q[ 9] = H[ 0] - H[ 3] + H[ 6] - H[ 7] + H[14]; - Q[10] = H[ 8] - H[ 1] - H[ 4] - H[ 7] + H[15]; - Q[11] = H[ 8] - H[ 0] - H[ 2] - H[ 5] + H[ 9]; - Q[12] = H[ 1] + H[ 3] - H[ 6] - H[ 9] + H[10]; - Q[13] = H[ 2] + H[ 4] + H[ 7] + H[10] + H[11]; - Q[14] = H[ 3] - H[ 5] + H[ 8] - H[11] - H[12]; - Q[15] = H[12] - H[ 4] - H[ 6] - H[ 9] + H[13]; - - Q[ 0] = S0(Q[ 0]); - Q[ 1] = S1(Q[ 1]); - Q[ 2] = S2(Q[ 2]); - Q[ 3] = S3(Q[ 3]); - Q[ 4] = S4(Q[ 4]); - Q[ 5] = S0(Q[ 5]); - Q[ 6] = S1(Q[ 6]); - Q[ 7] = S2(Q[ 7]); - Q[ 8] = S3(Q[ 8]); - Q[ 9] = S4(Q[ 9]); - Q[10] = S0(Q[10]); - Q[11] = S1(Q[11]); - Q[12] = S2(Q[12]); - Q[13] = S3(Q[13]); - Q[14] = S4(Q[14]); - Q[15] = S0(Q[15]); + H[16] = H[ 5] - H[ 7] + H[10] + H[13] + H[14]; + H[17] = H[ 6] - H[ 8] + H[11] + H[14] - H[15]; + H[18] = H[ 0] + H[ 7] + H[ 9] - H[12] + H[15]; + H[19] = H[ 0] - H[ 1] + H[ 8] - H[10] + H[13]; + H[20] = H[ 1] + H[ 2] + H[ 9] - H[11] - H[14]; + H[21] = H[ 3] - H[ 2] + H[10] - H[12] + H[15]; + H[22] = H[ 4] - H[ 0] - H[ 3] - H[11] + H[13]; + H[23] = H[ 1] - H[ 4] - H[ 5] - H[12] - H[14]; + H[24] = H[ 2] - H[ 5] - H[ 6] + H[13] - H[15]; + H[25] = H[ 0] - H[ 3] + H[ 6] - H[ 7] + H[14]; + H[26] = H[ 8] - H[ 1] - H[ 4] - H[ 7] + H[15]; + H[27] = H[ 8] - H[ 0] - H[ 2] - H[ 5] + H[ 9]; + H[28] = H[ 1] + H[ 3] - H[ 6] - H[ 9] + H[10]; + H[29] = H[ 2] + H[ 4] + H[ 7] + H[10] + H[11]; + H[30] = H[ 3] - H[ 5] + H[ 8] - H[11] - H[12]; + H[31] = H[12] - H[ 4] - H[ 6] - H[ 9] + H[13]; + + H[ 0] = S0(H[16]); + H[ 1] = S1(H[17]); + H[ 2] = S2(H[18]); + H[ 3] = S3(H[19]); + H[ 4] = S4(H[20]); + H[ 5] = S0(H[21]); + H[ 6] = S1(H[22]); + H[ 7] = S2(H[23]); + H[ 8] = S3(H[24]); + H[ 9] = S4(H[25]); + H[10] = S0(H[26]); + H[11] = S1(H[27]); + H[12] = S2(H[28]); + H[13] = S3(H[29]); + H[14] = S4(H[30]); + H[15] = S0(H[31]); for(u32bit j = 16; j != 18; ++j) { - Q[j] = S1(Q[j-16]) + S2(Q[j-15]) + S3(Q[j-14]) + S0(Q[j-13]) + - S1(Q[j-12]) + S2(Q[j-11]) + S3(Q[j-10]) + S0(Q[j- 9]) + - S1(Q[j- 8]) + S2(Q[j- 7]) + S3(Q[j- 6]) + S0(Q[j- 5]) + - S1(Q[j- 4]) + S2(Q[j- 3]) + S3(Q[j- 2]) + S0(Q[j- 1]) + + H[j] = S1(H[j-16]) + S2(H[j-15]) + S3(H[j-14]) + S0(H[j-13]) + + S1(H[j-12]) + S2(H[j-11]) + S3(H[j-10]) + S0(H[j- 9]) + + S1(H[j- 8]) + S2(H[j- 7]) + S3(H[j- 6]) + S0(H[j- 5]) + + S1(H[j- 4]) + S2(H[j- 3]) + S3(H[j- 2]) + S0(H[j- 1]) + M[j-16] + M[j-13] - M[j-6] + (0x0555555555555555 * j); } for(u32bit j = 18; j != 32; ++j) { - Q[j] = Q[j-16] + rotate_left(Q[j-15], 5) + - Q[j-14] + rotate_left(Q[j-13], 11) + - Q[j-12] + rotate_left(Q[j-11], 27) + - Q[j-10] + rotate_left(Q[j- 9], 32) + - Q[j- 8] + rotate_left(Q[j- 7], 37) + - Q[j- 6] + rotate_left(Q[j- 5], 43) + - Q[j- 4] + rotate_left(Q[j- 3], 53) + - (Q[j- 2] >> 2 ^ Q[j- 2]) + S4(Q[j- 1]) + + H[j] = H[j-16] + rotate_left(H[j-15], 5) + + H[j-14] + rotate_left(H[j-13], 11) + + H[j-12] + rotate_left(H[j-11], 27) + + H[j-10] + rotate_left(H[j- 9], 32) + + H[j- 8] + rotate_left(H[j- 7], 37) + + H[j- 6] + rotate_left(H[j- 5], 43) + + H[j- 4] + rotate_left(H[j- 3], 53) + + (H[j- 2] >> 2 ^ H[j- 2]) + S4(H[j- 1]) + M[j-16] + M[(j-13) % 16] - M[(j-6) % 16] + (0x0555555555555555 * j); } - u64bit XL = Q[16] ^ Q[17] ^ Q[18] ^ Q[19] ^ - Q[20] ^ Q[21] ^ Q[22] ^ Q[23]; + u64bit XL = H[16] ^ H[17] ^ H[18] ^ H[19] ^ + H[20] ^ H[21] ^ H[22] ^ H[23]; - u64bit XH = Q[24] ^ Q[25] ^ Q[26] ^ Q[27] ^ - Q[28] ^ Q[29] ^ Q[30] ^ Q[31]; + u64bit XH = H[24] ^ H[25] ^ H[26] ^ H[27] ^ + H[28] ^ H[29] ^ H[30] ^ H[31]; XH ^= XL; - H[ 0] = ((XH << 5) ^ (Q[16] >> 5) ^ M[0]) + (XL ^ Q[24] ^ Q[0]); - H[ 1] = ((XH >> 7) ^ (Q[17] << 8) ^ M[1]) + (XL ^ Q[25] ^ Q[1]); - H[ 2] = ((XH >> 5) ^ (Q[18] << 5) ^ M[2]) + (XL ^ Q[26] ^ Q[2]); - H[ 3] = ((XH >> 1) ^ (Q[19] << 5) ^ M[3]) + (XL ^ Q[27] ^ Q[3]); - H[ 4] = ((XH >> 3) ^ (Q[20] ) ^ M[4]) + (XL ^ Q[28] ^ Q[4]); - H[ 5] = ((XH << 6) ^ (Q[21] >> 6) ^ M[5]) + (XL ^ Q[29] ^ Q[5]); - H[ 6] = ((XH >> 4) ^ (Q[22] << 6) ^ M[6]) + (XL ^ Q[30] ^ Q[6]); - H[ 7] = ((XH >> 11) ^ (Q[23] << 2) ^ M[7]) + (XL ^ Q[31] ^ Q[7]); - - H[ 8] = rotate_left(H[4], 9) + (XH ^ Q[24] ^ M[ 8]) + ((XL << 8) ^ Q[23] ^ Q[ 8]); - H[ 9] = rotate_left(H[5], 10) + (XH ^ Q[25] ^ M[ 9]) + ((XL >> 6) ^ Q[16] ^ Q[ 9]); - H[10] = rotate_left(H[6], 11) + (XH ^ Q[26] ^ M[10]) + ((XL << 6) ^ Q[17] ^ Q[10]); - H[11] = rotate_left(H[7], 12) + (XH ^ Q[27] ^ M[11]) + ((XL << 4) ^ Q[18] ^ Q[11]); - H[12] = rotate_left(H[0], 13) + (XH ^ Q[28] ^ M[12]) + ((XL >> 3) ^ Q[19] ^ Q[12]); - H[13] = rotate_left(H[1], 14) + (XH ^ Q[29] ^ M[13]) + ((XL >> 4) ^ Q[20] ^ Q[13]); - H[14] = rotate_left(H[2], 15) + (XH ^ Q[30] ^ M[14]) + ((XL >> 7) ^ Q[21] ^ Q[14]); - H[15] = rotate_left(H[3], 16) + (XH ^ Q[31] ^ M[15]) + ((XL >> 2) ^ Q[22] ^ Q[15]); + H[ 0] = ((XH << 5) ^ (H[16] >> 5) ^ M[0]) + (XL ^ H[24] ^ H[0]); + H[ 1] = ((XH >> 7) ^ (H[17] << 8) ^ M[1]) + (XL ^ H[25] ^ H[1]); + H[ 2] = ((XH >> 5) ^ (H[18] << 5) ^ M[2]) + (XL ^ H[26] ^ H[2]); + H[ 3] = ((XH >> 1) ^ (H[19] << 5) ^ M[3]) + (XL ^ H[27] ^ H[3]); + H[ 4] = ((XH >> 3) ^ (H[20] ) ^ M[4]) + (XL ^ H[28] ^ H[4]); + H[ 5] = ((XH << 6) ^ (H[21] >> 6) ^ M[5]) + (XL ^ H[29] ^ H[5]); + H[ 6] = ((XH >> 4) ^ (H[22] << 6) ^ M[6]) + (XL ^ H[30] ^ H[6]); + H[ 7] = ((XH >> 11) ^ (H[23] << 2) ^ M[7]) + (XL ^ H[31] ^ H[7]); + + H[ 8] = rotate_left(H[4], 9) + (XH ^ H[24] ^ M[ 8]) + ((XL << 8) ^ H[23] ^ H[ 8]); + H[ 9] = rotate_left(H[5], 10) + (XH ^ H[25] ^ M[ 9]) + ((XL >> 6) ^ H[16] ^ H[ 9]); + H[10] = rotate_left(H[6], 11) + (XH ^ H[26] ^ M[10]) + ((XL << 6) ^ H[17] ^ H[10]); + H[11] = rotate_left(H[7], 12) + (XH ^ H[27] ^ M[11]) + ((XL << 4) ^ H[18] ^ H[11]); + H[12] = rotate_left(H[0], 13) + (XH ^ H[28] ^ M[12]) + ((XL >> 3) ^ H[19] ^ H[12]); + H[13] = rotate_left(H[1], 14) + (XH ^ H[29] ^ M[13]) + ((XL >> 4) ^ H[20] ^ H[13]); + H[14] = rotate_left(H[2], 15) + (XH ^ H[30] ^ M[14]) + ((XL >> 7) ^ H[21] ^ H[14]); + H[15] = rotate_left(H[3], 16) + (XH ^ H[31] ^ M[15]) + ((XL >> 2) ^ H[22] ^ H[15]); } } @@ -153,6 +150,8 @@ void BMW_512::copy_out(byte output[]) void BMW_512::clear() throw() { MDx_HashFunction::clear(); + M.clear(); + H[ 0] = 0x8081828384858687; H[ 1] = 0x88898A8B8C8D8E8F; H[ 2] = 0x9091929394959697; diff --git a/src/hash/bmw/bmw_512.h b/src/hash/bmw/bmw_512.h index da4b42598..4be6afd04 100644 --- a/src/hash/bmw/bmw_512.h +++ b/src/hash/bmw/bmw_512.h @@ -23,7 +23,8 @@ class BMW_512 : public MDx_HashFunction void compress_n(const byte input[], u32bit blocks); void copy_out(byte output[]); - SecureBuffer H; + SecureBuffer H; + SecureBuffer M; }; } -- cgit v1.2.3 From 268c1b8902fccc4e942f6ccd5651dab826846a92 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 17 Sep 2009 13:46:29 +0000 Subject: Update OpenSSL engine with encrypt_n interface for block ciphers. Add support for SHA-2 and SEED. Wrap block cipher usage in checks for OPENSSL_NO_XXX --- src/engine/openssl/ossl_bc.cpp | 34 +++++++++++++++++++++++++++------- src/engine/openssl/ossl_md.cpp | 24 +++++++++++++++++++----- 2 files changed, 46 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/engine/openssl/ossl_bc.cpp b/src/engine/openssl/ossl_bc.cpp index 4d3761adb..dd6bb38db 100644 --- a/src/engine/openssl/ossl_bc.cpp +++ b/src/engine/openssl/ossl_bc.cpp @@ -27,8 +27,8 @@ class EVP_BlockCipher : public BlockCipher ~EVP_BlockCipher(); private: - void enc(const byte[], byte[]) const; - void dec(const byte[], byte[]) const; + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; void key_schedule(const byte[], u32bit); std::string cipher_name; mutable EVP_CIPHER_CTX encrypt, decrypt; @@ -90,19 +90,21 @@ EVP_BlockCipher::~EVP_BlockCipher() /* * Encrypt a block */ -void EVP_BlockCipher::enc(const byte in[], byte out[]) const +void EVP_BlockCipher::encrypt_n(const byte in[], byte out[], + u32bit blocks) const { int out_len = 0; - EVP_EncryptUpdate(&encrypt, out, &out_len, in, BLOCK_SIZE); + EVP_EncryptUpdate(&encrypt, out, &out_len, in, blocks * BLOCK_SIZE); } /* * Decrypt a block */ -void EVP_BlockCipher::dec(const byte in[], byte out[]) const +void EVP_BlockCipher::decrypt_n(const byte in[], byte out[], + u32bit blocks) const { int out_len = 0; - EVP_DecryptUpdate(&decrypt, out, &out_len, in, BLOCK_SIZE); + EVP_DecryptUpdate(&decrypt, out, &out_len, in, blocks * BLOCK_SIZE); } /* @@ -174,7 +176,7 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request, if(request.algo_name() == NAME && request.arg_count() == 0) \ return new EVP_BlockCipher(EVP, NAME, MIN, MAX, MOD); -#if 0 +#if 0 && !defined(OPENSSL_NO_AES) /* Using OpenSSL's AES causes crashes inside EVP on x86-64 with OpenSSL 0.9.8g cause is unknown @@ -184,12 +186,30 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request, HANDLE_EVP_CIPHER("AES-256", EVP_aes_256_ecb()); #endif +#if !defined(OPENSSL_NO_DES) HANDLE_EVP_CIPHER("DES", EVP_des_ecb()); HANDLE_EVP_CIPHER_KEYLEN("TripleDES", EVP_des_ede3_ecb(), 16, 24, 8); +#endif +#if !defined(OPENSSL_NO_BF) HANDLE_EVP_CIPHER_KEYLEN("Blowfish", EVP_bf_ecb(), 1, 56, 1); +#endif + +#if !defined(OPENSSL_NO_CAST) HANDLE_EVP_CIPHER_KEYLEN("CAST-128", EVP_cast5_ecb(), 1, 16, 1); +#endif + +#if !defined(OPENSSL_NO_RC2) HANDLE_EVP_CIPHER_KEYLEN("RC2", EVP_rc2_ecb(), 1, 32, 1); +#endif + +#if !defined(OPENSSL_NO_IDEA) + HANDLE_EVP_CIPHER("IDEA", EVP_idea_ecb()); +#endif + +#if !defined(OPENSSL_NO_SEED) + HANDLE_EVP_CIPHER("SEED", EVP_seed_ecb()); +#endif #undef HANDLE_EVP_CIPHER #undef HANDLE_EVP_CIPHER_KEYLEN diff --git a/src/engine/openssl/ossl_md.cpp b/src/engine/openssl/ossl_md.cpp index 7c8fb678c..42975c8a3 100644 --- a/src/engine/openssl/ossl_md.cpp +++ b/src/engine/openssl/ossl_md.cpp @@ -95,27 +95,41 @@ EVP_HashFunction::~EVP_HashFunction() HashFunction* OpenSSL_Engine::find_hash(const SCAN_Name& request, Algorithm_Factory&) const { -#ifndef OPENSSL_NO_SHA +#if !defined(OPENSSL_NO_SHA) if(request.algo_name() == "SHA-160") return new EVP_HashFunction(EVP_sha1(), "SHA-160"); #endif -#ifndef OPENSSL_NO_MD2 +#if !defined(OPENSSL_NO_SHA256) + if(request.algo_name() == "SHA-224") + return new EVP_HashFunction(EVP_sha224(), "SHA-224"); + if(request.algo_name() == "SHA-256") + return new EVP_HashFunction(EVP_sha256(), "SHA-256"); +#endif + +#if !defined(OPENSSL_NO_SHA512) + if(request.algo_name() == "SHA-384") + return new EVP_HashFunction(EVP_sha384(), "SHA-384"); + if(request.algo_name() == "SHA-512") + return new EVP_HashFunction(EVP_sha512(), "SHA-512"); +#endif + +#if !defined(OPENSSL_NO_MD2) if(request.algo_name() == "MD2") return new EVP_HashFunction(EVP_md2(), "MD2"); #endif -#ifndef OPENSSL_NO_MD4 +#if !defined(OPENSSL_NO_MD4) if(request.algo_name() == "MD4") return new EVP_HashFunction(EVP_md4(), "MD4"); #endif -#ifndef OPENSSL_NO_MD5 +#if !defined(OPENSSL_NO_MD5) if(request.algo_name() == "MD5") return new EVP_HashFunction(EVP_md5(), "MD5"); #endif -#ifndef OPENSSL_NO_RIPEMD +#if !defined(OPENSSL_NO_RIPEMD) if(request.algo_name() == "RIPEMD-160") return new EVP_HashFunction(EVP_ripemd160(), "RIPEMD-160"); #endif -- cgit v1.2.3 From 7d51181d2841b29277da9a31752cae612d64b534 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 17 Sep 2009 13:48:12 +0000 Subject: Move memory locking function decls to mlock.h Inline round_up and round_down --- src/alloc/system_alloc/defalloc.cpp | 2 +- src/utils/info.txt | 1 + src/utils/mlock.cpp | 2 +- src/utils/mlock.h | 32 ++++++++++++++++++++++++++++++++ src/utils/util.cpp | 18 ------------------ src/utils/util.h | 18 ++++++++++++------ 6 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 src/utils/mlock.h (limited to 'src') diff --git a/src/alloc/system_alloc/defalloc.cpp b/src/alloc/system_alloc/defalloc.cpp index 8791c74e4..b1b338d71 100644 --- a/src/alloc/system_alloc/defalloc.cpp +++ b/src/alloc/system_alloc/defalloc.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/src/utils/info.txt b/src/utils/info.txt index ab50b88ad..bf9778369 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -17,6 +17,7 @@ exceptn.cpp exceptn.h loadstor.h mem_ops.h +mlock.h mlock.cpp parsing.cpp parsing.h diff --git a/src/utils/mlock.cpp b/src/utils/mlock.cpp index 9bb062da5..6453d8a30 100644 --- a/src/utils/mlock.cpp +++ b/src/utils/mlock.cpp @@ -5,7 +5,7 @@ * Distributed under the terms of the Botan license */ -#include +#include #if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK) #include diff --git a/src/utils/mlock.h b/src/utils/mlock.h new file mode 100644 index 000000000..0811e8190 --- /dev/null +++ b/src/utils/mlock.h @@ -0,0 +1,32 @@ +/* +* Memory Locking Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MLOCK_H__ +#define BOTAN_MLOCK_H__ + +#include + +namespace Botan { + +/** +* Lock memory into RAM if possible +* @param addr the start of the memory block +* @param length the length of the memory block in bytes +* @returns true if successful, false otherwise +*/ +BOTAN_DLL bool lock_mem(void* addr, u32bit length); + +/** +* Unlock memory locked with lock_mem() +* @param addr the start of the memory block +* @param length the length of the memory block in bytes +*/ +BOTAN_DLL void unlock_mem(void* addr, u32bit length); + +} + +#endif diff --git a/src/utils/util.cpp b/src/utils/util.cpp index 84dfd1a14..09ac9f1ca 100644 --- a/src/utils/util.cpp +++ b/src/utils/util.cpp @@ -11,24 +11,6 @@ namespace Botan { -/* -* Round up n to multiple of align_to -*/ -u32bit round_up(u32bit n, u32bit align_to) - { - if(n % align_to || n == 0) - n += align_to - (n % align_to); - return n; - } - -/* -* Round down n to multiple of align_to -*/ -u32bit round_down(u32bit n, u32bit align_to) - { - return (n - (n % align_to)); - } - /* * Choose the exponent size for a DL group */ diff --git a/src/utils/util.h b/src/utils/util.h index ac7867390..e3dadc64b 100644 --- a/src/utils/util.h +++ b/src/utils/util.h @@ -18,16 +18,22 @@ namespace Botan { BOTAN_DLL u64bit system_time(); /* -* Memory Locking Functions +* Round up n to multiple of align_to */ -BOTAN_DLL bool lock_mem(void*, u32bit); -BOTAN_DLL void unlock_mem(void*, u32bit); +inline u32bit round_up(u32bit n, u32bit align_to) + { + if(n % align_to || n == 0) + n += align_to - (n % align_to); + return n; + } /* -* Misc Utility Functions +* Round down n to multiple of align_to */ -BOTAN_DLL u32bit round_up(u32bit, u32bit); -BOTAN_DLL u32bit round_down(u32bit, u32bit); +inline u32bit round_down(u32bit n, u32bit align_to) + { + return (n - (n % align_to)); + } /* * Work Factor Estimates -- cgit v1.2.3 From e1d81327dde6c6837ed81c61c58876bd261fb47d Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 17 Sep 2009 13:59:56 +0000 Subject: Split up util.h into 3 files - rounding.h (round_up, round_down) - workfactor.h (dl_work_factor) - timer.h (system_time) And update all users of the previous util.h --- checks/cvc_tests.cpp | 2 +- src/alloc/mem_pool/mem_pool.cpp | 2 +- src/benchmark/benchmark.cpp | 1 - src/cert/cvc/cvc_ca.cpp | 1 - src/cert/cvc/cvc_self.cpp | 2 +- src/cert/x509/crl_ent.cpp | 2 +- src/cert/x509/x509_ca.cpp | 2 +- src/cert/x509/x509opt.cpp | 4 +-- src/cert/x509/x509stor.cpp | 2 +- src/math/bigint/bigint.cpp | 2 +- src/math/numbertheory/mp_numth.cpp | 2 +- src/modes/mode_pad/mode_pad.cpp | 1 - src/pubkey/dh/dh.cpp | 2 +- src/pubkey/dl_group/dl_group.cpp | 2 +- src/pubkey/ecc_key/ecc_key.cpp | 1 - src/pubkey/ecdsa/ecdsa.cpp | 1 - src/pubkey/eckaeg/eckaeg.cpp | 1 - src/pubkey/elgamal/elgamal.cpp | 2 +- src/pubkey/info.txt | 2 ++ src/pubkey/workfactor.cpp | 51 ++++++++++++++++++++++++++++++++++++++ src/pubkey/workfactor.h | 22 ++++++++++++++++ src/rng/hmac_rng/hmac_rng.cpp | 1 - src/rng/randpool/randpool.cpp | 2 +- src/timer/gettimeofday/tm_unix.cpp | 1 - src/timer/posix_rt/tm_posix.cpp | 1 - src/timer/timer.cpp | 1 - src/timer/timer.h | 5 ++++ src/utils/info.txt | 3 +-- src/utils/rounding.h | 35 ++++++++++++++++++++++++++ src/utils/util.cpp | 50 ------------------------------------- src/utils/util.h | 45 --------------------------------- 31 files changed, 130 insertions(+), 121 deletions(-) create mode 100644 src/pubkey/workfactor.cpp create mode 100644 src/pubkey/workfactor.h create mode 100644 src/utils/rounding.h delete mode 100644 src/utils/util.cpp delete mode 100644 src/utils/util.h (limited to 'src') diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp index 792e9c58d..d62099b6e 100644 --- a/checks/cvc_tests.cpp +++ b/checks/cvc_tests.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #define TEST_DATA_DIR "checks/ecc_testdata" diff --git a/src/alloc/mem_pool/mem_pool.cpp b/src/alloc/mem_pool/mem_pool.cpp index 38e0c3285..dabf5e310 100644 --- a/src/alloc/mem_pool/mem_pool.cpp +++ b/src/alloc/mem_pool/mem_pool.cpp @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp index 3bbc1f883..9be845974 100644 --- a/src/benchmark/benchmark.cpp +++ b/src/benchmark/benchmark.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include namespace Botan { diff --git a/src/cert/cvc/cvc_ca.cpp b/src/cert/cvc/cvc_ca.cpp index 638d3f984..8ca8db0c2 100644 --- a/src/cert/cvc/cvc_ca.cpp +++ b/src/cert/cvc/cvc_ca.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include namespace Botan { diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp index 91ea38724..777347a18 100644 --- a/src/cert/cvc/cvc_self.cpp +++ b/src/cert/cvc/cvc_self.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include namespace Botan { diff --git a/src/cert/x509/crl_ent.cpp b/src/cert/x509/crl_ent.cpp index afea8cf6b..a8a989c24 100644 --- a/src/cert/x509/crl_ent.cpp +++ b/src/cert/x509/crl_ent.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace Botan { diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp index 41e314724..f0eb9c3e5 100644 --- a/src/cert/x509/x509_ca.cpp +++ b/src/cert/x509/x509_ca.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/cert/x509/x509opt.cpp b/src/cert/x509/x509opt.cpp index de9d589a3..988ab2cfa 100644 --- a/src/cert/x509/x509opt.cpp +++ b/src/cert/x509/x509opt.cpp @@ -6,9 +6,9 @@ */ #include -#include -#include #include +#include +#include #include namespace Botan { diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp index cb61bc2d2..40801148c 100644 --- a/src/cert/x509/x509stor.cpp +++ b/src/cert/x509/x509stor.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp index 926bedc02..63bdc3605 100644 --- a/src/math/bigint/bigint.cpp +++ b/src/math/bigint/bigint.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace Botan { diff --git a/src/math/numbertheory/mp_numth.cpp b/src/math/numbertheory/mp_numth.cpp index 45a398440..2cb36b8a3 100644 --- a/src/math/numbertheory/mp_numth.cpp +++ b/src/math/numbertheory/mp_numth.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include namespace Botan { diff --git a/src/modes/mode_pad/mode_pad.cpp b/src/modes/mode_pad/mode_pad.cpp index b8badd7a7..2204c28b5 100644 --- a/src/modes/mode_pad/mode_pad.cpp +++ b/src/modes/mode_pad/mode_pad.cpp @@ -7,7 +7,6 @@ #include #include -#include namespace Botan { diff --git a/src/pubkey/dh/dh.cpp b/src/pubkey/dh/dh.cpp index 0c9d02f0e..149bc5882 100644 --- a/src/pubkey/dh/dh.cpp +++ b/src/pubkey/dh/dh.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include namespace Botan { diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp index 81c5d5e1d..13ea03016 100644 --- a/src/pubkey/dl_group/dl_group.cpp +++ b/src/pubkey/dl_group/dl_group.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include namespace Botan { diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp index 615efecf1..677a5088e 100644 --- a/src/pubkey/ecc_key/ecc_key.cpp +++ b/src/pubkey/ecc_key/ecc_key.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp index 9640c6397..ea2c35a19 100644 --- a/src/pubkey/ecdsa/ecdsa.cpp +++ b/src/pubkey/ecdsa/ecdsa.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/pubkey/eckaeg/eckaeg.cpp b/src/pubkey/eckaeg/eckaeg.cpp index b8ff75d89..dc6eb925b 100644 --- a/src/pubkey/eckaeg/eckaeg.cpp +++ b/src/pubkey/eckaeg/eckaeg.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp index 1f79df57a..8c07c5735 100644 --- a/src/pubkey/elgamal/elgamal.cpp +++ b/src/pubkey/elgamal/elgamal.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace Botan { diff --git a/src/pubkey/info.txt b/src/pubkey/info.txt index ee8da5b9d..63af86c47 100644 --- a/src/pubkey/info.txt +++ b/src/pubkey/info.txt @@ -15,6 +15,8 @@ pubkey.cpp pubkey.h pubkey_enums.cpp pubkey_enums.h +workfactor.cpp +workfactor.h diff --git a/src/pubkey/workfactor.cpp b/src/pubkey/workfactor.cpp new file mode 100644 index 000000000..e40b7919c --- /dev/null +++ b/src/pubkey/workfactor.cpp @@ -0,0 +1,51 @@ +/* +* Public Key Work Factor Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include +#include + +namespace Botan { + +/* +* Choose the exponent size for a DL group +*/ +u32bit dl_work_factor(u32bit bits) + { +#if 0 + /* + These values were taken from RFC 3526 + */ + if(bits <= 1536) + return 90; + else if(bits <= 2048) + return 110; + else if(bits <= 3072) + return 130; + else if(bits <= 4096) + return 150; + else if(bits <= 6144) + return 170; + else if(bits <= 8192) + return 190; + return 256; +#else + const u32bit MIN_ESTIMATE = 64; + + const double log_x = bits / 1.44; + + const double strength = + 2.76 * std::pow(log_x, 1.0/3.0) * std::pow(std::log(log_x), 2.0/3.0); + + if(strength > MIN_ESTIMATE) + return static_cast(strength); + return MIN_ESTIMATE; +#endif + } + + +} diff --git a/src/pubkey/workfactor.h b/src/pubkey/workfactor.h new file mode 100644 index 000000000..653f697e3 --- /dev/null +++ b/src/pubkey/workfactor.h @@ -0,0 +1,22 @@ +/* +* Public Key Work Factor Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_WORKFACTOR_H__ +#define BOTAN_WORKFACTOR_H__ + +#include + +namespace Botan { + +/* +* Work Factor Estimates +*/ +BOTAN_DLL u32bit dl_work_factor(u32bit prime_group_size); + +} + +#endif diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp index 113489db3..8444b1083 100644 --- a/src/rng/hmac_rng/hmac_rng.cpp +++ b/src/rng/hmac_rng/hmac_rng.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index 77a5228c6..fe83f4361 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/timer/gettimeofday/tm_unix.cpp b/src/timer/gettimeofday/tm_unix.cpp index e32df7166..9d8ac4a04 100644 --- a/src/timer/gettimeofday/tm_unix.cpp +++ b/src/timer/gettimeofday/tm_unix.cpp @@ -6,7 +6,6 @@ */ #include -#include #include namespace Botan { diff --git a/src/timer/posix_rt/tm_posix.cpp b/src/timer/posix_rt/tm_posix.cpp index d356384ab..96182025c 100644 --- a/src/timer/posix_rt/tm_posix.cpp +++ b/src/timer/posix_rt/tm_posix.cpp @@ -6,7 +6,6 @@ */ #include -#include #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 199309 diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp index 035c217f9..e3e3c5a16 100644 --- a/src/timer/timer.cpp +++ b/src/timer/timer.cpp @@ -7,7 +7,6 @@ #include #include -#include #include namespace Botan { diff --git a/src/timer/timer.h b/src/timer/timer.h index b6e8ef448..3bbe85a5e 100644 --- a/src/timer/timer.h +++ b/src/timer/timer.h @@ -12,6 +12,11 @@ namespace Botan { +/* +* Time Access Functions +*/ +BOTAN_DLL u64bit system_time(); + /** * Timer Interface */ diff --git a/src/utils/info.txt b/src/utils/info.txt index bf9778369..68981729f 100644 --- a/src/utils/info.txt +++ b/src/utils/info.txt @@ -22,12 +22,11 @@ mlock.cpp parsing.cpp parsing.h rotate.h +rounding.h stl_util.h types.h ui.cpp ui.h -util.cpp -util.h version.cpp version.h xor_buf.h diff --git a/src/utils/rounding.h b/src/utils/rounding.h new file mode 100644 index 000000000..11ab90b8d --- /dev/null +++ b/src/utils/rounding.h @@ -0,0 +1,35 @@ +/* +* Integer Rounding Functions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ROUNDING_H__ +#define BOTAN_ROUNDING_H__ + +#include + +namespace Botan { + +/* +* Round up n to multiple of align_to +*/ +inline u32bit round_up(u32bit n, u32bit align_to) + { + if(n % align_to || n == 0) + n += align_to - (n % align_to); + return n; + } + +/* +* Round down n to multiple of align_to +*/ +inline u32bit round_down(u32bit n, u32bit align_to) + { + return (n - (n % align_to)); + } + +} + +#endif diff --git a/src/utils/util.cpp b/src/utils/util.cpp deleted file mode 100644 index 09ac9f1ca..000000000 --- a/src/utils/util.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Utility Functions -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include -#include -#include - -namespace Botan { - -/* -* Choose the exponent size for a DL group -*/ -u32bit dl_work_factor(u32bit bits) - { -#if 0 - /* - These values were taken from RFC 3526 - */ - if(bits <= 1536) - return 90; - else if(bits <= 2048) - return 110; - else if(bits <= 3072) - return 130; - else if(bits <= 4096) - return 150; - else if(bits <= 6144) - return 170; - else if(bits <= 8192) - return 190; - return 256; -#else - const u32bit MIN_ESTIMATE = 64; - - const double log_x = bits / 1.44; - - const double strength = - 2.76 * std::pow(log_x, 1.0/3.0) * std::pow(std::log(log_x), 2.0/3.0); - - if(strength > MIN_ESTIMATE) - return static_cast(strength); - return MIN_ESTIMATE; -#endif - } - -} diff --git a/src/utils/util.h b/src/utils/util.h deleted file mode 100644 index e3dadc64b..000000000 --- a/src/utils/util.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Utility Functions -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_UTIL_H__ -#define BOTAN_UTIL_H__ - -#include - -namespace Botan { - -/* -* Time Access Functions -*/ -BOTAN_DLL u64bit system_time(); - -/* -* Round up n to multiple of align_to -*/ -inline u32bit round_up(u32bit n, u32bit align_to) - { - if(n % align_to || n == 0) - n += align_to - (n % align_to); - return n; - } - -/* -* Round down n to multiple of align_to -*/ -inline u32bit round_down(u32bit n, u32bit align_to) - { - return (n - (n % align_to)); - } - -/* -* Work Factor Estimates -*/ -BOTAN_DLL u32bit dl_work_factor(u32bit); - -} - -#endif -- cgit v1.2.3 From 7e839d037119055b572f40ce0cd882f85583db2e Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 17 Sep 2009 14:12:57 +0000 Subject: The get_tm function was duplicated. Move single version to timer.{h,cpp} --- doc/examples/bench.cpp | 44 ++++++++++++++++++++------------- src/asn1/asn1_tm.cpp | 22 ++--------------- src/cert/cvc/asn1_eac_tm.cpp | 59 ++++++++++++-------------------------------- src/cert/x509/x509opt.cpp | 1 - src/timer/timer.cpp | 13 ++++++++++ src/timer/timer.h | 5 +++- 6 files changed, 62 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/doc/examples/bench.cpp b/doc/examples/bench.cpp index 0aedc699d..cc43fade0 100644 --- a/doc/examples/bench.cpp +++ b/doc/examples/bench.cpp @@ -60,30 +60,40 @@ const std::string algos[] = { "", }; -int main() +void benchmark_algo(const std::string& algo, + RandomNumberGenerator& rng) { - LibraryInitializer init; - - u32bit milliseconds = 1000; - AutoSeeded_RNG rng; + u32bit milliseconds = 3000; Default_Benchmark_Timer timer; - Algorithm_Factory& af = global_state().algorithm_factory(); - for(u32bit i = 0; algos[i] != ""; ++i) + std::map speeds = + algorithm_benchmark(algo, milliseconds, timer, rng, af); + + std::cout << algo << ":"; + + for(std::map::const_iterator i = speeds.begin(); + i != speeds.end(); ++i) { - std::string algo = algos[i]; + std::cout << " " << i->second << " [" << i->first << "]"; + } + std::cout << "\n"; + } - std::map speeds = - algorithm_benchmark(algos[i], milliseconds, timer, rng, af); +int main(int argc, char* argv[]) + { + LibraryInitializer init; - std::cout << algo << ":"; + AutoSeeded_RNG rng; - for(std::map::const_iterator i = speeds.begin(); - i != speeds.end(); ++i) - { - std::cout << " " << i->second << " [" << i->first << "]"; - } - std::cout << "\n"; + if(argc == 1) // no args, benchmark everything + { + for(u32bit i = 0; algos[i] != ""; ++i) + benchmark_algo(algos[i], rng); + } + else + { + for(int i = 1; argv[i]; ++i) + benchmark_algo(argv[i], rng); } } diff --git a/src/asn1/asn1_tm.cpp b/src/asn1/asn1_tm.cpp index f85ea128b..09bc4d347 100644 --- a/src/asn1/asn1_tm.cpp +++ b/src/asn1/asn1_tm.cpp @@ -10,28 +10,10 @@ #include #include #include -#include +#include namespace Botan { -namespace { - -/* -* Convert a time_t to a struct tm -*/ -std::tm get_tm(u64bit timer) - { - std::time_t time_val = static_cast(timer); - - std::tm* tm_p = std::gmtime(&time_val); - if(tm_p == 0) - throw Encoding_Error("X509_Time: gmtime could not encode " + - to_string(timer)); - return (*tm_p); - } - -} - /* * Create an X509_Time */ @@ -45,7 +27,7 @@ X509_Time::X509_Time(const std::string& time_str) */ X509_Time::X509_Time(u64bit timer) { - std::tm time_info = get_tm(timer); + std::tm time_info = time_t_to_tm(timer); year = time_info.tm_year + 1900; month = time_info.tm_mon + 1; diff --git a/src/cert/cvc/asn1_eac_tm.cpp b/src/cert/cvc/asn1_eac_tm.cpp index 05533b520..947b9e66d 100644 --- a/src/cert/cvc/asn1_eac_tm.cpp +++ b/src/cert/cvc/asn1_eac_tm.cpp @@ -11,53 +11,39 @@ #include #include #include -#include -#include +#include +#include namespace Botan { namespace { -/* -* Convert a time_t to a struct tm -*/ -std::tm get_tm(u64bit timer) - { - std::time_t time_val = static_cast(timer); - - std::tm* tm_p = std::gmtime(&time_val); - if (tm_p == 0) - throw Encoding_Error("EAC_Time: gmtime could not encode " + - to_string(timer)); - return (*tm_p); - } SecureVector enc_two_digit(u32bit in) { SecureVector result; in %= 100; if (in < 10) - { result.append(0x00); - } else { - u32bit y_first_pos = (in - (in%10))/10; + u32bit y_first_pos = round_down(in, 10) / 10; result.append(static_cast(y_first_pos)); } - u32bit y_sec_pos = in%10; + + u32bit y_sec_pos = in % 10; result.append(static_cast(y_sec_pos)); return result; } + u32bit dec_two_digit(byte b1, byte b2) { u32bit upper = (u32bit)b1; u32bit lower = (u32bit)b2; - if (upper > 9 || lower > 9) - { - throw Invalid_Argument("u32bit dec_two_digit(byte b1, byte b2): value too large"); - } - return upper*10 + lower; + if(upper > 9 || lower > 9) + throw Invalid_Argument("CVC dec_two_digit value too large"); + + return upper*10 + lower; } } @@ -67,12 +53,11 @@ u32bit dec_two_digit(byte b1, byte b2) EAC_Time::EAC_Time(u64bit timer, ASN1_Tag t) :tag(t) { - std::tm time_info = get_tm(timer); + std::tm time_info = time_t_to_tm(timer); year = time_info.tm_year + 1900; month = time_info.tm_mon + 1; day = time_info.tm_mday; - } /* @@ -272,27 +257,15 @@ bool operator<(const EAC_Time& t1, const EAC_Time& t2) void EAC_Time::decode_from(BER_Decoder& source) { BER_Object obj = source.get_next_object(); - if (obj.type_tag != this->tag) - { - std::string message("decoding type mismatch for EAC_Time, tag is "); - std::stringstream ss; - std::string str_is; - ss << std::hex << obj.type_tag; - ss >> str_is; - message.append(str_is); - message.append(", while it should be "); - std::stringstream ss2; - std::string str_should; - ss2 << std::hex << this->tag; - ss2 >> str_should; - message.append(str_should); - throw Decoding_Error(message); - } - if (obj.value.size() != 6) + if(obj.type_tag != this->tag) + throw BER_Decoding_Error("Tag mismatch when decoding"); + + if(obj.value.size() != 6) { throw Decoding_Error("EAC_Time decoding failed"); } + try { u32bit tmp_year = dec_two_digit(obj.value[0], obj.value[1]); diff --git a/src/cert/x509/x509opt.cpp b/src/cert/x509/x509opt.cpp index 988ab2cfa..03bcd20f4 100644 --- a/src/cert/x509/x509opt.cpp +++ b/src/cert/x509/x509opt.cpp @@ -9,7 +9,6 @@ #include #include #include -#include namespace Botan { diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp index e3e3c5a16..16d7dc368 100644 --- a/src/timer/timer.cpp +++ b/src/timer/timer.cpp @@ -19,6 +19,19 @@ u64bit system_time() return static_cast(std::time(0)); } +/* +* Convert a time_t to a struct tm +*/ +std::tm time_t_to_tm(u64bit timer) + { + std::time_t time_val = static_cast(timer); + + std::tm* tm_p = std::gmtime(&time_val); + if (tm_p == 0) + throw Encoding_Error("time_t_to_tm could not convert"); + return (*tm_p); + } + /** * Read the clock and return the output */ diff --git a/src/timer/timer.h b/src/timer/timer.h index 3bbe85a5e..603027f6d 100644 --- a/src/timer/timer.h +++ b/src/timer/timer.h @@ -9,14 +9,17 @@ #define BOTAN_TIMERS_H__ #include +#include namespace Botan { /* -* Time Access Functions +* Time Access/Conversion Functions */ BOTAN_DLL u64bit system_time(); +BOTAN_DLL std::tm time_t_to_tm(u64bit); + /** * Timer Interface */ -- cgit v1.2.3