diff options
| author | jsing <> | 2018-11-21 15:13:29 +0000 |
|---|---|---|
| committer | jsing <> | 2018-11-21 15:13:29 +0000 |
| commit | e8890ed3b276eb268ca4797509a7faf50534f77d (patch) | |
| tree | 7992535c747d2aff7dd9a131f8fc65ad2af3636d /src/lib/libssl/t1_hash.c | |
| parent | 832db10c7eec76c2d877de16144d9855ad294293 (diff) | |
| download | openbsd-e8890ed3b276eb268ca4797509a7faf50534f77d.tar.gz openbsd-e8890ed3b276eb268ca4797509a7faf50534f77d.tar.bz2 openbsd-e8890ed3b276eb268ca4797509a7faf50534f77d.zip | |
Fix DTLS transcript handling for HelloVerifyRequest.
If DTLS sees a HelloVerifyRequest the transcript is reset - the previous
tls1_init_finished_mac() function could be called multiple times and would
discard any existing state. The replacement tls1_transcript_init() is more
strict and fails if a transcript already exists.
Provide an explicit tls1_transcript_reset() function and call it from the
appropriate places. This also lets us make DTLS less of a special snowflake
and call tls1_transcript_init() in the same place as used for TLS.
ok beck@ tb@
Diffstat (limited to 'src/lib/libssl/t1_hash.c')
| -rw-r--r-- | src/lib/libssl/t1_hash.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/libssl/t1_hash.c b/src/lib/libssl/t1_hash.c index f514c5290e..50e0ad3ca0 100644 --- a/src/lib/libssl/t1_hash.c +++ b/src/lib/libssl/t1_hash.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: t1_hash.c,v 1.4 2018/11/08 22:28:52 jsing Exp $ */ | 1 | /* $OpenBSD: t1_hash.c,v 1.5 2018/11/21 15:13:29 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -118,7 +118,7 @@ tls1_transcript_init(SSL *s) | |||
| 118 | if ((S3I(s)->handshake_transcript = BUF_MEM_new()) == NULL) | 118 | if ((S3I(s)->handshake_transcript = BUF_MEM_new()) == NULL) |
| 119 | return 0; | 119 | return 0; |
| 120 | 120 | ||
| 121 | s->s3->flags &= ~TLS1_FLAGS_FREEZE_TRANSCRIPT; | 121 | tls1_transcript_reset(s); |
| 122 | 122 | ||
| 123 | return 1; | 123 | return 1; |
| 124 | } | 124 | } |
| @@ -130,6 +130,21 @@ tls1_transcript_free(SSL *s) | |||
| 130 | S3I(s)->handshake_transcript = NULL; | 130 | S3I(s)->handshake_transcript = NULL; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | void | ||
| 134 | tls1_transcript_reset(SSL *s) | ||
| 135 | { | ||
| 136 | /* | ||
| 137 | * We should check the return value of BUF_MEM_grow_clean(), however | ||
| 138 | * due to yet another bad API design, when called with a length of zero | ||
| 139 | * it is impossible to tell if it succeeded (returning a length of zero) | ||
| 140 | * or if it failed (and returned zero)... our implementation never | ||
| 141 | * fails with a length of zero, so we trust all is okay... | ||
| 142 | */ | ||
| 143 | (void)BUF_MEM_grow_clean(S3I(s)->handshake_transcript, 0); | ||
| 144 | |||
| 145 | s->s3->flags &= ~TLS1_FLAGS_FREEZE_TRANSCRIPT; | ||
| 146 | } | ||
| 147 | |||
| 133 | int | 148 | int |
| 134 | tls1_transcript_append(SSL *s, const unsigned char *buf, size_t len) | 149 | tls1_transcript_append(SSL *s, const unsigned char *buf, size_t len) |
| 135 | { | 150 | { |
