GCM: Move gcm_table initialization to setkey
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Wed, 20 Nov 2013 13:44:27 +0000 (15:44 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Thu, 21 Nov 2013 09:58:09 +0000 (11:58 +0200)
commitdbfa651618693da7ea73b4d2d00d4efd411bfb46
tree64bfe4135eb663dacc8459af97fef7ad1e4b5142
parentfb1e52e3fe231671de546eacd6becd31c26c4f7b
GCM: Move gcm_table initialization to setkey

* cipher/cipher-gcm.c: Change all 'c->u_iv.iv' to
'c->u_mode.gcm.u_ghash_key.key'.
(_gcry_cipher_gcm_setkey): New.
(_gcry_cipher_gcm_initiv): Move ghash initialization to function above.
* cipher/cipher-internal.h (gcry_cipher_handle): Add
'u_mode.gcm.u_ghash_key'; Reorder 'u_mode.gcm' members for partial
clearing in gcry_cipher_reset.
(_gcry_cipher_gcm_setkey): New prototype.
* cipher/cipher.c (cipher_setkey): Add GCM setkey.
(cipher_reset): Clear 'u_mode' only partially for GCM.
--

GHASH tables can be generated at setkey time. No need to regenerate
for every new IV.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/cipher-gcm.c
cipher/cipher-internal.h
cipher/cipher.c