Skip to content

Commit

Permalink
Do not allow dropping Extended Master Secret extension on renegotiaton
Browse files Browse the repository at this point in the history
Abort renegotiation if server receives client hello with Extended Master
Secret extension dropped in comparison to the initial session.

Fixes #9754

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from openssl/openssl#12099)

(cherry picked from commit 4b7097025305b219694dd8b04f84155cd12fb71d)
[Yilin: drop CHANGES.md]

Signed-off-by: YiLin.Li <YiLin.Li@linux.alibaba.com>
  • Loading branch information
t8m authored and hustliyilin committed Sep 22, 2021
1 parent 82fc547 commit 8bb830f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/openssl/ssl3.h
Expand Up @@ -292,6 +292,9 @@ extern "C" {

# define TLS1_FLAGS_STATELESS 0x0800

/* Set if extended master secret extension required on renegotiation */
# define TLS1_FLAGS_REQUIRED_EXTMS 0x1000

# define SSL3_MT_HELLO_REQUEST 0
# define SSL3_MT_CLIENT_HELLO 1
# define SSL3_MT_SERVER_HELLO 2
Expand Down
14 changes: 13 additions & 1 deletion ssl/statem/extensions.c
Expand Up @@ -1225,14 +1225,26 @@ static int init_etm(SSL *s, unsigned int context)

static int init_ems(SSL *s, unsigned int context)
{
if (!s->server)
if (s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) {
s->s3->flags &= ~TLS1_FLAGS_RECEIVED_EXTMS;
s->s3->flags |= TLS1_FLAGS_REQUIRED_EXTMS;
}

return 1;
}

static int final_ems(SSL *s, unsigned int context, int sent)
{
/*
* Check extended master secret extension is not dropped on
* renegotiation.
*/
if (!(s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS)
&& (s->s3->flags & TLS1_FLAGS_REQUIRED_EXTMS)) {
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_FINAL_EMS,
SSL_R_INCONSISTENT_EXTMS);
return 0;
}
if (!s->server && s->hit) {
/*
* Check extended master secret extension is consistent with
Expand Down

0 comments on commit 8bb830f

Please sign in to comment.