Use PSA_BITS_TO_BYTES macro to convert key bits to bytes

Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemyslaw Stekiel 2022-01-12 10:42:58 +01:00
parent ae77b0ab28
commit 11a33e6d90
2 changed files with 4 additions and 11 deletions

View file

@ -56,9 +56,6 @@
#include "mbedtls/oid.h"
#endif
/* Convert key bits to byte size */
#define KEY_BYTES( bits ) ( ( (size_t) bits + 7 ) / 8 )
#if defined(MBEDTLS_SSL_PROTO_DTLS)
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
@ -1106,7 +1103,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform,
if( ( status = psa_import_key( &attributes,
key1,
KEY_BYTES( key_bits ),
PSA_BITS_TO_BYTES( key_bits ),
&transform->psa_key_enc ) ) != PSA_SUCCESS )
{
MBEDTLS_SSL_DEBUG_RET( 1, "psa_import_key", status );
@ -1114,7 +1111,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform,
}
if( ( status = psa_import_key( &attributes,
key2,
KEY_BYTES( key_bits ),
PSA_BITS_TO_BYTES( key_bits ),
&transform->psa_key_dec ) ) != PSA_SUCCESS )
{
MBEDTLS_SSL_DEBUG_RET( 1, "psa_import_key", status );

View file

@ -31,10 +31,6 @@
#include "ssl_misc.h"
#include "ssl_tls13_keys.h"
/* Convert key bits to byte size */
#define KEY_BYTES( bits ) ( ( (size_t) bits + 7 ) / 8 )
#define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \
.name = string,
@ -937,7 +933,7 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform,
if( ( status = psa_import_key( &attributes,
key_enc,
KEY_BYTES( key_bits ),
PSA_BITS_TO_BYTES( key_bits ),
&transform->psa_key_enc ) ) != PSA_SUCCESS )
{
MBEDTLS_SSL_DEBUG_RET( 1, "psa_import_key", status );
@ -945,7 +941,7 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform,
}
if( ( status = psa_import_key( &attributes,
key_dec,
KEY_BYTES( key_bits ),
PSA_BITS_TO_BYTES( key_bits ),
&transform->psa_key_dec ) ) != PSA_SUCCESS )
{
MBEDTLS_SSL_DEBUG_RET( 1, "psa_import_key", status );