From 99a507ee55e0969ee49c33584f0a6eeaf68c2f4c Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 22 Nov 2022 16:54:54 +0000 Subject: [PATCH] Use mbedtls_xor in md Signed-off-by: Dave Rodgman --- library/md.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/library/md.c b/library/md.c index 8efcf105b..9c161a53f 100644 --- a/library/md.c +++ b/library/md.c @@ -633,7 +633,6 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char sum[MBEDTLS_MD_MAX_SIZE]; unsigned char *ipad, *opad; - size_t i; if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); @@ -657,11 +656,8 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, memset( ipad, 0x36, ctx->md_info->block_size ); memset( opad, 0x5C, ctx->md_info->block_size ); - for( i = 0; i < keylen; i++ ) - { - ipad[i] = (unsigned char)( ipad[i] ^ key[i] ); - opad[i] = (unsigned char)( opad[i] ^ key[i] ); - } + mbedtls_xor( ipad, ipad, key, keylen ); + mbedtls_xor( opad, opad, key, keylen ); if( ( ret = mbedtls_md_starts( ctx ) ) != 0 ) goto cleanup;