Use PSA_BITS_TO_BYTES macro to convert key bits to bytes
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 44b9c85..0be6ec6 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -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 @@
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 @@
}
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 );