Add support for CCM*-no-tag to PSA.
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
diff --git a/library/cipher.c b/library/cipher.c
index dc80189..4ed6c91 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -424,6 +424,31 @@
}
#endif
+#if defined(MBEDTLS_CCM_C)
+ if( MBEDTLS_MODE_CCM == ctx->cipher_info->mode )
+ {
+ int set_lengths_result;
+ int ccm_star_mode;
+
+ set_lengths_result = mbedtls_ccm_set_lengths(
+ (mbedtls_ccm_context *) ctx->cipher_ctx,
+ 0, 0, 0 );
+ if( set_lengths_result != 0 )
+ return set_lengths_result;
+
+ if( ctx->operation == MBEDTLS_DECRYPT )
+ ccm_star_mode = MBEDTLS_CCM_STAR_DECRYPT;
+ else if( ctx->operation == MBEDTLS_ENCRYPT )
+ ccm_star_mode = MBEDTLS_CCM_STAR_ENCRYPT;
+ else
+ return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
+
+ return( mbedtls_ccm_starts( (mbedtls_ccm_context *) ctx->cipher_ctx,
+ ccm_star_mode,
+ iv, iv_len ) );
+ }
+#endif
+
if ( actual_iv_size != 0 )
{
memcpy( ctx->iv, iv, actual_iv_size );
@@ -560,6 +585,15 @@
}
#endif
+#if defined(MBEDTLS_CCM_C)
+ if( ctx->cipher_info->mode == MBEDTLS_MODE_CCM )
+ {
+ return( mbedtls_ccm_update( (mbedtls_ccm_context *) ctx->cipher_ctx,
+ input, ilen,
+ output, ilen, olen ) );
+ }
+#endif
+
#if defined(MBEDTLS_CHACHAPOLY_C)
if ( ctx->cipher_info->type == MBEDTLS_CIPHER_CHACHA20_POLY1305 )
{
@@ -947,6 +981,7 @@
MBEDTLS_MODE_OFB == ctx->cipher_info->mode ||
MBEDTLS_MODE_CTR == ctx->cipher_info->mode ||
MBEDTLS_MODE_GCM == ctx->cipher_info->mode ||
+ MBEDTLS_MODE_CCM == ctx->cipher_info->mode ||
MBEDTLS_MODE_XTS == ctx->cipher_info->mode ||
MBEDTLS_MODE_STREAM == ctx->cipher_info->mode )
{