mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Old Compiler Warning Cleanup (GCC 4.0.2)
pwdbased.c: Simplified some arithmetic to fix a variable promotion warning.
This commit is contained in:
@ -568,8 +568,6 @@ int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd, int passLen,
|
|||||||
|
|
||||||
/* (2^32 - 1) */
|
/* (2^32 - 1) */
|
||||||
#define SCRYPT_WORD32_MAX 4294967295U
|
#define SCRYPT_WORD32_MAX 4294967295U
|
||||||
/* (2^32 - 1) * 32, used in a couple of scrypt max calculations. */
|
|
||||||
#define SCRYPT_MAX 137438953440UL
|
|
||||||
|
|
||||||
/* One round of Salsa20/8.
|
/* One round of Salsa20/8.
|
||||||
* Code taken from RFC 7914: scrypt PBKDF.
|
* Code taken from RFC 7914: scrypt PBKDF.
|
||||||
@ -760,7 +758,13 @@ int wc_scrypt(byte* output, const byte* passwd, int passLen,
|
|||||||
if (cost < 1 || cost >= 128 * blockSize / 8 || parallel < 1 || dkLen < 1)
|
if (cost < 1 || cost >= 128 * blockSize / 8 || parallel < 1 || dkLen < 1)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
if ((word32)parallel > (SCRYPT_MAX / (128 * blockSize)))
|
/* The following comparison used to be:
|
||||||
|
* ((word32)parallel > (SCRYPT_MAX / (128 * blockSize)))
|
||||||
|
* where SCRYPT_MAX is (2^32 - 1) * 32. For some compilers, the RHS of
|
||||||
|
* the comparison is greater than parallel's type. It wouldn't promote
|
||||||
|
* both sides to word64. What follows is just arithmetic simplification.
|
||||||
|
*/
|
||||||
|
if ((word32)parallel > (SCRYPT_WORD32_MAX / (4 * blockSize)))
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
bSz = 128 * blockSize;
|
bSz = 128 * blockSize;
|
||||||
|
Reference in New Issue
Block a user