OCB: Move large L handling from bottom to upper level
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Sat, 10 Dec 2016 10:29:12 +0000 (12:29 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Sat, 10 Dec 2016 10:29:12 +0000 (12:29 +0200)
commit2d2e5286d53e1f62fe040dff4c6e01961f00afe2
tree6e1b88b6ec0ef96de23a0c67278276edb1de626f
parent161d339f48c03be7fd0f4249d730f7f1767ef8e4
OCB: Move large L handling from bottom to upper level

* cipher/cipher-ocb.c (_gcry_cipher_ocb_get_l): Remove.
(ocb_get_L_big): New.
(_gcry_cipher_ocb_authenticate): L-big handling done in upper
processing loop, so that lower level never sees the case where
'aad_nblocks % 65536 == 0'; Add missing stack burn.
(ocb_aad_finalize): Add missing stack burn.
(ocb_crypt): L-big handling done in upper processing loop, so that
lower level never sees the case where 'data_nblocks % 65536 == 0'.
* cipher/cipher-internal.h (_gcry_cipher_ocb_get_l): Remove.
(ocb_get_l): Remove 'l_tmp' usage and simplify since input
is more limited now, 'N is not multiple of 65536'.
* cipher/rijndael-aesni.c (get_l): Remove.
(aesni_ocb_enc, aesni_ocb_dec, _gcry_aes_aesni_ocb_auth): Remove
l_tmp; Use 'ocb_get_l'.
* cipher/rijndael-ssse3-amd64.c (get_l): Remove.
(ssse3_ocb_enc, ssse3_ocb_dec, _gcry_aes_ssse3_ocb_auth): Remove
l_tmp; Use 'ocb_get_l'.
* cipher/camellia-glue.c: Remove OCB l_tmp usage.
* cipher/rijndael-armv8-ce.c: Ditto.
* cipher/rijndael.c: Ditto.
* cipher/serpent.c: Ditto.
* cipher/twofish.c: Ditto.
--

Move large L value generation to up-most level to simplify lower level
ocb_get_l for greater performance and simpler implementation. This helps
implementing OCB in assembly as 'ocb_get_l' no longer has function call
on slow-path.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/camellia-glue.c
cipher/cipher-internal.h
cipher/cipher-ocb.c
cipher/rijndael-aesni.c
cipher/rijndael-armv8-ce.c
cipher/rijndael-ssse3-amd64.c
cipher/rijndael.c
cipher/serpent.c
cipher/twofish.c