• Marcelo Cerri's avatar
    crypto: nx - fix GCM for zero length messages · dec0ed6c
    Marcelo Cerri authored
    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: default avatarJoy Latten <jmlatten@linux.vnet.ibm.com>
    Signed-off-by: default avatarMarcelo Cerri <mhcerri@linux.vnet.ibm.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    dec0ed6c
nx-aes-gcm.c 14.2 KB