summaryrefslogtreecommitdiff
path: root/src/lib/libssl/t1_hash.c
diff options
context:
space:
mode:
authorjsing <>2018-11-21 15:13:29 +0000
committerjsing <>2018-11-21 15:13:29 +0000
commitab91451e6ebf1260022c78c25a334e437c04d78e (patch)
tree7992535c747d2aff7dd9a131f8fc65ad2af3636d /src/lib/libssl/t1_hash.c
parent1b50b4396296c64d8937c2ec1c7ed2eb5547cf91 (diff)
downloadopenbsd-ab91451e6ebf1260022c78c25a334e437c04d78e.tar.gz
openbsd-ab91451e6ebf1260022c78c25a334e437c04d78e.tar.bz2
openbsd-ab91451e6ebf1260022c78c25a334e437c04d78e.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.c19
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
133void
134tls1_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
133int 148int
134tls1_transcript_append(SSL *s, const unsigned char *buf, size_t len) 149tls1_transcript_append(SSL *s, const unsigned char *buf, size_t len)
135{ 150{