From e57c92fd23b3f1c38bf18e302db7c1792d5a70d6 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 13 Nov 2014 22:09:45 +0100 Subject: [PATCH] replace calls to standard memcmp with constant memcmp where necessary --- src/pk/pkcs1/pkcs_1_oaep_decode.c | 2 +- src/pk/pkcs1/pkcs_1_pss_decode.c | 2 +- src/pk/rsa/rsa_verify_hash.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pk/pkcs1/pkcs_1_oaep_decode.c b/src/pk/pkcs1/pkcs_1_oaep_decode.c index 3a87efe..4801e0e 100644 --- a/src/pk/pkcs1/pkcs_1_oaep_decode.c +++ b/src/pk/pkcs1/pkcs_1_oaep_decode.c @@ -136,7 +136,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, } /* compare the lhash'es */ - if (XMEMCMP(seed, DB, hLen) != 0) { + if (mem_neq(seed, DB, hLen) != 0) { err = CRYPT_OK; goto LBL_ERR; } diff --git a/src/pk/pkcs1/pkcs_1_pss_decode.c b/src/pk/pkcs1/pkcs_1_pss_decode.c index 27aa216..91f8c2b 100644 --- a/src/pk/pkcs1/pkcs_1_pss_decode.c +++ b/src/pk/pkcs1/pkcs_1_pss_decode.c @@ -151,7 +151,7 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, } /* mask == hash means valid signature */ - if (XMEMCMP(mask, hash, hLen) == 0) { + if (mem_neq(mask, hash, hLen) == 0) { *res = 1; } diff --git a/src/pk/rsa/rsa_verify_hash.c b/src/pk/rsa/rsa_verify_hash.c index fc000de..aaadba9 100644 --- a/src/pk/rsa/rsa_verify_hash.c +++ b/src/pk/rsa/rsa_verify_hash.c @@ -153,9 +153,9 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen, /* test OID */ if ((reallen == outlen) && (digestinfo[0].size == hash_descriptor[hash_idx].OIDlen) && - (XMEMCMP(digestinfo[0].data, hash_descriptor[hash_idx].OID, sizeof(unsigned long) * hash_descriptor[hash_idx].OIDlen) == 0) && + (mem_neq(digestinfo[0].data, hash_descriptor[hash_idx].OID, sizeof(unsigned long) * hash_descriptor[hash_idx].OIDlen) == 0) && (siginfo[1].size == hashlen) && - (XMEMCMP(siginfo[1].data, hash, hashlen) == 0)) { + (mem_neq(siginfo[1].data, hash, hashlen) == 0)) { *stat = 1; }