diff -uw rainbowcrack-1.2-src/src/HashAlgorithm.cpp rainbowcrack-1.2-src/src-padlock/HashAlgorithm.cpp --- rainbowcrack-1.2-src/src/HashAlgorithm.cpp 2003-11-23 00:33:22.000000000 +0100 +++ rainbowcrack-1.2-src/src-padlock/HashAlgorithm.cpp 2007-02-10 18:41:11.000000000 +0100 @@ -12,6 +12,8 @@ #ifdef _WIN32 #pragma comment(lib, "libeay32.lib") #endif +#include /* for memcpy() */ +#include /* for bswap_32() used in bswap_shabuffer */ void setup_des_key(unsigned char key_56[], des_key_schedule &ks) { @@ -57,3 +59,81 @@ { SHA1(pPlain, nPlainLen, pHash); } + +/* + Preliminary direct implementation of VIA PadLock Hardware SHA1/SHA256 by eddy at klopper net + + Sample benchmark numbers: + sha1 hash speed: 292397/s sha1 step speed: 248015/s + sha1padlock: 1953125/s sha1padlock step speed: 912408/s + + Extra speed can be achieved by aligning the m_Hash[] member in ChainWalkContext.h + and removing the bswap operations, but then the input must be pre-processed instead. +*/ +struct sha_t +{ + char output[128]; +} __attribute__((aligned(16))); + +inline void padlock_xsha1(unsigned char *pPlain, char *pHash, int nPlainLen) +{ + asm volatile + ( + "xsha1" : "+S"(pPlain), "+D"(pHash) : "c"(nPlainLen), "a"(0) : "memory" + ); +} + + +inline void padlock_xsha256(unsigned char *pPlain, char *pHash, int nPlainLen) +{ + asm volatile + ( + "xsha256" : "+S"(pPlain), "+D"(pHash) : "c"(nPlainLen), "a"(0) : "memory" + ); +} + +inline void bswap_shabuffer(char* src, unsigned char* dest, int len) +{ + int i; + for(i = 0 ; i