summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_pkt.c
diff options
context:
space:
mode:
authorjsing <>2021-04-25 13:15:23 +0000
committerjsing <>2021-04-25 13:15:23 +0000
commitebe128ca73ce7d178a186b93684c8bf8577f3b80 (patch)
tree0d77df32f82a4eb3addc8531055c43c868f52f5e /src/lib/libssl/ssl_pkt.c
parent6b7899114d6b9acd6fbc1fc2f5129bf1ca98ac1c (diff)
downloadopenbsd-ebe128ca73ce7d178a186b93684c8bf8577f3b80.tar.gz
openbsd-ebe128ca73ce7d178a186b93684c8bf8577f3b80.tar.bz2
openbsd-ebe128ca73ce7d178a186b93684c8bf8577f3b80.zip
Clean up derivation of finished/peer finished.
Make this process more readable by having specific client/server functions, calling the correct one based on s->server. This allows to remove various SSL_ST_ACCEPT/SSL_ST_CONNECT checks, along with duplicate code. ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_pkt.c')
-rw-r--r--src/lib/libssl/ssl_pkt.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c
index a760f90a3a..6e0cfe2102 100644
--- a/src/lib/libssl/ssl_pkt.c
+++ b/src/lib/libssl/ssl_pkt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_pkt.c,v 1.40 2021/03/29 16:46:09 jsing Exp $ */ 1/* $OpenBSD: ssl_pkt.c,v 1.41 2021/04/25 13:15:22 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1155,13 +1155,6 @@ int
1155ssl3_do_change_cipher_spec(SSL *s) 1155ssl3_do_change_cipher_spec(SSL *s)
1156{ 1156{
1157 int i; 1157 int i;
1158 const char *sender;
1159 int slen;
1160
1161 if (S3I(s)->hs.state & SSL_ST_ACCEPT)
1162 i = SSL3_CHANGE_CIPHER_SERVER_READ;
1163 else
1164 i = SSL3_CHANGE_CIPHER_CLIENT_READ;
1165 1158
1166 if (S3I(s)->hs.tls12.key_block == NULL) { 1159 if (S3I(s)->hs.tls12.key_block == NULL) {
1167 if (s->session == NULL || s->session->master_key_length == 0) { 1160 if (s->session == NULL || s->session->master_key_length == 0) {
@@ -1175,27 +1168,20 @@ ssl3_do_change_cipher_spec(SSL *s)
1175 return (0); 1168 return (0);
1176 } 1169 }
1177 1170
1171 if (S3I(s)->hs.state & SSL_ST_ACCEPT)
1172 i = SSL3_CHANGE_CIPHER_SERVER_READ;
1173 else
1174 i = SSL3_CHANGE_CIPHER_CLIENT_READ;
1175
1178 if (!tls1_change_cipher_state(s, i)) 1176 if (!tls1_change_cipher_state(s, i))
1179 return (0); 1177 return (0);
1180 1178
1181 /* we have to record the message digest at 1179 /*
1182 * this point so we can get it before we read 1180 * We have to record the message digest at this point so we can get it
1183 * the finished message */ 1181 * before we read the finished message.
1184 if (S3I(s)->hs.state & SSL_ST_CONNECT) { 1182 */
1185 sender = TLS_MD_SERVER_FINISH_CONST; 1183 if (!tls12_derive_peer_finished(s))
1186 slen = TLS_MD_SERVER_FINISH_CONST_SIZE; 1184 return (0);
1187 } else {
1188 sender = TLS_MD_CLIENT_FINISH_CONST;
1189 slen = TLS_MD_CLIENT_FINISH_CONST_SIZE;
1190 }
1191
1192 i = tls1_final_finish_mac(s, sender, slen,
1193 S3I(s)->hs.peer_finished);
1194 if (i == 0) {
1195 SSLerror(s, ERR_R_INTERNAL_ERROR);
1196 return 0;
1197 }
1198 S3I(s)->hs.peer_finished_len = i;
1199 1185
1200 return (1); 1186 return (1);
1201} 1187}