diff options
author | lloyd <[email protected]> | 2011-04-22 13:08:05 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-04-22 13:08:05 +0000 |
commit | 8b40f974e65b7cc7d21a8e72b5f18f6e14208e57 (patch) | |
tree | 1192bdf14dbab29218db64abbef9ec0217ce30c8 /src/hash/md4_x86_32 | |
parent | 7b96a4844bf97b9c04a18565334e21dc89b8ba0b (diff) |
Rename all references of ia32 to x86-32 and amd64 to x86-64.
Back the reported version from 1.10.0 to 1.9.17 for the time
being. Still on the fence if this will be 1.10.0 or another release
candidate instead.
Diffstat (limited to 'src/hash/md4_x86_32')
-rw-r--r-- | src/hash/md4_x86_32/info.txt | 12 | ||||
-rw-r--r-- | src/hash/md4_x86_32/md4_x86_32.cpp | 34 | ||||
-rw-r--r-- | src/hash/md4_x86_32/md4_x86_32.h | 28 | ||||
-rw-r--r-- | src/hash/md4_x86_32/md4_x86_32_imp.S | 137 |
4 files changed, 211 insertions, 0 deletions
diff --git a/src/hash/md4_x86_32/info.txt b/src/hash/md4_x86_32/info.txt new file mode 100644 index 000000000..fdc534df4 --- /dev/null +++ b/src/hash/md4_x86_32/info.txt @@ -0,0 +1,12 @@ +define MD4_X86_32 + +load_on asm_ok + +<arch> +x86_32 +</arch> + +<requires> +asm_x86_32 +md4 +</requires> diff --git a/src/hash/md4_x86_32/md4_x86_32.cpp b/src/hash/md4_x86_32/md4_x86_32.cpp new file mode 100644 index 000000000..750e65a95 --- /dev/null +++ b/src/hash/md4_x86_32/md4_x86_32.cpp @@ -0,0 +1,34 @@ +/* +* MD4 (x86-32) +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/md4_x86_32.h> + +namespace Botan { + +/** +* MD4 compression function in x86-32 asm +* @param digest the current digest +* @param input the input block +* @param M the message buffer +*/ +extern "C" void botan_md4_x86_32_compress(u32bit digest[4], + const byte input[64], + u32bit M[16]); + +/* +* MD4 Compression Function +*/ +void MD4_X86_32::compress_n(const byte input[], size_t blocks) + { + for(size_t i = 0; i != blocks; ++i) + { + botan_md4_x86_32_compress(digest, input, M); + input += hash_block_size(); + } + } + +} diff --git a/src/hash/md4_x86_32/md4_x86_32.h b/src/hash/md4_x86_32/md4_x86_32.h new file mode 100644 index 000000000..a9f23e94f --- /dev/null +++ b/src/hash/md4_x86_32/md4_x86_32.h @@ -0,0 +1,28 @@ +/* +* MD4 (x86-32) +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_MD4_X86_32_H__ +#define BOTAN_MD4_X86_32_H__ + +#include <botan/md4.h> + +namespace Botan { + +/** +* MD4 using x86 assembly +*/ +class BOTAN_DLL MD4_X86_32 : public MD4 + { + public: + HashFunction* clone() const { return new MD4_X86_32; } + private: + void compress_n(const byte[], size_t blocks); + }; + +} + +#endif diff --git a/src/hash/md4_x86_32/md4_x86_32_imp.S b/src/hash/md4_x86_32/md4_x86_32_imp.S new file mode 100644 index 000000000..192751166 --- /dev/null +++ b/src/hash/md4_x86_32/md4_x86_32_imp.S @@ -0,0 +1,137 @@ +/* +* MD4 in x86-32 assembler +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/internal/asm_x86_32.h> + +START_LISTING(md4_x86_32_imp.S) + +START_FUNCTION(botan_md4_x86_32_compress) + SPILL_REGS() + +#define PUSHED 4 + + ASSIGN(EBP, ARG(2)) /* input block */ + ASSIGN(EDI, ARG(3)) /* expanded words */ + + ZEROIZE(ESI) + +START_LOOP(.LOAD_INPUT) + ADD_IMM(ESI, 4) + + ASSIGN(EAX, ARRAY4(EBP, 0)) + ASSIGN(EBX, ARRAY4(EBP, 1)) + ASSIGN(ECX, ARRAY4(EBP, 2)) + ASSIGN(EDX, ARRAY4(EBP, 3)) + + ADD_IMM(EBP, 16) + + ASSIGN(ARRAY4_INDIRECT(EDI,ESI,-4), EAX) + ASSIGN(ARRAY4_INDIRECT(EDI,ESI,-3), EBX) + ASSIGN(ARRAY4_INDIRECT(EDI,ESI,-2), ECX) + ASSIGN(ARRAY4_INDIRECT(EDI,ESI,-1), EDX) +LOOP_UNTIL_EQ(ESI, 16, .LOAD_INPUT) + + ASSIGN(EBP, ARG(1)) + ASSIGN(EAX, ARRAY4(EBP, 0)) + ASSIGN(EBX, ARRAY4(EBP, 1)) + ASSIGN(ECX, ARRAY4(EBP, 2)) + ASSIGN(EDX, ARRAY4(EBP, 3)) + +#define MSG EDI +#define T1 ESI +#define T2 EBP + +#define FF(A, B, C, D, N, S) \ + ASSIGN(T1, ARRAY4(MSG, N)) ; \ + ASSIGN(T2, C) ; \ + XOR(T2, D) ; \ + AND(T2, B) ; \ + XOR(T2, D) ; \ + ADD(A, T1) ; \ + ADD(A, T2) ; \ + ROTL_IMM(A, S) ; + +#define GG(A, B, C, D, N, S) \ + ASSIGN(T1, ARRAY4(MSG, N)) ; \ + ASSIGN(T2, B) ; \ + OR(T2, C) ; \ + AND(T2, D) ; \ + ADD3_IMM(A, T1, 0x5A827999) ; \ + ASSIGN(T1, B) ; \ + AND(T1, C) ; \ + OR(T2, T1) ; \ + ADD(A, T2) ; \ + ROTL_IMM(A, S) ; + +#define HH(A, B, C, D, N, S) \ + ASSIGN(T1, ARRAY4(MSG, N)) ; \ + ASSIGN(T2, B) ; \ + XOR(T2, C) ; \ + XOR(T2, D) ; \ + ADD3_IMM(A, T1, 0x6ED9EBA1) ; \ + ADD(A, T2) ; \ + ROTL_IMM(A, S) ; + + FF(EAX,EBX,ECX,EDX, 0, 3); + FF(EDX,EAX,EBX,ECX, 1, 7); + FF(ECX,EDX,EAX,EBX, 2,11); + FF(EBX,ECX,EDX,EAX, 3,19); + FF(EAX,EBX,ECX,EDX, 4, 3); + FF(EDX,EAX,EBX,ECX, 5, 7); + FF(ECX,EDX,EAX,EBX, 6,11); + FF(EBX,ECX,EDX,EAX, 7,19); + FF(EAX,EBX,ECX,EDX, 8, 3); + FF(EDX,EAX,EBX,ECX, 9, 7); + FF(ECX,EDX,EAX,EBX,10,11); + FF(EBX,ECX,EDX,EAX,11,19); + FF(EAX,EBX,ECX,EDX,12, 3); + FF(EDX,EAX,EBX,ECX,13, 7); + FF(ECX,EDX,EAX,EBX,14,11); + FF(EBX,ECX,EDX,EAX,15,19); + + GG(EAX,EBX,ECX,EDX, 0, 3); + GG(EDX,EAX,EBX,ECX, 4, 5); + GG(ECX,EDX,EAX,EBX, 8, 9); + GG(EBX,ECX,EDX,EAX,12,13); + GG(EAX,EBX,ECX,EDX, 1, 3); + GG(EDX,EAX,EBX,ECX, 5, 5); + GG(ECX,EDX,EAX,EBX, 9, 9); + GG(EBX,ECX,EDX,EAX,13,13); + GG(EAX,EBX,ECX,EDX, 2, 3); + GG(EDX,EAX,EBX,ECX, 6, 5); + GG(ECX,EDX,EAX,EBX,10, 9); + GG(EBX,ECX,EDX,EAX,14,13); + GG(EAX,EBX,ECX,EDX, 3, 3); + GG(EDX,EAX,EBX,ECX, 7, 5); + GG(ECX,EDX,EAX,EBX,11, 9); + GG(EBX,ECX,EDX,EAX,15,13); + + HH(EAX,EBX,ECX,EDX, 0, 3); + HH(EDX,EAX,EBX,ECX, 8, 9); + HH(ECX,EDX,EAX,EBX, 4,11); + HH(EBX,ECX,EDX,EAX,12,15); + HH(EAX,EBX,ECX,EDX, 2, 3); + HH(EDX,EAX,EBX,ECX,10, 9); + HH(ECX,EDX,EAX,EBX, 6,11); + HH(EBX,ECX,EDX,EAX,14,15); + HH(EAX,EBX,ECX,EDX, 1, 3); + HH(EDX,EAX,EBX,ECX, 9, 9); + HH(ECX,EDX,EAX,EBX, 5,11); + HH(EBX,ECX,EDX,EAX,13,15); + HH(EAX,EBX,ECX,EDX, 3, 3); + HH(EDX,EAX,EBX,ECX,11, 9); + HH(ECX,EDX,EAX,EBX, 7,11); + HH(EBX,ECX,EDX,EAX,15,15); + + ASSIGN(EBP, ARG(1)) + ADD(ARRAY4(EBP, 0), EAX) + ADD(ARRAY4(EBP, 1), EBX) + ADD(ARRAY4(EBP, 2), ECX) + ADD(ARRAY4(EBP, 3), EDX) + + RESTORE_REGS() +END_FUNCTION(botan_md4_x86_32_compress) |