cipher: GCM: check that length of supplied tag is one of valid lengths
* cipher/cipher-gcm.c (is_tag_length_valid): New. (_gcry_cipher_gcm_tag): Check that 'outbuflen' has valid tag length. * tests/basic.c (_check_gcm_cipher): Add test-vectors with different valid tag lengths and negative test vectors with invalid lengths.
NIST SP 800-38D allows following tag lengths:
128, 120, 112, 104, 96, 64 and 32 bits.
[v2: allow larger buffer when outputting tag. 128-bit tag is written
to target buffer in this case]
- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>