diff options
author | nelsonb%netscape.com <devnull@localhost> | 2002-11-02 01:53:01 +0000 |
---|---|---|
committer | nelsonb%netscape.com <devnull@localhost> | 2002-11-02 01:53:01 +0000 |
commit | aab6e04fb21d21de6432a5dc1b2d984dc1f05d99 (patch) | |
tree | e9b2bdd5c50cc2d6169b3f1cecffde82e7347503 | |
parent | c32ba0c2f4037f31f3a7d1b9328098bd32b9dd82 (diff) | |
download | nss-hg-aab6e04fb21d21de6432a5dc1b2d984dc1f05d99.tar.gz |
Add some processor and compiler dependent optimizations to SHA1.
-rw-r--r-- | security/nss/lib/freebl/sha_fast.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/security/nss/lib/freebl/sha_fast.c b/security/nss/lib/freebl/sha_fast.c index 655f5c3e6..52589a5ae 100644 --- a/security/nss/lib/freebl/sha_fast.c +++ b/security/nss/lib/freebl/sha_fast.c @@ -42,12 +42,40 @@ #include "ssltrace.h" #endif +#if defined(IS_LITTLE_ENDIAN) && defined(_MSC_VER) && defined(_X86_) +#undef SHA_HTONL +#ifndef FORCEINLINE +#if (MSC_VER >= 1200) +#define FORCEINLINE __forceinline +#else +#define FORCEINLINE __inline +#endif +#endif +#define FASTCALL __fastcall + +static FORCEINLINE PRUint32 FASTCALL +swap4b(PRUint32 dwd) +{ + __asm { + mov eax,dwd + bswap eax + } +} + +#define SHA_HTONL(x) swap4b(x) +#endif + static void shaCompress(SHA1Context *ctx); #define W u.w #define B u.b +#if defined(_MSC_VER) && defined(_X86_) +#pragma intrinsic (_lrotr, _lrotl) +#define SHA_ROTL(x,n) _lrotl(x,n) +#else #define SHA_ROTL(X,n) (((X) << (n)) | ((X) >> (32-(n)))) +#endif #define SHA_F1(X,Y,Z) ((((Y)^(Z))&(X))^(Z)) #define SHA_F2(X,Y,Z) ((X)^(Y)^(Z)) #define SHA_F3(X,Y,Z) (((X)&(Y))|((Z)&((X)|(Y)))) @@ -72,7 +100,6 @@ SHA1_Begin(SHA1Context *ctx) ctx->H[2] = 0x98badcfeL; ctx->H[3] = 0x10325476L; ctx->H[4] = 0xc3d2e1f0L; - } |