Skip to content

Commit

Permalink
Bug 1182667 - Fixing unoptimized byteswap
Browse files Browse the repository at this point in the history
  • Loading branch information
martinthomson committed Aug 20, 2015
1 parent e0d7912 commit 366fad3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions lib/freebl/sha512.c
Expand Up @@ -72,7 +72,6 @@ static const PRUint32 H256[8] = {
#include <stdlib.h>
#pragma intrinsic(_byteswap_ulong)
#define SHA_HTONL(x) _byteswap_ulong(x)
#define BYTESWAP4(x) x = SHA_HTONL(x)
#elif defined(_MSC_VER) && defined(NSS_X86_OR_X64)
#ifndef FORCEINLINE
#if (_MSC_VER >= 1200)
Expand All @@ -93,7 +92,6 @@ swap4b(PRUint32 dwd)
}

#define SHA_HTONL(x) swap4b(x)
#define BYTESWAP4(x) x = SHA_HTONL(x)

#elif defined(__GNUC__) && defined(NSS_X86_OR_X64)
static __inline__ PRUint32 swap4b(PRUint32 value)
Expand All @@ -102,7 +100,6 @@ static __inline__ PRUint32 swap4b(PRUint32 value)
return (value);
}
#define SHA_HTONL(x) swap4b(x)
#define BYTESWAP4(x) x = SHA_HTONL(x)

#elif defined(__GNUC__) && (defined(__thumb2__) || \
(!defined(__thumb__) && \
Expand All @@ -122,18 +119,17 @@ static __inline__ PRUint32 swap4b(PRUint32 value)
return ret;
}
#define SHA_HTONL(x) swap4b(x)
#define BYTESWAP4(x) x = SHA_HTONL(x)

#else
#define SWAP4MASK 0x00FF00FF
static PRUint32 swap4b(PRUint32 value)
{
PRUint32 t1 = (x << 16) | (x >> 16);
PRUint32 t1 = (value << 16) | (value >> 16);
return ((t1 & SWAP4MASK) << 8) | ((t1 >> 8) & SWAP4MASK);
}
#define SHA_HTONL(x) swap4b
#define BYTESWAP4(x) x = SHA_HTONL(x)
#endif
#define BYTESWAP4(x) x = SHA_HTONL(x)
#endif /* defined(IS_LITTLE_ENDIAN) */

#if defined(_MSC_VER)
Expand Down
4 changes: 2 additions & 2 deletions lib/softoken/pkcs11c.c
Expand Up @@ -3840,7 +3840,7 @@ CK_RV NSC_GenerateKey(CK_SESSION_HANDLE hSession,
* produce them any more. The affected algorithm was 3DES.
*/
PRBool faultyPBE3DES = PR_FALSE;
HASH_HashType hashType;
HASH_HashType hashType = HASH_AlgNULL;

CHECK_FORK();

Expand Down Expand Up @@ -4081,7 +4081,7 @@ sftk_PairwiseConsistencyCheck(CK_SESSION_HANDLE hSession,
*/
CK_MECHANISM mech = {0, NULL, 0};

CK_ULONG modulusLen;
CK_ULONG modulusLen = 0;
CK_ULONG subPrimeLen = 0;
PRBool isEncryptable = PR_FALSE;
PRBool canSignVerify = PR_FALSE;
Expand Down

0 comments on commit 366fad3

Please sign in to comment.