Skip to content

Commit 6da2211

Browse files
rswindellsjaeckel
authored andcommitted
Update rsa_import.c
Bug-fix: MAX_RSA_SIZE is the maximum RSA key size in *bits* (as commented in tomcrypt_custom.h), so the proper conversion to bytes (as the argument value to XCALLOC) would be to divide by 8 (bits per byte), not multiply by 8. This excessive allocation (32 Kbytes instead of 512 bytes) is readily apparent in memory-constrained environments.
1 parent c2f0675 commit 6da2211

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/pk/rsa/rsa_import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key)
4040
}
4141

4242
/* see if the OpenSSL DER format RSA public key will work */
43-
tmpbuf_len = MAX_RSA_SIZE * 8;
43+
tmpbuf_len = MAX_RSA_SIZE / 8;
4444
tmpbuf = XCALLOC(1, tmpbuf_len);
4545
if (tmpbuf == NULL) {
4646
err = CRYPT_MEM;

0 commit comments

Comments
 (0)