mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-07 22:27:01 -04:00
Generate test wrappers
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
290aac472a
commit
c63e31af8b
@ -153,6 +153,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,
|
||||
|
@ -602,7 +602,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;
|
||||
}
|
||||
|
||||
@ -616,7 +624,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;
|
||||
}
|
||||
|
||||
@ -629,7 +645,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;
|
||||
}
|
||||
|
||||
@ -642,7 +666,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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user