mirror of
https://github.com/cuberite/polarssl.git
synced 2025-10-01 09:31:25 -04:00
Generate poisoning wrappers for AEAD
Modify wrapper generation script to generate poisoning calls and regenerate wrappers. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
18dc032fb4
commit
86e6fe0cce
@ -142,7 +142,8 @@ class PSAWrapperGenerator(c_wrapper_generator.Base):
|
|||||||
_buffer_name: Optional[str]) -> bool:
|
_buffer_name: Optional[str]) -> bool:
|
||||||
"""Whether the specified buffer argument to a PSA function should be copied.
|
"""Whether the specified buffer argument to a PSA function should be copied.
|
||||||
"""
|
"""
|
||||||
# Proof-of-concept: just instrument one function for now
|
if function_name.startswith('psa_aead'):
|
||||||
|
return True
|
||||||
if function_name == 'psa_cipher_encrypt':
|
if function_name == 'psa_cipher_encrypt':
|
||||||
return True
|
return True
|
||||||
if function_name in ('psa_import_key',
|
if function_name in ('psa_import_key',
|
||||||
|
@ -70,7 +70,19 @@ psa_status_t mbedtls_test_wrap_psa_aead_decrypt(
|
|||||||
size_t arg9_plaintext_size,
|
size_t arg9_plaintext_size,
|
||||||
size_t *arg10_plaintext_length)
|
size_t *arg10_plaintext_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg2_nonce, arg3_nonce_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg4_additional_data, arg5_additional_data_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg6_ciphertext, arg7_ciphertext_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg8_plaintext, arg9_plaintext_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_decrypt)(arg0_key, arg1_alg, arg2_nonce, arg3_nonce_length, arg4_additional_data, arg5_additional_data_length, arg6_ciphertext, arg7_ciphertext_length, arg8_plaintext, arg9_plaintext_size, arg10_plaintext_length);
|
psa_status_t status = (psa_aead_decrypt)(arg0_key, arg1_alg, arg2_nonce, arg3_nonce_length, arg4_additional_data, arg5_additional_data_length, arg6_ciphertext, arg7_ciphertext_length, arg8_plaintext, arg9_plaintext_size, arg10_plaintext_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg2_nonce, arg3_nonce_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_additional_data, arg5_additional_data_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg6_ciphertext, arg7_ciphertext_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg8_plaintext, arg9_plaintext_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +110,19 @@ psa_status_t mbedtls_test_wrap_psa_aead_encrypt(
|
|||||||
size_t arg9_ciphertext_size,
|
size_t arg9_ciphertext_size,
|
||||||
size_t *arg10_ciphertext_length)
|
size_t *arg10_ciphertext_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg2_nonce, arg3_nonce_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg4_additional_data, arg5_additional_data_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg6_plaintext, arg7_plaintext_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg8_ciphertext, arg9_ciphertext_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_encrypt)(arg0_key, arg1_alg, arg2_nonce, arg3_nonce_length, arg4_additional_data, arg5_additional_data_length, arg6_plaintext, arg7_plaintext_length, arg8_ciphertext, arg9_ciphertext_size, arg10_ciphertext_length);
|
psa_status_t status = (psa_aead_encrypt)(arg0_key, arg1_alg, arg2_nonce, arg3_nonce_length, arg4_additional_data, arg5_additional_data_length, arg6_plaintext, arg7_plaintext_length, arg8_ciphertext, arg9_ciphertext_size, arg10_ciphertext_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg2_nonce, arg3_nonce_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_additional_data, arg5_additional_data_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg6_plaintext, arg7_plaintext_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg8_ciphertext, arg9_ciphertext_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +146,15 @@ psa_status_t mbedtls_test_wrap_psa_aead_finish(
|
|||||||
size_t arg5_tag_size,
|
size_t arg5_tag_size,
|
||||||
size_t *arg6_tag_length)
|
size_t *arg6_tag_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg1_ciphertext, arg2_ciphertext_size);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg4_tag, arg5_tag_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_finish)(arg0_operation, arg1_ciphertext, arg2_ciphertext_size, arg3_ciphertext_length, arg4_tag, arg5_tag_size, arg6_tag_length);
|
psa_status_t status = (psa_aead_finish)(arg0_operation, arg1_ciphertext, arg2_ciphertext_size, arg3_ciphertext_length, arg4_tag, arg5_tag_size, arg6_tag_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg1_ciphertext, arg2_ciphertext_size);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_tag, arg5_tag_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +165,13 @@ psa_status_t mbedtls_test_wrap_psa_aead_generate_nonce(
|
|||||||
size_t arg2_nonce_size,
|
size_t arg2_nonce_size,
|
||||||
size_t *arg3_nonce_length)
|
size_t *arg3_nonce_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg1_nonce, arg2_nonce_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_generate_nonce)(arg0_operation, arg1_nonce, arg2_nonce_size, arg3_nonce_length);
|
psa_status_t status = (psa_aead_generate_nonce)(arg0_operation, arg1_nonce, arg2_nonce_size, arg3_nonce_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg1_nonce, arg2_nonce_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +191,13 @@ psa_status_t mbedtls_test_wrap_psa_aead_set_nonce(
|
|||||||
const uint8_t *arg1_nonce,
|
const uint8_t *arg1_nonce,
|
||||||
size_t arg2_nonce_length)
|
size_t arg2_nonce_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg1_nonce, arg2_nonce_length);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_set_nonce)(arg0_operation, arg1_nonce, arg2_nonce_length);
|
psa_status_t status = (psa_aead_set_nonce)(arg0_operation, arg1_nonce, arg2_nonce_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg1_nonce, arg2_nonce_length);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +210,15 @@ psa_status_t mbedtls_test_wrap_psa_aead_update(
|
|||||||
size_t arg4_output_size,
|
size_t arg4_output_size,
|
||||||
size_t *arg5_output_length)
|
size_t *arg5_output_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg3_output, arg4_output_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_update)(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length);
|
psa_status_t status = (psa_aead_update)(arg0_operation, arg1_input, arg2_input_length, arg3_output, arg4_output_size, arg5_output_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg3_output, arg4_output_size);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +228,13 @@ psa_status_t mbedtls_test_wrap_psa_aead_update_ad(
|
|||||||
const uint8_t *arg1_input,
|
const uint8_t *arg1_input,
|
||||||
size_t arg2_input_length)
|
size_t arg2_input_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg1_input, arg2_input_length);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_update_ad)(arg0_operation, arg1_input, arg2_input_length);
|
psa_status_t status = (psa_aead_update_ad)(arg0_operation, arg1_input, arg2_input_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg1_input, arg2_input_length);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +247,15 @@ psa_status_t mbedtls_test_wrap_psa_aead_verify(
|
|||||||
const uint8_t *arg4_tag,
|
const uint8_t *arg4_tag,
|
||||||
size_t arg5_tag_length)
|
size_t arg5_tag_length)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg1_plaintext, arg2_plaintext_size);
|
||||||
|
MBEDTLS_TEST_MEMORY_POISON(arg4_tag, arg5_tag_length);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
psa_status_t status = (psa_aead_verify)(arg0_operation, arg1_plaintext, arg2_plaintext_size, arg3_plaintext_length, arg4_tag, arg5_tag_length);
|
psa_status_t status = (psa_aead_verify)(arg0_operation, arg1_plaintext, arg2_plaintext_size, arg3_plaintext_length, arg4_tag, arg5_tag_length);
|
||||||
|
#if defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg1_plaintext, arg2_plaintext_size);
|
||||||
|
MBEDTLS_TEST_MEMORY_UNPOISON(arg4_tag, arg5_tag_length);
|
||||||
|
#endif /* defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS) */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user