Skip psa encryption/decryption for null cipher
@@ -724,6 +724,9 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
rec->data_len, 0 ) );
#if defined(MBEDTLS_USE_PSA_CRYPTO)
+ /* Skip psa encryption for null cipher */
+ if ( transform->psa_alg != MBEDTLS_SSL_NULL_CIPHER )
+ {
status = psa_cipher_encrypt_setup( &cipher_op,
transform->psa_key_enc, transform->psa_alg );
@@ -750,6 +753,9 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
return( psa_status_to_mbedtls( status ) );
olen += part_len;
+ } else {
+ olen = rec->data_len;
+ }
#else
if( ( ret = mbedtls_cipher_crypt( &transform->cipher_ctx_enc,
transform->iv_enc, transform->ivlen,
@@ -1135,6 +1141,9 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
#endif /* MBEDTLS_USE_PSA_CRYPTO */
#if defined(MBEDTLS_USE_PSA_CRYPTO)
+ /* Skip psa decryption for null cipher */
+ if ( transform->psa_alg != MBEDTLS_SSL_NULL_CIPHER )
+ {
status = psa_cipher_decrypt_setup( &cipher_op,
transform->psa_key_dec, transform->psa_alg );
@@ -1161,6 +1170,9 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
return( psa_status_to_mbedtls( status ) );
olen += part_len;
+ } else {
+ olen = rec->data_len;
+ }
#else
if( ( ret = mbedtls_cipher_crypt( &transform->cipher_ctx_dec,
