From 26abd45c61294aacdd59fa4763ff1cd78aefbc7c Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 29 Sep 2008 17:43:36 +0000 Subject: Make asm implementations distinctly named objects, for instance MD5_IA32, rather than silently replacing the C++ versions. Instead they are silently replaced (currently, at least) at the lookup level: we switch off the set of feature macros set to choose the best implementation in the current build configuration. So you can have (and benchmark) MD5 and MD5_IA32 directly against each other in the same program with no hassles, but if you ask for "MD5", you'll get maybe an MD5 or maybe MD5_IA32. Also make the canonical asm names (which aren't guarded by C++ namespaces) of the form botan___ as in botan_sha160_ia32_compress, to avoid namespace collisions. This change has another bonus that it should in many cases be possible to derive the asm specializations directly from the original implementation, saving some code (and of course logically SHA_160_IA32 is a SHA_160, just one with a faster implementation of the compression function, so this seems reasonable anyway). --- src/hash/sha1_ia32/info.txt | 14 ++- src/hash/sha1_ia32/sha160.cpp | 52 -------- src/hash/sha1_ia32/sha1_ia32.S | 242 ------------------------------------- src/hash/sha1_ia32/sha1_ia32.cpp | 49 ++++++++ src/hash/sha1_ia32/sha1_ia32.h | 36 ++++++ src/hash/sha1_ia32/sha1_ia32_imp.S | 242 +++++++++++++++++++++++++++++++++++++ 6 files changed, 335 insertions(+), 300 deletions(-) delete mode 100644 src/hash/sha1_ia32/sha160.cpp delete mode 100644 src/hash/sha1_ia32/sha1_ia32.S create mode 100644 src/hash/sha1_ia32/sha1_ia32.cpp create mode 100644 src/hash/sha1_ia32/sha1_ia32.h create mode 100644 src/hash/sha1_ia32/sha1_ia32_imp.S (limited to 'src/hash/sha1_ia32') diff --git a/src/hash/sha1_ia32/info.txt b/src/hash/sha1_ia32/info.txt index c1a75fc55..ff8b66ddc 100644 --- a/src/hash/sha1_ia32/info.txt +++ b/src/hash/sha1_ia32/info.txt @@ -1,17 +1,19 @@ -realname "SHA-1 (x86)" +realname "SHA-1 (IA-32)" -define SHA1 +define SHA1_IA32 -load_on requested +load_on auto -sha1_ia32.S -sha160.cpp -sha160.h +sha1_ia32_imp.S +sha1_ia32.cpp +sha1_ia32.h +asm_ia32 mdx_hash +utils diff --git a/src/hash/sha1_ia32/sha160.cpp b/src/hash/sha1_ia32/sha160.cpp deleted file mode 100644 index 7725541d5..000000000 --- a/src/hash/sha1_ia32/sha160.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************* -* SHA-160 Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include -#include - -namespace Botan { - -extern "C" void botan_sha160_asm_ia32(u32bit[5], const byte[64], u32bit[81]); - -/************************************************* -* SHA-160 Compression Function * -*************************************************/ -void SHA_160::hash(const byte input[]) - { - botan_sha160_asm_ia32(digest, input, W); - } - -/************************************************* -* Copy out the digest * -*************************************************/ -void SHA_160::copy_out(byte output[]) - { - for(u32bit j = 0; j != OUTPUT_LENGTH; ++j) - output[j] = get_byte(j % 4, digest[j/4]); - } - -/************************************************* -* Clear memory of sensitive data * -*************************************************/ -void SHA_160::clear() throw() - { - MDx_HashFunction::clear(); - W.clear(); - digest[0] = 0x67452301; - digest[1] = 0xEFCDAB89; - digest[2] = 0x98BADCFE; - digest[3] = 0x10325476; - digest[4] = 0xC3D2E1F0; - } - -/************************************************* -* SHA_160 Constructor * -*************************************************/ -SHA_160::SHA_160() : MDx_HashFunction(20, 64, true, true), W(81) - { - clear(); - } - -} diff --git a/src/hash/sha1_ia32/sha1_ia32.S b/src/hash/sha1_ia32/sha1_ia32.S deleted file mode 100644 index ddd72e316..000000000 --- a/src/hash/sha1_ia32/sha1_ia32.S +++ /dev/null @@ -1,242 +0,0 @@ -/************************************************* -* SHA-160 Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include - -START_LISTING(sha1_asm.S) - -START_FUNCTION(botan_sha160_core_asm) - SPILL_REGS() - -#define PUSHED 4 - - ASSIGN(EDI, ARG(2)) - ASSIGN(EBP, ARG(3)) - - ZEROIZE(ESI) - -START_LOOP(.LOAD_INPUT) - ADD_IMM(ESI, 4) - - ASSIGN(EAX, ARRAY4(EDI, 0)) - ASSIGN(EBX, ARRAY4(EDI, 1)) - ASSIGN(ECX, ARRAY4(EDI, 2)) - ASSIGN(EDX, ARRAY4(EDI, 3)) - - ADD_IMM(EDI, 16) - - BSWAP(EAX) - BSWAP(EBX) - BSWAP(ECX) - BSWAP(EDX) - - ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-4), EAX) - ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-3), EBX) - ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-2), ECX) - ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-1), EDX) -LOOP_UNTIL_EQ(ESI, 16, .LOAD_INPUT) - - ADD2_IMM(EDI, EBP, 64) - -START_LOOP(.EXPANSION) - ADD_IMM(ESI, 4) - - ZEROIZE(EAX) - ASSIGN(EBX, ARRAY4(EDI, -1)) - ASSIGN(ECX, ARRAY4(EDI, -2)) - ASSIGN(EDX, ARRAY4(EDI, -3)) - - XOR(EAX, ARRAY4(EDI, -5)) - XOR(EBX, ARRAY4(EDI, -6)) - XOR(ECX, ARRAY4(EDI, -7)) - XOR(EDX, ARRAY4(EDI, -8)) - - XOR(EAX, ARRAY4(EDI, -11)) - XOR(EBX, ARRAY4(EDI, -12)) - XOR(ECX, ARRAY4(EDI, -13)) - XOR(EDX, ARRAY4(EDI, -14)) - - XOR(EAX, ARRAY4(EDI, -13)) - XOR(EBX, ARRAY4(EDI, -14)) - XOR(ECX, ARRAY4(EDI, -15)) - XOR(EDX, ARRAY4(EDI, -16)) - - ROTL_IMM(EDX, 1) - ROTL_IMM(ECX, 1) - ROTL_IMM(EBX, 1) - XOR(EAX, EDX) - ROTL_IMM(EAX, 1) - - ASSIGN(ARRAY4(EDI, 0), EDX) - ASSIGN(ARRAY4(EDI, 1), ECX) - ASSIGN(ARRAY4(EDI, 2), EBX) - ASSIGN(ARRAY4(EDI, 3), EAX) - - ADD_IMM(EDI, 16) -LOOP_UNTIL_EQ(ESI, 80, .EXPANSION) - -#define MAGIC1 0x5A827999 -#define MAGIC2 0x6ED9EBA1 -#define MAGIC3 0x8F1BBCDC -#define MAGIC4 0xCA62C1D6 - -#define MSG ESP -#define T2 EBP - -#define F1(A, B, C, D, E, F, N) \ - ASSIGN(T2, ARRAY4(MSG, N)) ; \ - ASSIGN(A, F) ; \ - ROTL_IMM(F, 5) ; \ - ADD(F, E) ; \ - ASSIGN(E, C) ; \ - XOR(E, D) ; \ - ADD3_IMM(F, T2, MAGIC1) ; \ - AND(E, B) ; \ - XOR(E, D) ; \ - ROTR_IMM(B, 2) ; \ - ADD(E, F) ; - -#define F2_4(A, B, C, D, E, F, N, MAGIC) \ - ASSIGN(T2, ARRAY4(MSG, N)) ; \ - ASSIGN(A, F) ; \ - ROTL_IMM(F, 5) ; \ - ADD(F, E) ; \ - ASSIGN(E, B) ; \ - XOR(E, C) ; \ - ADD3_IMM(F, T2, MAGIC) ; \ - XOR(E, D) ; \ - ROTR_IMM(B, 2) ; \ - ADD(E, F) ; - -#define F3(A, B, C, D, E, F, N) \ - ASSIGN(T2, ARRAY4(MSG, N)) ; \ - ASSIGN(A, F) ; \ - ROTL_IMM(F, 5) ; \ - ADD(F, E) ; \ - ASSIGN(E, B) ; \ - OR(E, C) ; \ - AND(E, D) ; \ - ADD3_IMM(F, T2, MAGIC3) ; \ - ASSIGN(T2, B) ; \ - AND(T2, C) ; \ - OR(E, T2) ; \ - ROTR_IMM(B, 2) ; \ - ADD(E, F) ; - -#define F2(A, B, C, D, E, F, MSG) \ - F2_4(A, B, C, D, E, F, MSG, MAGIC2) - -#define F4(A, B, C, D, E, F, MSG) \ - F2_4(A, B, C, D, E, F, MSG, MAGIC4) - - ASSIGN(EAX, ARG(1)) - ASSIGN(EDI, ARRAY4(EAX, 0)) - ASSIGN(EBX, ARRAY4(EAX, 1)) - ASSIGN(ECX, ARRAY4(EAX, 2)) - ASSIGN(EDX, ARRAY4(EAX, 3)) - ASSIGN(ESI, ARRAY4(EAX, 4)) - - ASSIGN(ARRAY4(EBP, 80), ESP) - ASSIGN(ESP, EBP) - - /* First Round */ - F1(EAX, EBX, ECX, EDX, ESI, EDI, 0) - F1(EDI, EAX, EBX, ECX, EDX, ESI, 1) - F1(ESI, EDI, EAX, EBX, ECX, EDX, 2) - F1(EDX, ESI, EDI, EAX, EBX, ECX, 3) - F1(ECX, EDX, ESI, EDI, EAX, EBX, 4) - F1(EBX, ECX, EDX, ESI, EDI, EAX, 5) - F1(EAX, EBX, ECX, EDX, ESI, EDI, 6) - F1(EDI, EAX, EBX, ECX, EDX, ESI, 7) - F1(ESI, EDI, EAX, EBX, ECX, EDX, 8) - F1(EDX, ESI, EDI, EAX, EBX, ECX, 9) - F1(ECX, EDX, ESI, EDI, EAX, EBX, 10) - F1(EBX, ECX, EDX, ESI, EDI, EAX, 11) - F1(EAX, EBX, ECX, EDX, ESI, EDI, 12) - F1(EDI, EAX, EBX, ECX, EDX, ESI, 13) - F1(ESI, EDI, EAX, EBX, ECX, EDX, 14) - F1(EDX, ESI, EDI, EAX, EBX, ECX, 15) - F1(ECX, EDX, ESI, EDI, EAX, EBX, 16) - F1(EBX, ECX, EDX, ESI, EDI, EAX, 17) - F1(EAX, EBX, ECX, EDX, ESI, EDI, 18) - F1(EDI, EAX, EBX, ECX, EDX, ESI, 19) - - /* Second Round */ - F2(ESI, EDI, EAX, EBX, ECX, EDX, 20) - F2(EDX, ESI, EDI, EAX, EBX, ECX, 21) - F2(ECX, EDX, ESI, EDI, EAX, EBX, 22) - F2(EBX, ECX, EDX, ESI, EDI, EAX, 23) - F2(EAX, EBX, ECX, EDX, ESI, EDI, 24) - F2(EDI, EAX, EBX, ECX, EDX, ESI, 25) - F2(ESI, EDI, EAX, EBX, ECX, EDX, 26) - F2(EDX, ESI, EDI, EAX, EBX, ECX, 27) - F2(ECX, EDX, ESI, EDI, EAX, EBX, 28) - F2(EBX, ECX, EDX, ESI, EDI, EAX, 29) - F2(EAX, EBX, ECX, EDX, ESI, EDI, 30) - F2(EDI, EAX, EBX, ECX, EDX, ESI, 31) - F2(ESI, EDI, EAX, EBX, ECX, EDX, 32) - F2(EDX, ESI, EDI, EAX, EBX, ECX, 33) - F2(ECX, EDX, ESI, EDI, EAX, EBX, 34) - F2(EBX, ECX, EDX, ESI, EDI, EAX, 35) - F2(EAX, EBX, ECX, EDX, ESI, EDI, 36) - F2(EDI, EAX, EBX, ECX, EDX, ESI, 37) - F2(ESI, EDI, EAX, EBX, ECX, EDX, 38) - F2(EDX, ESI, EDI, EAX, EBX, ECX, 39) - - /* Third Round */ - F3(ECX, EDX, ESI, EDI, EAX, EBX, 40) - F3(EBX, ECX, EDX, ESI, EDI, EAX, 41) - F3(EAX, EBX, ECX, EDX, ESI, EDI, 42) - F3(EDI, EAX, EBX, ECX, EDX, ESI, 43) - F3(ESI, EDI, EAX, EBX, ECX, EDX, 44) - F3(EDX, ESI, EDI, EAX, EBX, ECX, 45) - F3(ECX, EDX, ESI, EDI, EAX, EBX, 46) - F3(EBX, ECX, EDX, ESI, EDI, EAX, 47) - F3(EAX, EBX, ECX, EDX, ESI, EDI, 48) - F3(EDI, EAX, EBX, ECX, EDX, ESI, 49) - F3(ESI, EDI, EAX, EBX, ECX, EDX, 50) - F3(EDX, ESI, EDI, EAX, EBX, ECX, 51) - F3(ECX, EDX, ESI, EDI, EAX, EBX, 52) - F3(EBX, ECX, EDX, ESI, EDI, EAX, 53) - F3(EAX, EBX, ECX, EDX, ESI, EDI, 54) - F3(EDI, EAX, EBX, ECX, EDX, ESI, 55) - F3(ESI, EDI, EAX, EBX, ECX, EDX, 56) - F3(EDX, ESI, EDI, EAX, EBX, ECX, 57) - F3(ECX, EDX, ESI, EDI, EAX, EBX, 58) - F3(EBX, ECX, EDX, ESI, EDI, EAX, 59) - - /* Fourth Round */ - F4(EAX, EBX, ECX, EDX, ESI, EDI, 60) - F4(EDI, EAX, EBX, ECX, EDX, ESI, 61) - F4(ESI, EDI, EAX, EBX, ECX, EDX, 62) - F4(EDX, ESI, EDI, EAX, EBX, ECX, 63) - F4(ECX, EDX, ESI, EDI, EAX, EBX, 64) - F4(EBX, ECX, EDX, ESI, EDI, EAX, 65) - F4(EAX, EBX, ECX, EDX, ESI, EDI, 66) - F4(EDI, EAX, EBX, ECX, EDX, ESI, 67) - F4(ESI, EDI, EAX, EBX, ECX, EDX, 68) - F4(EDX, ESI, EDI, EAX, EBX, ECX, 69) - F4(ECX, EDX, ESI, EDI, EAX, EBX, 70) - F4(EBX, ECX, EDX, ESI, EDI, EAX, 71) - F4(EAX, EBX, ECX, EDX, ESI, EDI, 72) - F4(EDI, EAX, EBX, ECX, EDX, ESI, 73) - F4(ESI, EDI, EAX, EBX, ECX, EDX, 74) - F4(EDX, ESI, EDI, EAX, EBX, ECX, 75) - F4(ECX, EDX, ESI, EDI, EAX, EBX, 76) - F4(EBX, ECX, EDX, ESI, EDI, EAX, 77) - F4(EAX, EBX, ECX, EDX, ESI, EDI, 78) - F4(EDI, EAX, EBX, ECX, EDX, ESI, 79) - - ASSIGN(ESP, ARRAY4(ESP, 80)) - - ASSIGN(EBP, ARG(1)) - ADD(ARRAY4(EBP, 0), EDX) - ADD(ARRAY4(EBP, 1), EDI) - ADD(ARRAY4(EBP, 2), EAX) - ADD(ARRAY4(EBP, 3), EBX) - ADD(ARRAY4(EBP, 4), ECX) - - RESTORE_REGS() -END_FUNCTION(botan_sha160_core_asm) diff --git a/src/hash/sha1_ia32/sha1_ia32.cpp b/src/hash/sha1_ia32/sha1_ia32.cpp new file mode 100644 index 000000000..4e24b0793 --- /dev/null +++ b/src/hash/sha1_ia32/sha1_ia32.cpp @@ -0,0 +1,49 @@ +/************************************************* +* SHA-160 (IA-32) Source File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#include +#include + +namespace Botan { + +namespace { + +extern "C" +void botan_sha160_ia32_compress(u32bit[5], const byte[64], u32bit[81]); + +} + +/************************************************* +* SHA-160 Compression Function * +*************************************************/ +void SHA_160_IA32::hash(const byte input[]) + { + botan_sha160_ia32_compress(digest, input, W); + } + +/************************************************* +* Copy out the digest * +*************************************************/ +void SHA_160_IA32::copy_out(byte output[]) + { + for(u32bit j = 0; j != OUTPUT_LENGTH; ++j) + output[j] = get_byte(j % 4, digest[j/4]); + } + +/************************************************* +* Clear memory of sensitive data * +*************************************************/ +void SHA_160_IA32::clear() throw() + { + MDx_HashFunction::clear(); + W.clear(); + digest[0] = 0x67452301; + digest[1] = 0xEFCDAB89; + digest[2] = 0x98BADCFE; + digest[3] = 0x10325476; + digest[4] = 0xC3D2E1F0; + } + +} diff --git a/src/hash/sha1_ia32/sha1_ia32.h b/src/hash/sha1_ia32/sha1_ia32.h new file mode 100644 index 000000000..ab9dd8ac2 --- /dev/null +++ b/src/hash/sha1_ia32/sha1_ia32.h @@ -0,0 +1,36 @@ +/************************************************* +* SHA-160 (IA-32) Header File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_SHA_160_IA32_H__ +#define BOTAN_SHA_160_IA32_H__ + +#include + +namespace Botan { + +/************************************************* +* SHA-160 * +*************************************************/ +class BOTAN_DLL SHA_160_IA32 : public MDx_HashFunction + { + public: + void clear() throw(); + std::string name() const { return "SHA-160"; } + HashFunction* clone() const { return new SHA_160_IA32; } + + SHA_160_IA32() : MDx_HashFunction(20, 64, true, true) { clear(); } + private: + void hash(const byte[]); + void copy_out(byte[]); + + SecureBuffer digest; + + // Note 81 instead of normal 80: IA-32 asm needs an extra temp + SecureBuffer W; + }; + +} + +#endif diff --git a/src/hash/sha1_ia32/sha1_ia32_imp.S b/src/hash/sha1_ia32/sha1_ia32_imp.S new file mode 100644 index 000000000..b7f881383 --- /dev/null +++ b/src/hash/sha1_ia32/sha1_ia32_imp.S @@ -0,0 +1,242 @@ +/************************************************* +* SHA-160 Source File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#include + +START_LISTING(sha1_ia32.S) + +START_FUNCTION(botan_sha160_ia32_compress) + SPILL_REGS() + +#define PUSHED 4 + + ASSIGN(EDI, ARG(2)) + ASSIGN(EBP, ARG(3)) + + ZEROIZE(ESI) + +START_LOOP(.LOAD_INPUT) + ADD_IMM(ESI, 4) + + ASSIGN(EAX, ARRAY4(EDI, 0)) + ASSIGN(EBX, ARRAY4(EDI, 1)) + ASSIGN(ECX, ARRAY4(EDI, 2)) + ASSIGN(EDX, ARRAY4(EDI, 3)) + + ADD_IMM(EDI, 16) + + BSWAP(EAX) + BSWAP(EBX) + BSWAP(ECX) + BSWAP(EDX) + + ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-4), EAX) + ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-3), EBX) + ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-2), ECX) + ASSIGN(ARRAY4_INDIRECT(EBP,ESI,-1), EDX) +LOOP_UNTIL_EQ(ESI, 16, .LOAD_INPUT) + + ADD2_IMM(EDI, EBP, 64) + +START_LOOP(.EXPANSION) + ADD_IMM(ESI, 4) + + ZEROIZE(EAX) + ASSIGN(EBX, ARRAY4(EDI, -1)) + ASSIGN(ECX, ARRAY4(EDI, -2)) + ASSIGN(EDX, ARRAY4(EDI, -3)) + + XOR(EAX, ARRAY4(EDI, -5)) + XOR(EBX, ARRAY4(EDI, -6)) + XOR(ECX, ARRAY4(EDI, -7)) + XOR(EDX, ARRAY4(EDI, -8)) + + XOR(EAX, ARRAY4(EDI, -11)) + XOR(EBX, ARRAY4(EDI, -12)) + XOR(ECX, ARRAY4(EDI, -13)) + XOR(EDX, ARRAY4(EDI, -14)) + + XOR(EAX, ARRAY4(EDI, -13)) + XOR(EBX, ARRAY4(EDI, -14)) + XOR(ECX, ARRAY4(EDI, -15)) + XOR(EDX, ARRAY4(EDI, -16)) + + ROTL_IMM(EDX, 1) + ROTL_IMM(ECX, 1) + ROTL_IMM(EBX, 1) + XOR(EAX, EDX) + ROTL_IMM(EAX, 1) + + ASSIGN(ARRAY4(EDI, 0), EDX) + ASSIGN(ARRAY4(EDI, 1), ECX) + ASSIGN(ARRAY4(EDI, 2), EBX) + ASSIGN(ARRAY4(EDI, 3), EAX) + + ADD_IMM(EDI, 16) +LOOP_UNTIL_EQ(ESI, 80, .EXPANSION) + +#define MAGIC1 0x5A827999 +#define MAGIC2 0x6ED9EBA1 +#define MAGIC3 0x8F1BBCDC +#define MAGIC4 0xCA62C1D6 + +#define MSG ESP +#define T2 EBP + +#define F1(A, B, C, D, E, F, N) \ + ASSIGN(T2, ARRAY4(MSG, N)) ; \ + ASSIGN(A, F) ; \ + ROTL_IMM(F, 5) ; \ + ADD(F, E) ; \ + ASSIGN(E, C) ; \ + XOR(E, D) ; \ + ADD3_IMM(F, T2, MAGIC1) ; \ + AND(E, B) ; \ + XOR(E, D) ; \ + ROTR_IMM(B, 2) ; \ + ADD(E, F) ; + +#define F2_4(A, B, C, D, E, F, N, MAGIC) \ + ASSIGN(T2, ARRAY4(MSG, N)) ; \ + ASSIGN(A, F) ; \ + ROTL_IMM(F, 5) ; \ + ADD(F, E) ; \ + ASSIGN(E, B) ; \ + XOR(E, C) ; \ + ADD3_IMM(F, T2, MAGIC) ; \ + XOR(E, D) ; \ + ROTR_IMM(B, 2) ; \ + ADD(E, F) ; + +#define F3(A, B, C, D, E, F, N) \ + ASSIGN(T2, ARRAY4(MSG, N)) ; \ + ASSIGN(A, F) ; \ + ROTL_IMM(F, 5) ; \ + ADD(F, E) ; \ + ASSIGN(E, B) ; \ + OR(E, C) ; \ + AND(E, D) ; \ + ADD3_IMM(F, T2, MAGIC3) ; \ + ASSIGN(T2, B) ; \ + AND(T2, C) ; \ + OR(E, T2) ; \ + ROTR_IMM(B, 2) ; \ + ADD(E, F) ; + +#define F2(A, B, C, D, E, F, MSG) \ + F2_4(A, B, C, D, E, F, MSG, MAGIC2) + +#define F4(A, B, C, D, E, F, MSG) \ + F2_4(A, B, C, D, E, F, MSG, MAGIC4) + + ASSIGN(EAX, ARG(1)) + ASSIGN(EDI, ARRAY4(EAX, 0)) + ASSIGN(EBX, ARRAY4(EAX, 1)) + ASSIGN(ECX, ARRAY4(EAX, 2)) + ASSIGN(EDX, ARRAY4(EAX, 3)) + ASSIGN(ESI, ARRAY4(EAX, 4)) + + ASSIGN(ARRAY4(EBP, 80), ESP) + ASSIGN(ESP, EBP) + + /* First Round */ + F1(EAX, EBX, ECX, EDX, ESI, EDI, 0) + F1(EDI, EAX, EBX, ECX, EDX, ESI, 1) + F1(ESI, EDI, EAX, EBX, ECX, EDX, 2) + F1(EDX, ESI, EDI, EAX, EBX, ECX, 3) + F1(ECX, EDX, ESI, EDI, EAX, EBX, 4) + F1(EBX, ECX, EDX, ESI, EDI, EAX, 5) + F1(EAX, EBX, ECX, EDX, ESI, EDI, 6) + F1(EDI, EAX, EBX, ECX, EDX, ESI, 7) + F1(ESI, EDI, EAX, EBX, ECX, EDX, 8) + F1(EDX, ESI, EDI, EAX, EBX, ECX, 9) + F1(ECX, EDX, ESI, EDI, EAX, EBX, 10) + F1(EBX, ECX, EDX, ESI, EDI, EAX, 11) + F1(EAX, EBX, ECX, EDX, ESI, EDI, 12) + F1(EDI, EAX, EBX, ECX, EDX, ESI, 13) + F1(ESI, EDI, EAX, EBX, ECX, EDX, 14) + F1(EDX, ESI, EDI, EAX, EBX, ECX, 15) + F1(ECX, EDX, ESI, EDI, EAX, EBX, 16) + F1(EBX, ECX, EDX, ESI, EDI, EAX, 17) + F1(EAX, EBX, ECX, EDX, ESI, EDI, 18) + F1(EDI, EAX, EBX, ECX, EDX, ESI, 19) + + /* Second Round */ + F2(ESI, EDI, EAX, EBX, ECX, EDX, 20) + F2(EDX, ESI, EDI, EAX, EBX, ECX, 21) + F2(ECX, EDX, ESI, EDI, EAX, EBX, 22) + F2(EBX, ECX, EDX, ESI, EDI, EAX, 23) + F2(EAX, EBX, ECX, EDX, ESI, EDI, 24) + F2(EDI, EAX, EBX, ECX, EDX, ESI, 25) + F2(ESI, EDI, EAX, EBX, ECX, EDX, 26) + F2(EDX, ESI, EDI, EAX, EBX, ECX, 27) + F2(ECX, EDX, ESI, EDI, EAX, EBX, 28) + F2(EBX, ECX, EDX, ESI, EDI, EAX, 29) + F2(EAX, EBX, ECX, EDX, ESI, EDI, 30) + F2(EDI, EAX, EBX, ECX, EDX, ESI, 31) + F2(ESI, EDI, EAX, EBX, ECX, EDX, 32) + F2(EDX, ESI, EDI, EAX, EBX, ECX, 33) + F2(ECX, EDX, ESI, EDI, EAX, EBX, 34) + F2(EBX, ECX, EDX, ESI, EDI, EAX, 35) + F2(EAX, EBX, ECX, EDX, ESI, EDI, 36) + F2(EDI, EAX, EBX, ECX, EDX, ESI, 37) + F2(ESI, EDI, EAX, EBX, ECX, EDX, 38) + F2(EDX, ESI, EDI, EAX, EBX, ECX, 39) + + /* Third Round */ + F3(ECX, EDX, ESI, EDI, EAX, EBX, 40) + F3(EBX, ECX, EDX, ESI, EDI, EAX, 41) + F3(EAX, EBX, ECX, EDX, ESI, EDI, 42) + F3(EDI, EAX, EBX, ECX, EDX, ESI, 43) + F3(ESI, EDI, EAX, EBX, ECX, EDX, 44) + F3(EDX, ESI, EDI, EAX, EBX, ECX, 45) + F3(ECX, EDX, ESI, EDI, EAX, EBX, 46) + F3(EBX, ECX, EDX, ESI, EDI, EAX, 47) + F3(EAX, EBX, ECX, EDX, ESI, EDI, 48) + F3(EDI, EAX, EBX, ECX, EDX, ESI, 49) + F3(ESI, EDI, EAX, EBX, ECX, EDX, 50) + F3(EDX, ESI, EDI, EAX, EBX, ECX, 51) + F3(ECX, EDX, ESI, EDI, EAX, EBX, 52) + F3(EBX, ECX, EDX, ESI, EDI, EAX, 53) + F3(EAX, EBX, ECX, EDX, ESI, EDI, 54) + F3(EDI, EAX, EBX, ECX, EDX, ESI, 55) + F3(ESI, EDI, EAX, EBX, ECX, EDX, 56) + F3(EDX, ESI, EDI, EAX, EBX, ECX, 57) + F3(ECX, EDX, ESI, EDI, EAX, EBX, 58) + F3(EBX, ECX, EDX, ESI, EDI, EAX, 59) + + /* Fourth Round */ + F4(EAX, EBX, ECX, EDX, ESI, EDI, 60) + F4(EDI, EAX, EBX, ECX, EDX, ESI, 61) + F4(ESI, EDI, EAX, EBX, ECX, EDX, 62) + F4(EDX, ESI, EDI, EAX, EBX, ECX, 63) + F4(ECX, EDX, ESI, EDI, EAX, EBX, 64) + F4(EBX, ECX, EDX, ESI, EDI, EAX, 65) + F4(EAX, EBX, ECX, EDX, ESI, EDI, 66) + F4(EDI, EAX, EBX, ECX, EDX, ESI, 67) + F4(ESI, EDI, EAX, EBX, ECX, EDX, 68) + F4(EDX, ESI, EDI, EAX, EBX, ECX, 69) + F4(ECX, EDX, ESI, EDI, EAX, EBX, 70) + F4(EBX, ECX, EDX, ESI, EDI, EAX, 71) + F4(EAX, EBX, ECX, EDX, ESI, EDI, 72) + F4(EDI, EAX, EBX, ECX, EDX, ESI, 73) + F4(ESI, EDI, EAX, EBX, ECX, EDX, 74) + F4(EDX, ESI, EDI, EAX, EBX, ECX, 75) + F4(ECX, EDX, ESI, EDI, EAX, EBX, 76) + F4(EBX, ECX, EDX, ESI, EDI, EAX, 77) + F4(EAX, EBX, ECX, EDX, ESI, EDI, 78) + F4(EDI, EAX, EBX, ECX, EDX, ESI, 79) + + ASSIGN(ESP, ARRAY4(ESP, 80)) + + ASSIGN(EBP, ARG(1)) + ADD(ARRAY4(EBP, 0), EDX) + ADD(ARRAY4(EBP, 1), EDI) + ADD(ARRAY4(EBP, 2), EAX) + ADD(ARRAY4(EBP, 3), EBX) + ADD(ARRAY4(EBP, 4), ECX) + + RESTORE_REGS() +END_FUNCTION(botan_sha160_ia32_compress) -- cgit v1.2.3