]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: nx - Fix timing leak in GCM and CCM decryption
authorDavid Gstir <david@sigma-star.at>
Sun, 15 Nov 2015 16:14:41 +0000 (17:14 +0100)
committerLuis Henriques <luis.henriques@canonical.com>
Tue, 5 Jan 2016 11:22:18 +0000 (11:22 +0000)
commit cb8affb55c7e64816f3effcd9b2fc3268c016fac upstream.

Using non-constant time memcmp() makes the verification of the authentication
tag in the decrypt path vulnerable to timing attacks. Fix this by using
crypto_memneq() instead.

Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/crypto/nx/nx-aes-ccm.c
drivers/crypto/nx/nx-aes-gcm.c

index 5ecd4c2414aa85bbc9cbca1b4311a954dfcd3710..b1679db09de2d0b78bb633cb081b29f53024cbd6 100644 (file)
@@ -411,7 +411,7 @@ static int ccm_nx_decrypt(struct aead_request   *req,
                processed += to_process;
        } while (processed < nbytes);
 
-       rc = memcmp(csbcpb->cpb.aes_ccm.out_pat_or_mac, priv->oauth_tag,
+       rc = crypto_memneq(csbcpb->cpb.aes_ccm.out_pat_or_mac, priv->oauth_tag,
                    authsize) ? -EBADMSG : 0;
 out:
        spin_unlock_irqrestore(&nx_ctx->lock, irq_flags);
index 025d9a8d5b1908126804c8468d30ec6902cb4c59..dd4431ea1376ebafe33dd05cff44b83a18156160 100644 (file)
@@ -415,7 +415,7 @@ mac:
                scatterwalk_map_and_copy(itag, req->src, nbytes,
                                 crypto_aead_authsize(crypto_aead_reqtfm(req)),
                                 SCATTERWALK_FROM_SG);
-               rc = memcmp(itag, otag,
+               rc = crypto_memneq(itag, otag,
                            crypto_aead_authsize(crypto_aead_reqtfm(req))) ?
                     -EBADMSG : 0;
        }