mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Generate test wrappers
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
@ -145,6 +145,11 @@ class PSAWrapperGenerator(c_wrapper_generator.Base):
|
||||
# Proof-of-concept: just instrument one function for now
|
||||
if function_name == 'psa_cipher_encrypt':
|
||||
return True
|
||||
if function_name in ('psa_sign_message',
|
||||
'psa_verify_message',
|
||||
'psa_sign_hash',
|
||||
'psa_verify_hash'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _write_function_call(self, out: typing_util.Writable,
|
||||
|
@ -873,7 +873,15 @@ psa_status_t mbedtls_test_wrap_psa_sign_hash(
|
||||
size_t arg5_signature_size,
|
||||
size_t *arg6_signature_length)
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg2_hash, arg3_hash_length);
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_size);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
psa_status_t status = (psa_sign_hash)(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_size, arg6_signature_length);
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg2_hash, arg3_hash_length);
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_size);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -918,7 +926,15 @@ psa_status_t mbedtls_test_wrap_psa_sign_message(
|
||||
size_t arg5_signature_size,
|
||||
size_t *arg6_signature_length)
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length);
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_size);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
psa_status_t status = (psa_sign_message)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_size, arg6_signature_length);
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length);
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_size);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -931,7 +947,15 @@ psa_status_t mbedtls_test_wrap_psa_verify_hash(
|
||||
const uint8_t *arg4_signature,
|
||||
size_t arg5_signature_length)
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg2_hash, arg3_hash_length);
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_length);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
psa_status_t status = (psa_verify_hash)(arg0_key, arg1_alg, arg2_hash, arg3_hash_length, arg4_signature, arg5_signature_length);
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg2_hash, arg3_hash_length);
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_length);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -974,7 +998,15 @@ psa_status_t mbedtls_test_wrap_psa_verify_message(
|
||||
const uint8_t *arg4_signature,
|
||||
size_t arg5_signature_length)
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg2_input, arg3_input_length);
|
||||
MBEDTLS_TEST_MEMORY_POISON(arg4_signature, arg5_signature_length);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
psa_status_t status = (psa_verify_message)(arg0_key, arg1_alg, arg2_input, arg3_input_length, arg4_signature, arg5_signature_length);
|
||||
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg2_input, arg3_input_length);
|
||||
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_signature, arg5_signature_length);
|
||||
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user