Correctly clear the current cipher state, when changing cipher state.
authorjsing <jsing@openbsd.org>
Wed, 5 Sep 2018 16:48:11 +0000 (16:48 +0000)
committerjsing <jsing@openbsd.org>
Wed, 5 Sep 2018 16:48:11 +0000 (16:48 +0000)
commitf1abf68627e51bc3621a614ccccf1e70315337bb
tree4eeb7f056bbcead7b2ae00fcb32853ab8d46cbdb
parenta152958512f308afc63273a2baac73e466ba2c39
Correctly clear the current cipher state, when changing cipher state.

When a renegotiation results in a change of cipher suite, the renegotation
would fail if it switched from AEAD to non-AEAD or vice versa. This is due
to the fact that the previous EVP_AEAD or EVP_CIPHER state remained,
resulting in incorrect logic that caused MAC failures.

Rename ssl_clear_cipher_ctx() to ssl_clear_cipher_state() and split it
into separate read/write components, then call these functions from the
appropriate places when a ChangeCipherSpec message is being processed.
Also, remove the separate ssl_clear_hash_ctx() calls and fold these into
the ssl_clear_cipher_{read,write}_state() functions.

Issue reported by Bernard Spil, who also tested this diff.

ok tb@
lib/libssl/ssl_lib.c
lib/libssl/ssl_locl.h
lib/libssl/t1_enc.c