Don't send key_share for PSK-only key exchange
authorBenjamin Kaduk <bkaduk@akamai.com>
Tue, 30 Mar 2021 04:27:49 +0000 (21:27 -0700)
committerBenjamin Kaduk <bkaduk@akamai.com>
Wed, 12 May 2021 16:11:48 +0000 (09:11 -0700)
commite776858bce32d473bd7a69c616ad7f6c2f979dfc
tree4d93ce0c3ee94cb7e7560a0d1a98f959b68ee640
parentf84ab284e91991a80191cf0e6d22ddc452043661
Don't send key_share for PSK-only key exchange

TLS 1.3 allows for the "psk_ke" and "psk_dhe_ke" key-exchange modes.
Only the latter mode introduces a new ephemeral (Diffie-Hellman)
key exchange, with the PSK being the only key material used in the
former case.

It's a compliance requirement of RFC 8446 that the server MUST NOT
send a KeyShareEntry when using the "psk_ke" mode, but prior to
this commit we would send a key-share based solely on whether the
client sent one.  This bug goes unnoticed in our internal test suite
since openssl communicating with openssl can never negotiate the
PSK-only key-exchange mode.  However, we should still be compliant
with the spec, so check whether the DHE mode was offered and don't
send a key-share if it wasn't.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14749)
ssl/statem/extensions_srvr.c