Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: gcm - restrict assoclen for rfc4543

Based on seqiv, IPsec ESP and rfc4543/rfc4106 the assoclen can be 16 or
20 bytes.

From esp4/esp6, assoclen is sizeof IP Header. This includes spi, seq_no
and extended seq_no, that is 8 or 12 bytes.
In seqiv, to asscolen is added the IV size (8 bytes).
Therefore, the assoclen, for rfc4543, should be restricted to 16 or 20
bytes, as for rfc4106.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Reviewed-by: Horia Geanta <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Iuliana Prodan and committed by
Herbert Xu
74bf81d0 ad3f0a93

+4 -2
+4 -2
crypto/gcm.c
··· 1034 1034 1035 1035 static int crypto_rfc4543_encrypt(struct aead_request *req) 1036 1036 { 1037 - return crypto_rfc4543_crypt(req, true); 1037 + return crypto_ipsec_check_assoclen(req->assoclen) ?: 1038 + crypto_rfc4543_crypt(req, true); 1038 1039 } 1039 1040 1040 1041 static int crypto_rfc4543_decrypt(struct aead_request *req) 1041 1042 { 1042 - return crypto_rfc4543_crypt(req, false); 1043 + return crypto_ipsec_check_assoclen(req->assoclen) ?: 1044 + crypto_rfc4543_crypt(req, false); 1043 1045 } 1044 1046 1045 1047 static int crypto_rfc4543_init_tfm(struct crypto_aead *tfm)