Skip to content

Commit 1aaff0e

Browse files
author
Ron Eldor
committed
Return MBEDTLS_ERR_CCM_AUTH_FAILED where needed.
On authentication decryption, when the driver returns the relevant error, return `MBEDTLS_ERR_CCM_AUTH_FAILED`.
1 parent 4e7e054 commit 1aaff0e

File tree

1 file changed

+16
-3
lines changed
  • features/cryptocell/FEATURE_CRYPTOCELL310

1 file changed

+16
-3
lines changed

features/cryptocell/FEATURE_CRYPTOCELL310/ccm_alt.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,23 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
130130

131131
CrysRet = CRYS_AESCCM( SASI_AES_DECRYPT, ctx->cipher_key, ctx->keySize_ID,(uint8_t*)iv, iv_len,
132132
(uint8_t*)add, add_len, (uint8_t*)input, length, output, tag_len, (uint8_t*)tag );
133-
if ( CrysRet != CRYS_OK )
134-
return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
133+
if( CrysRet == CRYS_FATAL_ERROR )
134+
{
135+
/*
136+
* Unfortunately, Crys AESCCM returns CRYS_FATAL_ERROR when
137+
* MAC isn't as expected.
138+
*/
139+
ret = MBEDTLS_ERR_CCM_AUTH_FAILED;
140+
goto exit;
141+
}
142+
else if ( CrysRet != CRYS_OK )
143+
{
144+
ret = MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED;
145+
goto exit;
146+
}
135147

136-
return ( 0 );
148+
exit:
149+
return( ret );
137150

138151
}
139152

0 commit comments

Comments
 (0)