cipher: Avoid NULL-segv in GCM mode if a key has not been set.
authorWerner Koch <wk@gnupg.org>
Wed, 23 Mar 2016 13:13:18 +0000 (14:13 +0100)
committerWerner Koch <wk@gnupg.org>
Wed, 23 Mar 2016 13:16:12 +0000 (14:16 +0100)
commite709d86fe596a4bcf235799468947c13ae657d78
treedb7b05053127347c4f750b3733e7dd847321f13a
parent7c9c82feecf94a455c66d9c38576f36c9c4b484c
cipher: Avoid NULL-segv in GCM mode if a key has not been set.

* cipher/cipher-gcm.c (_gcry_cipher_gcm_encrypt): Check that GHASH_FN
has been initialized.
(_gcry_cipher_gcm_decrypt): Ditto.
(_gcry_cipher_gcm_authenticate): Ditto.
(_gcry_cipher_gcm_initiv): Ditto.
(_gcry_cipher_gcm_tag): Ditto.
--

Avoid a crash if certain functions are used before setkey.

Reported-by: Peter Wu <peter@lekensteyn.nl>
  One crash is not fixed, that is the crash when setkey is not invoked
  before using the GCM ciphers (introduced in the 1.7.0 cycle). Either
  these functions should check that the key is present, or they should
  initialize the ghash table earlier. Affected functions:

    _gcry_cipher_gcm_encrypt
    _gcry_cipher_gcm_decrypt
    _gcry_cipher_gcm_authenticate
    _gcry_cipher_gcm_initiv
    (via _gcry_cipher_gcm_setiv)
    _gcry_cipher_gcm_tag
    (via _gcry_cipher_gcm_get_tag, _gcry_cipher_gcm_check_tag)

Regression-due-to: 4a0795af021305f9240f23626a3796157db46bd7
Signed-off-by: Werner Koch <wk@gnupg.org>
cipher/cipher-gcm.c