forked from wolfSSL/wolfssl
Check memory is zeroized
Add a define WOLFSSL_CHECK_MEM_ZERO to turn on code that checks that memory that must be zeroized before going out of use is zero. Everytime sensitive data is put into a allocated buffer or stack buffer; the address, its length and a name is stored to be checked later. Where the stack buffer is about to go out of use, a call is added to check that the required parts are zero. wc_MemZero_Add() adds an address with length and name to a table of addressed to be checked later. wc_MemZero_Check() checks that the memory associated with the address is zeroized where required. mp_memzero_add() adds mp_int's data pointer with length and name to table. mp_memzero_check() checks that the data pointer is zeroized where required. Freeing memory will check the address. The length was prepended on allocation. Realloction was changed for WOLFSSL_CHECK_MEM_ZERO to perform an allocate, check, copy, free.
This commit is contained in:
@@ -19107,6 +19107,10 @@ static int test_wc_RsaKeyToDer (void)
|
||||
/* Try Public Key. */
|
||||
genKey.type = 0;
|
||||
ret = wc_RsaKeyToDer(&genKey, der, FOURK_BUF);
|
||||
#ifdef WOLFSSL_CHECK_MEM_ZERO
|
||||
/* Put back to Private Key */
|
||||
genKey.type = 1;
|
||||
#endif
|
||||
}
|
||||
if (ret == BAD_FUNC_ARG) {
|
||||
ret = 0;
|
||||
@@ -19126,6 +19130,10 @@ static int test_wc_RsaKeyToDer (void)
|
||||
/* Try Public Key. */
|
||||
genKey.type = 0;
|
||||
ret = wc_RsaKeyToDer(&genKey, der, FOURK_BUF);
|
||||
#ifdef WOLFSSL_CHECK_MEM_ZERO
|
||||
/* Put back to Private Key */
|
||||
genKey.type = 1;
|
||||
#endif
|
||||
}
|
||||
if (ret == USER_CRYPTO_ERROR) {
|
||||
ret = 0;
|
||||
|
Reference in New Issue
Block a user