mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-02 07:20:26 +00:00
Remove SetLengths() requirement for GCM
Also return NOT_SUPPORTED, rather than BAD_STATE for our current workarounds for GCM/CCM Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
9e8ccd7e82
commit
c10ad21a1b
@ -509,15 +509,12 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t
|
|||||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
|
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
|
||||||
if( operation->alg == PSA_ALG_GCM )
|
if( operation->alg == PSA_ALG_GCM )
|
||||||
{
|
{
|
||||||
if( !operation->lengths_set || operation->ad_started )
|
/* GCM currently requires all the additional data to be passed in in
|
||||||
return( PSA_ERROR_BAD_STATE );
|
|
||||||
|
|
||||||
/* GCM currently requires all the additional data to be passed in in
|
|
||||||
* one contiguous buffer, so until that is re-done, we have to enforce
|
* one contiguous buffer, so until that is re-done, we have to enforce
|
||||||
* this, as we cannot allocate a buffer to collate multiple calls into.
|
* this, as we cannot allocate a buffer to collate multiple calls into.
|
||||||
*/
|
*/
|
||||||
if( operation->ad_remaining != 0 )
|
if( operation->ad_started )
|
||||||
return ( PSA_ERROR_INVALID_ARGUMENT );
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
status = mbedtls_to_psa_error(
|
status = mbedtls_to_psa_error(
|
||||||
mbedtls_gcm_starts( &operation->ctx.gcm,
|
mbedtls_gcm_starts( &operation->ctx.gcm,
|
||||||
@ -537,7 +534,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t
|
|||||||
/* CCM requires all additional data to be passed in in one go at the
|
/* CCM requires all additional data to be passed in in one go at the
|
||||||
minute, as we are basically operating in oneshot mode. */
|
minute, as we are basically operating in oneshot mode. */
|
||||||
if( operation->ad_started )
|
if( operation->ad_started )
|
||||||
return( PSA_ERROR_BAD_STATE );
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
/* Save the additional data for later, this will be passed in
|
/* Save the additional data for later, this will be passed in
|
||||||
when we have the body. */
|
when we have the body. */
|
||||||
@ -617,11 +614,9 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation,
|
|||||||
* must be passed in in one update, rather than deal with the complexity
|
* must be passed in in one update, rather than deal with the complexity
|
||||||
* of non block size aligned updates. This will be fixed in 3.0 when
|
* of non block size aligned updates. This will be fixed in 3.0 when
|
||||||
we can change the signature of the GCM multipart functions */
|
we can change the signature of the GCM multipart functions */
|
||||||
if( !operation->lengths_set || operation->body_remaining != 0 )
|
if( operation->body_started )
|
||||||
return( PSA_ERROR_BAD_STATE );
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
if( !operation->ad_started )
|
|
||||||
return( PSA_ERROR_BAD_STATE );
|
|
||||||
|
|
||||||
status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm,
|
status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm,
|
||||||
input_length,
|
input_length,
|
||||||
@ -636,7 +631,7 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation,
|
|||||||
/* CCM does not support multipart yet, so all the input has to be
|
/* CCM does not support multipart yet, so all the input has to be
|
||||||
passed in in one go. */
|
passed in in one go. */
|
||||||
if( operation->body_started )
|
if( operation->body_started )
|
||||||
return( PSA_ERROR_BAD_STATE );
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
/* Need to store tag for Finish() / Verify() */
|
/* Need to store tag for Finish() / Verify() */
|
||||||
operation->tag_buffer =
|
operation->tag_buffer =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user