All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH cryptodev] crypto: arch - use crypto_memneq instead of memcmp
@ 2013-12-11 10:28 Daniel Borkmann
  2013-12-20 14:07 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Borkmann @ 2013-12-11 10:28 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, James Yonan

Replace remaining occurences (just as we did in crypto/) under arch/*/crypto/
that make use of memcmp() for comparing keys or authentication tags for
usage with crypto_memneq(). It can simply be used as a drop-in replacement
for the normal memcmp().

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Cc: James Yonan <james@openvpn.net>
---
 arch/s390/crypto/des_s390.c        | 6 +++---
 arch/x86/crypto/aesni-intel_glue.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index bcca01c..200f2a1 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -237,9 +237,9 @@ static int des3_setkey(struct crypto_tfm *tfm, const u8 *key,
 	struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm);
 	u32 *flags = &tfm->crt_flags;
 
-	if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) &&
-	    memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2],
-		   DES_KEY_SIZE)) &&
+	if (!(crypto_memneq(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) &&
+	    crypto_memneq(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2],
+			  DES_KEY_SIZE)) &&
 	    (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
 		*flags |= CRYPTO_TFM_RES_WEAK_KEY;
 		return -EINVAL;
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 835488b..aba34b8 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -1001,7 +1001,7 @@ static int __driver_rfc4106_decrypt(struct aead_request *req)
 		authTag, auth_tag_len);
 
 	/* Compare generated tag with passed in tag. */
-	retval = memcmp(src + tempCipherLen, authTag, auth_tag_len) ?
+	retval = crypto_memneq(src + tempCipherLen, authTag, auth_tag_len) ?
 		-EBADMSG : 0;
 
 	if (one_entry_in_sg) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH cryptodev] crypto: arch - use crypto_memneq instead of memcmp
  2013-12-11 10:28 [PATCH cryptodev] crypto: arch - use crypto_memneq instead of memcmp Daniel Borkmann
@ 2013-12-20 14:07 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2013-12-20 14:07 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: linux-crypto, James Yonan

On Wed, Dec 11, 2013 at 11:28:59AM +0100, Daniel Borkmann wrote:
> Replace remaining occurences (just as we did in crypto/) under arch/*/crypto/
> that make use of memcmp() for comparing keys or authentication tags for
> usage with crypto_memneq(). It can simply be used as a drop-in replacement
> for the normal memcmp().
> 
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> Cc: James Yonan <james@openvpn.net>

Patch applied.  Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-20 14:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-11 10:28 [PATCH cryptodev] crypto: arch - use crypto_memneq instead of memcmp Daniel Borkmann
2013-12-20 14:07 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.