]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: nx - fix GCM for zero length messages
authorMarcelo Cerri <mhcerri@linux.vnet.ibm.com>
Thu, 29 Aug 2013 14:36:39 +0000 (11:36 -0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 2 Sep 2013 10:32:55 +0000 (20:32 +1000)
commit0fd7e3a6b23cdd19b43c5944cc7d6671c6d770f4
tree8d49a66edd8468c22598ae8aa13af9c6aae799f1
parent2b8c91130d81ec0de94e53656eebcc7b3e4f141a
crypto: nx - fix GCM for zero length messages

The NX CGM implementation doesn't support zero length messages and the
current implementation has two flaws:

 - When the input data length is zero, it ignores the associated data.
 - Even when both lengths are zero, it uses the Crypto API to encrypt a
   zeroed block using ctr(aes) and because of this it allocates a new
   transformation and sets the key for this new tfm. Both operations are
   intended to be used only in user context, while the cryptographic
   operations can be called in both user and softirq contexts.

This patch replaces the nested Crypto API use and adds two special
cases:

 - When input data and associated data lengths are zero: it uses NX ECB
   mode to emulate the encryption of a zeroed block using ctr(aes).
 - When input data is zero and associated data is available: it uses NX
   GMAC mode to calculate the associated data MAC.

Reviewed-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/nx/nx-aes-gcm.c