mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-24 06:02:44 +00:00
Add memory poisoning hooks
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
dbbfdabfd8
commit
372b8bb6c5
@ -329,7 +329,8 @@ foreach(target IN LISTS target_libraries)
|
|||||||
$<INSTALL_INTERFACE:include/>
|
$<INSTALL_INTERFACE:include/>
|
||||||
PRIVATE ${MBEDTLS_DIR}/library/
|
PRIVATE ${MBEDTLS_DIR}/library/
|
||||||
# Needed to include psa_crypto_driver_wrappers.h
|
# Needed to include psa_crypto_driver_wrappers.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR})
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${MBEDTLS_DIR}/tests/include/)
|
||||||
# Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE
|
# Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE
|
||||||
if(MBEDTLS_CONFIG_FILE)
|
if(MBEDTLS_CONFIG_FILE)
|
||||||
target_compile_definitions(${target}
|
target_compile_definitions(${target}
|
||||||
|
@ -72,6 +72,10 @@
|
|||||||
#include "mbedtls/sha512.h"
|
#include "mbedtls/sha512.h"
|
||||||
#include "md_psa.h"
|
#include "md_psa.h"
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
#include "test/memory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) || \
|
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) || \
|
||||||
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT) || \
|
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT) || \
|
||||||
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND)
|
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND)
|
||||||
@ -8451,10 +8455,18 @@ psa_status_t psa_crypto_copy_input(const uint8_t *input, size_t input_len,
|
|||||||
return PSA_ERROR_CORRUPTION_DETECTED;
|
return PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(input, input_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (input_len > 0) {
|
if (input_len > 0) {
|
||||||
memcpy(input_copy, input, input_len);
|
memcpy(input_copy, input, input_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(input, input_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
return PSA_SUCCESS;
|
return PSA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8478,10 +8490,18 @@ psa_status_t psa_crypto_copy_output(const uint8_t *output_copy, size_t output_co
|
|||||||
return PSA_ERROR_BUFFER_TOO_SMALL;
|
return PSA_ERROR_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(output, output_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (output_copy_len > 0) {
|
if (output_copy_len > 0) {
|
||||||
memcpy(output, output_copy, output_copy_len);
|
memcpy(output, output_copy, output_copy_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(output, output_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
return PSA_SUCCESS;
|
return PSA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user