Changed every memcmp to SCA equivalent mbedtls_platform_memcmp
This makes physical attacks more difficult.
Selftest memcmp functions were not changed.
diff --git a/library/asn1parse.c b/library/asn1parse.c
index aac253b..806724d 100644
--- a/library/asn1parse.c
+++ b/library/asn1parse.c
@@ -431,7 +431,7 @@
while( list != NULL )
{
if( list->oid.len == len &&
- memcmp( list->oid.p, oid, len ) == 0 )
+ mbedtls_platform_memcmp( list->oid.p, oid, len ) == 0 )
{
break;
}
diff --git a/library/asn1write.c b/library/asn1write.c
index c0b4622..6e5badb 100644
--- a/library/asn1write.c
+++ b/library/asn1write.c
@@ -347,7 +347,7 @@
while( list != NULL )
{
if( list->oid.len == len &&
- memcmp( list->oid.p, oid, len ) == 0 )
+ mbedtls_platform_memcmp( list->oid.p, oid, len ) == 0 )
{
break;
}
diff --git a/library/base64.c b/library/base64.c
index f06b57b..1e9f6d7 100644
--- a/library/base64.c
+++ b/library/base64.c
@@ -260,7 +260,7 @@
src = base64_test_dec;
if( mbedtls_base64_encode( buffer, sizeof( buffer ), &len, src, 64 ) != 0 ||
- memcmp( base64_test_enc, buffer, 88 ) != 0 )
+ memcmp( base64_test_enc, buffer, 88 ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
@@ -274,7 +274,7 @@
src = base64_test_enc;
if( mbedtls_base64_decode( buffer, sizeof( buffer ), &len, src, 88 ) != 0 ||
- memcmp( base64_test_dec, buffer, 64 ) != 0 )
+ memcmp( base64_test_dec, buffer, 64 ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
diff --git a/library/ccm.c b/library/ccm.c
index c6211ee..94ebd97 100644
--- a/library/ccm.c
+++ b/library/ccm.c
@@ -505,7 +505,7 @@
ciphertext + msg_len[i], tag_len[i] );
if( ret != 0 ||
- memcmp( ciphertext, res[i], msg_len[i] + tag_len[i] ) != 0 )
+ memcmp( ciphertext, res[i], msg_len[i] + tag_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
@@ -520,7 +520,7 @@
ciphertext + msg_len[i], tag_len[i] );
if( ret != 0 ||
- memcmp( plaintext, msg, msg_len[i] ) != 0 )
+ memcmp( plaintext, msg, msg_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
diff --git a/library/cmac.c b/library/cmac.c
index 5d101e1..cc0a4a7 100644
--- a/library/cmac.c
+++ b/library/cmac.c
@@ -902,7 +902,7 @@
mbedtls_printf( " AES CMAC 128 PRF #%u: ", i );
ret = mbedtls_aes_cmac_prf_128( PRFK, PRFKlen[i], PRFM, 20, output );
if( ret != 0 ||
- memcmp( output, PRFT[i], MBEDTLS_AES_BLOCK_SIZE ) != 0 )
+ memcmp( output, PRFT[i], MBEDTLS_AES_BLOCK_SIZE ) != 0 )
{
if( verbose != 0 )
diff --git a/library/des.c b/library/des.c
index 8a33d82..f61545e 100644
--- a/library/des.c
+++ b/library/des.c
@@ -417,7 +417,7 @@
int i;
for( i = 0; i < WEAK_KEY_COUNT; i++ )
- if( memcmp( weak_key_table[i], key, MBEDTLS_DES_KEY_SIZE) == 0 )
+ if( mbedtls_platform_memcmp( weak_key_table[i], key, MBEDTLS_DES_KEY_SIZE) == 0 )
return( 1 );
return( 0 );
@@ -939,7 +939,7 @@
if( ( v == MBEDTLS_DES_DECRYPT &&
memcmp( buf, des3_test_ecb_dec[u], 8 ) != 0 ) ||
( v != MBEDTLS_DES_DECRYPT &&
- memcmp( buf, des3_test_ecb_enc[u], 8 ) != 0 ) )
+ memcmp( buf, des3_test_ecb_enc[u], 8 ) != 0 ) )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
@@ -1035,7 +1035,7 @@
if( ( v == MBEDTLS_DES_DECRYPT &&
memcmp( buf, des3_test_cbc_dec[u], 8 ) != 0 ) ||
( v != MBEDTLS_DES_DECRYPT &&
- memcmp( buf, des3_test_cbc_enc[u], 8 ) != 0 ) )
+ memcmp( buf, des3_test_cbc_enc[u], 8 ) != 0 ) )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
diff --git a/library/gcm.c b/library/gcm.c
index 675926a..95586ea 100644
--- a/library/gcm.c
+++ b/library/gcm.c
@@ -823,7 +823,7 @@
goto exit;
if ( memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 ||
- memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
+ memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
ret = 1;
goto exit;
@@ -855,7 +855,7 @@
goto exit;
if( memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 ||
- memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
+ memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
ret = 1;
goto exit;
@@ -907,7 +907,7 @@
goto exit;
if( memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 ||
- memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
+ memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
ret = 1;
goto exit;
@@ -960,7 +960,7 @@
goto exit;
if( memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 ||
- memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
+ memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
ret = 1;
goto exit;
diff --git a/library/nist_kw.c b/library/nist_kw.c
index 317a242..345a24d 100644
--- a/library/nist_kw.c
+++ b/library/nist_kw.c
@@ -651,7 +651,7 @@
ret = mbedtls_nist_kw_wrap( &ctx, MBEDTLS_KW_MODE_KW, kw_msg[i],
kw_msg_len[i], out, &olen, sizeof( out ) );
if( ret != 0 || kw_out_len[i] != olen ||
- memcmp( out, kw_res[i], kw_out_len[i] ) != 0 )
+ memcmp( out, kw_res[i], kw_out_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed. ");
@@ -674,7 +674,7 @@
out, olen, out, &olen, sizeof( out ) );
if( ret != 0 || olen != kw_msg_len[i] ||
- memcmp( out, kw_msg[i], kw_msg_len[i] ) != 0 )
+ memcmp( out, kw_msg[i], kw_msg_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
@@ -706,7 +706,7 @@
kwp_msg_len[i], out, &olen, sizeof( out ) );
if( ret != 0 || kwp_out_len[i] != olen ||
- memcmp( out, kwp_res[i], kwp_out_len[i] ) != 0 )
+ memcmp( out, kwp_res[i], kwp_out_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed. ");
@@ -729,7 +729,7 @@
olen, out, &olen, sizeof( out ) );
if( ret != 0 || olen != kwp_msg_len[i] ||
- memcmp( out, kwp_msg[i], kwp_msg_len[i] ) != 0 )
+ memcmp( out, kwp_msg[i], kwp_msg_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed. ");
diff --git a/library/oid.c b/library/oid.c
index abe7bc7..00a02c3 100644
--- a/library/oid.c
+++ b/library/oid.c
@@ -75,7 +75,7 @@
if( p == NULL || oid == NULL ) return( NULL ); \
while( cur->asn1 != NULL ) { \
if( cur->asn1_len == oid->len && \
- memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \
+ mbedtls_platform_memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \
return( p ); \
} \
p++; \
diff --git a/library/pem.c b/library/pem.c
index 897c8a0..4b99664 100644
--- a/library/pem.c
+++ b/library/pem.c
@@ -273,7 +273,7 @@
enc = 0;
- if( s2 - s1 >= 22 && memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
+ if( s2 - s1 >= 22 && mbedtls_platform_memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
{
#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
@@ -286,7 +286,7 @@
#if defined(MBEDTLS_DES_C)
- if( s2 - s1 >= 23 && memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
+ if( s2 - s1 >= 23 && mbedtls_platform_memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
{
enc_alg = MBEDTLS_CIPHER_DES_EDE3_CBC;
@@ -296,7 +296,7 @@
s1 += 16;
}
- else if( s2 - s1 >= 18 && memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
+ else if( s2 - s1 >= 18 && mbedtls_platform_memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
{
enc_alg = MBEDTLS_CIPHER_DES_CBC;
@@ -309,15 +309,15 @@
#endif /* MBEDTLS_DES_C */
#if defined(MBEDTLS_AES_C)
- if( s2 - s1 >= 14 && memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
+ if( s2 - s1 >= 14 && mbedtls_platform_memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
{
if( s2 - s1 < 22 )
return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
- else if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
+ else if( mbedtls_platform_memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
enc_alg = MBEDTLS_CIPHER_AES_128_CBC;
- else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 )
+ else if( mbedtls_platform_memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 )
enc_alg = MBEDTLS_CIPHER_AES_192_CBC;
- else if( memcmp( s1, "DEK-Info: AES-256-CBC,", 22 ) == 0 )
+ else if( mbedtls_platform_memcmp( s1, "DEK-Info: AES-256-CBC,", 22 ) == 0 )
enc_alg = MBEDTLS_CIPHER_AES_256_CBC;
else
return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
diff --git a/library/pk.c b/library/pk.c
index fb563d0..fbcaa5d 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -556,7 +556,7 @@
const mbedtls_uecc_keypair *uecc_prv =
(const mbedtls_uecc_keypair *) prv;
- if( memcmp( uecc_pub->public_key,
+ if( mbedtls_platform_memcmp( uecc_pub->public_key,
uecc_prv->public_key,
2 * NUM_ECC_BYTES ) == 0 )
{
diff --git a/library/pkcs5.c b/library/pkcs5.c
index a517778..f6610e7 100644
--- a/library/pkcs5.c
+++ b/library/pkcs5.c
@@ -383,7 +383,7 @@
ret = mbedtls_pkcs5_pbkdf2_hmac( &sha1_ctx, password[i], plen[i], salt[i],
slen[i], it_cnt[i], key_len[i], key );
if( ret != 0 ||
- memcmp( result_key[i], key, key_len[i] ) != 0 )
+ memcmp( result_key[i], key, key_len[i] ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
diff --git a/library/pkparse.c b/library/pkparse.c
index 4cff8d7..f567b17 100644
--- a/library/pkparse.c
+++ b/library/pkparse.c
@@ -309,7 +309,7 @@
return( ret );
if( len != MBEDTLS_OID_SIZE( MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD ) ||
- memcmp( p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len ) != 0 )
+ mbedtls_platform_memcmp( p, MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD, len ) != 0 )
{
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
}
diff --git a/library/rsa.c b/library/rsa.c
index 3bfc73e..e3d5124 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -2266,7 +2266,7 @@
if ( ret != 0 )
goto exit;
- if( memcmp( hash_start, result, hlen ) != 0 )
+ if( mbedtls_platform_memcmp( hash_start, result, hlen ) != 0 )
{
ret = MBEDTLS_ERR_RSA_VERIFY_FAILED;
goto exit;
diff --git a/library/ssl_cache.c b/library/ssl_cache.c
index 90e2a81..468273d 100644
--- a/library/ssl_cache.c
+++ b/library/ssl_cache.c
@@ -93,7 +93,7 @@
continue;
}
- if( memcmp( session->id, entry->session.id,
+ if( mbedtls_platform_memcmp( session->id, entry->session.id,
entry->session.id_len ) != 0 )
continue;
@@ -179,7 +179,7 @@
}
#endif
- if( memcmp( session->id, cur->session.id, cur->session.id_len ) == 0 )
+ if( mbedtls_platform_memcmp( session->id, cur->session.id, cur->session.id_len ) == 0 )
break; /* client reconnected, keep timestamp for session id */
#if defined(MBEDTLS_HAVE_TIME)
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index ebc2a63..16f1513 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -1482,7 +1482,7 @@
for( p = ssl->conf->alpn_list; *p != NULL; p++ )
{
if( name_len == strlen( *p ) &&
- memcmp( buf + 3, *p, name_len ) == 0 )
+ mbedtls_platform_memcmp( buf + 3, *p, name_len ) == 0 )
{
ssl->alpn_chosen = *p;
return( 0 );
@@ -1815,7 +1815,7 @@
mbedtls_ssl_session_get_ciphersuite( ssl->session_negotiate ) != i ||
mbedtls_ssl_session_get_compression( ssl->session_negotiate ) != comp ||
ssl->session_negotiate->id_len != n ||
- memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 )
+ mbedtls_platform_memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 )
{
ssl->handshake->resume = 0;
}
@@ -2811,7 +2811,7 @@
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
}
- if( memcmp( p, ecdh_group, sizeof( ecdh_group ) ) != 0 )
+ if( mbedtls_platform_memcmp( p, ecdh_group, sizeof( ecdh_group ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "Bad server key exchange (unexpected header)" ) );
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 747b9f4..c9b03f5 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -708,7 +708,7 @@
cur_len = *theirs++;
if( cur_len == ours_len &&
- memcmp( theirs, *ours, cur_len ) == 0 )
+ mbedtls_platform_memcmp( theirs, *ours, cur_len ) == 0 )
{
ssl->alpn_chosen = *ours;
return( 0 );
@@ -1618,7 +1618,7 @@
* fragment_offset == 0 and fragment_length == length
*/
if( ssl->in_msg[6] != 0 || ssl->in_msg[7] != 0 || ssl->in_msg[8] != 0 ||
- memcmp( ssl->in_msg + 1, ssl->in_msg + 9, 3 ) != 0 )
+ mbedtls_platform_memcmp( ssl->in_msg + 1, ssl->in_msg + 9, 3 ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "ClientHello fragmentation not supported" ) );
return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );
diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c
index 285e736..b5cd901 100644
--- a/library/ssl_ticket.c
+++ b/library/ssl_ticket.c
@@ -259,7 +259,7 @@
unsigned char i;
for( i = 0; i < sizeof( ctx->keys ) / sizeof( *ctx->keys ); i++ )
- if( memcmp( name, ctx->keys[i].name, 4 ) == 0 )
+ if( mbedtls_platform_memcmp( name, ctx->keys[i].name, 4 ) == 0 )
return( &ctx->keys[i] );
return( NULL );
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 9810090..3cc6046 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -2883,7 +2883,7 @@
* Match record's CID with incoming CID.
*/
if( rec->cid_len != transform->in_cid_len ||
- memcmp( rec->cid, transform->in_cid, rec->cid_len ) != 0 )
+ mbedtls_platform_memcmp( rec->cid, transform->in_cid, rec->cid_len ) != 0 )
{
return( MBEDTLS_ERR_SSL_UNEXPECTED_CID );
}
@@ -4634,8 +4634,8 @@
static int ssl_hs_is_proper_fragment( mbedtls_ssl_context *ssl )
{
if( ssl->in_msglen < ssl->in_hslen ||
- memcmp( ssl->in_msg + 6, "\0\0\0", 3 ) != 0 ||
- memcmp( ssl->in_msg + 9, ssl->in_msg + 1, 3 ) != 0 )
+ mbedtls_platform_memcmp( ssl->in_msg + 6, "\0\0\0", 3 ) != 0 ||
+ mbedtls_platform_memcmp( ssl->in_msg + 9, ssl->in_msg + 1, 3 ) != 0 )
{
return( 1 );
}
@@ -6013,7 +6013,7 @@
else
{
/* Make sure msg_type and length are consistent */
- if( memcmp( hs_buf->data, ssl->in_msg, 4 ) != 0 )
+ if( mbedtls_platform_memcmp( hs_buf->data, ssl->in_msg, 4 ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "Fragment header mismatch - ignore" ) );
/* Ignore */
@@ -6872,7 +6872,7 @@
if( peer_crt->raw.len != crt_buf_len )
return( -1 );
- return( memcmp( peer_crt->raw.p, crt_buf, crt_buf_len ) );
+ return( mbedtls_platform_memcmp( peer_crt->raw.p, crt_buf, crt_buf_len ) );
}
#elif defined(MBEDTLS_SSL_RENEGOTIATION)
static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
@@ -6903,7 +6903,7 @@
if( ret != 0 )
return( -1 );
- return( memcmp( tmp_digest, peer_cert_digest, digest_len ) );
+ return( mbedtls_platform_memcmp( tmp_digest, peer_cert_digest, digest_len ) );
}
#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE && MBEDTLS_SSL_RENEGOTIATION */
#endif /* MBEDTLS_SSL_RENEGOTIATION && MBEDTLS_SSL_CLI_C */
@@ -7086,7 +7086,7 @@
if( ssl->in_hslen == 3 + mbedtls_ssl_hs_hdr_len( ssl ) &&
ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE &&
ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE &&
- memcmp( ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ), "\0\0\0", 3 ) == 0 )
+ mbedtls_platform_memcmp( ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ), "\0\0\0", 3 ) == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLSv1 client has no certificate" ) );
return( 0 );
@@ -9961,7 +9961,7 @@
if( (size_t)( end - p ) < sizeof( ssl_serialized_session_header ) )
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
- if( memcmp( p, ssl_serialized_session_header,
+ if( mbedtls_platform_memcmp( p, ssl_serialized_session_header,
sizeof( ssl_serialized_session_header ) ) != 0 )
{
return( MBEDTLS_ERR_SSL_VERSION_MISMATCH );
@@ -10403,9 +10403,9 @@
return( 0 );
}
- in_ctr_cmp = memcmp( ssl->in_ctr + ep_len,
+ in_ctr_cmp = mbedtls_platform_memcmp( ssl->in_ctr + ep_len,
ssl->conf->renego_period + ep_len, 8 - ep_len );
- out_ctr_cmp = memcmp( ssl->cur_out_ctr + ep_len,
+ out_ctr_cmp = mbedtls_platform_memcmp( ssl->cur_out_ctr + ep_len,
ssl->conf->renego_period + ep_len, 8 - ep_len );
if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 )
@@ -11448,7 +11448,7 @@
if( (size_t)( end - p ) < sizeof( ssl_serialized_context_header ) )
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
- if( memcmp( p, ssl_serialized_context_header,
+ if( mbedtls_platform_memcmp( p, ssl_serialized_context_header,
sizeof( ssl_serialized_context_header ) ) != 0 )
{
return( MBEDTLS_ERR_SSL_VERSION_MISMATCH );
@@ -11615,7 +11615,7 @@
for( cur = ssl->conf->alpn_list; *cur != NULL; cur++ )
{
if( strlen( *cur ) == alpn_len &&
- memcmp( p, cur, alpn_len ) == 0 )
+ mbedtls_platform_memcmp( p, cur, alpn_len ) == 0 )
{
ssl->alpn_chosen = *cur;
break;
diff --git a/library/x509.c b/library/x509.c
index d570f71..1e61db8 100644
--- a/library/x509.c
+++ b/library/x509.c
@@ -500,7 +500,7 @@
{
if( a->tag == b->tag &&
a->len == b->len &&
- memcmp( a->p, b->p, b->len ) == 0 )
+ mbedtls_platform_memcmp( a->p, b->p, b->len ) == 0 )
{
return( 0 );
}
@@ -589,7 +589,7 @@
goto exit;
if( oid[0].len != oid[1].len ||
- memcmp( oid[0].p, oid[1].p, oid[1].len ) != 0 )
+ mbedtls_platform_memcmp( oid[0].p, oid[1].p, oid[1].len ) != 0 )
{
return( 1 );
}
diff --git a/library/x509_crl.c b/library/x509_crl.c
index 3113de4..7f99683 100644
--- a/library/x509_crl.c
+++ b/library/x509_crl.c
@@ -511,10 +511,10 @@
}
if( crl->sig_oid.len != sig_oid2.len ||
- memcmp( crl->sig_oid.p, sig_oid2.p, crl->sig_oid.len ) != 0 ||
+ mbedtls_platform_memcmp( crl->sig_oid.p, sig_oid2.p, crl->sig_oid.len ) != 0 ||
sig_params1.len != sig_params2.len ||
( sig_params1.len != 0 &&
- memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 ) )
+ mbedtls_platform_memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 ) )
{
mbedtls_x509_crl_free( crl );
return( MBEDTLS_ERR_X509_SIG_MISMATCH );
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 1923abf..1c6ac57 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -1316,7 +1316,7 @@
* signature field in the sequence tbsCertificate (Section 4.1.2.3).
*/
if( outer_sig_alg.len != inner_sig_alg_len ||
- memcmp( outer_sig_alg.p, inner_sig_alg_start, inner_sig_alg_len ) != 0 )
+ mbedtls_platform_memcmp( outer_sig_alg.p, inner_sig_alg_start, inner_sig_alg_len ) != 0 )
{
return( MBEDTLS_ERR_X509_SIG_MISMATCH );
}
@@ -2588,7 +2588,7 @@
return( 1 );
}
- if( data_len == cb_ctx->oid_len && memcmp( data, cb_ctx->oid,
+ if( data_len == cb_ctx->oid_len && mbedtls_platform_memcmp( data, cb_ctx->oid,
data_len ) == 0 )
{
return( 1 );
@@ -2646,7 +2646,7 @@
while( cur != NULL && cur->serial.len != 0 )
{
if( serial_len == cur->serial.len &&
- memcmp( serial, cur->serial.p, serial_len ) == 0 )
+ mbedtls_platform_memcmp( serial, cur->serial.p, serial_len ) == 0 )
{
if( mbedtls_x509_time_is_past( &cur->revocation_date ) )
return( 1 );
@@ -3173,7 +3173,7 @@
for( cur = trust_ca; cur != NULL; cur = cur->next )
{
if( crt->raw.len == cur->raw.len &&
- memcmp( crt->raw.p, cur->raw.p, crt->raw.len ) == 0 )
+ mbedtls_platform_memcmp( crt->raw.p, cur->raw.p, crt->raw.len ) == 0 )
{
return( 0 );
}