pkcs_5_alg1 hangs if iterations is 0
guidovranken opened this issue · 0 comments
guidovranken commented
Prerequisites
- Checked the developer manual
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=repo%3Alibtom%2Flibtomcrypt
- Checked that your issue isn't related to TomsFastMath's limitation that PK operations can by default only be done with max. 2048bit keys
Description
pkcs_5_alg1
hangs if iterations
is 0. It would be better to return an error value in this case.
Steps to Reproduce
#include <tomcrypt.h>
#define CF_CHECK_EQ(expr, res) if ( (expr) != (res) ) { goto end; }
#define CF_CHECK_NE(expr, res) if ( (expr) == (res) ) { goto end; }
int main(void)
{
const unsigned char password[8] = { 0 };
const unsigned char salt[8] = { 0 };
unsigned char out[8];
unsigned long outLen = sizeof(out);
CF_CHECK_NE(register_hash(&sha256_desc), -1);
CF_CHECK_EQ(pkcs_5_alg1(
password,
sizeof(password),
salt,
0,
find_hash("sha256"),
out,
&outLen), CRYPT_OK);
end:
return 0;
}
Version
Latest develop
branch checkout, Clang, Linux 64 bit.
Additional Information
N/A