mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-16 04:20:49 +00:00
Flip logic of generate_psa_wrappers.py
Change from a long list of PSA functions to a list of excluded false-positives. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
5d64c6acca
commit
5ba3f5f7a5
@ -142,52 +142,14 @@ class PSAWrapperGenerator(c_wrapper_generator.Base):
|
||||
_buffer_name: Optional[str]) -> bool:
|
||||
"""Whether the specified buffer argument to a PSA function should be copied.
|
||||
"""
|
||||
#pylint: disable=too-many-return-statements
|
||||
if function_name in ('psa_sign_hash_start',
|
||||
'psa_sign_hash_complete',
|
||||
'psa_verify_hash_start'):
|
||||
return True
|
||||
if function_name.startswith('psa_pake'):
|
||||
return True
|
||||
if function_name.startswith('psa_aead'):
|
||||
return True
|
||||
if function_name in {'psa_cipher_encrypt', 'psa_cipher_decrypt',
|
||||
'psa_cipher_update', 'psa_cipher_finish',
|
||||
'psa_cipher_generate_iv', 'psa_cipher_set_iv'}:
|
||||
return True
|
||||
if function_name in ('psa_key_derivation_output_bytes',
|
||||
'psa_key_derivation_input_bytes'):
|
||||
return True
|
||||
if function_name in ('psa_import_key',
|
||||
'psa_export_key',
|
||||
'psa_export_public_key'):
|
||||
return True
|
||||
if function_name in ('psa_sign_message',
|
||||
'psa_verify_message',
|
||||
'psa_sign_hash',
|
||||
'psa_verify_hash'):
|
||||
return True
|
||||
if function_name in ('psa_hash_update',
|
||||
'psa_hash_finish',
|
||||
'psa_hash_verify',
|
||||
'psa_hash_compute',
|
||||
'psa_hash_compare'):
|
||||
return True
|
||||
if function_name in ('psa_key_derivation_key_agreement',
|
||||
'psa_raw_key_agreement'):
|
||||
return True
|
||||
if function_name == 'psa_generate_random':
|
||||
return True
|
||||
if function_name in ('psa_mac_update',
|
||||
'psa_mac_sign_finish',
|
||||
'psa_mac_verify_finish',
|
||||
'psa_mac_compute',
|
||||
'psa_mac_verify'):
|
||||
return True
|
||||
if function_name in ('psa_asymmetric_encrypt',
|
||||
'psa_asymmetric_decrypt'):
|
||||
return True
|
||||
return False
|
||||
# False-positives that do not need buffer copying
|
||||
if function_name in ('mbedtls_psa_inject_entropy',
|
||||
'psa_crypto_driver_pake_get_password',
|
||||
'psa_crypto_driver_pake_get_user',
|
||||
'psa_crypto_driver_pake_get_peer'):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def _write_function_call(self, out: typing_util.Writable,
|
||||
function: c_wrapper_generator.FunctionInfo,
|
||||
|
Loading…
x
Reference in New Issue
Block a user