summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_pkt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/d1_pkt.c')
-rw-r--r--src/lib/libssl/d1_pkt.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c
index 36090533aa..d6b1506119 100644
--- a/src/lib/libssl/d1_pkt.c
+++ b/src/lib/libssl/d1_pkt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_pkt.c,v 1.73 2020/03/13 16:40:42 jsing Exp $ */ 1/* $OpenBSD: d1_pkt.c,v 1.74 2020/07/30 16:53:01 jsing Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -1175,28 +1175,29 @@ int
1175do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) 1175do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len)
1176{ 1176{
1177 unsigned char *p; 1177 unsigned char *p;
1178 int i, mac_size, clear = 0;
1179 SSL3_RECORD_INTERNAL *wr; 1178 SSL3_RECORD_INTERNAL *wr;
1180 SSL3_BUFFER_INTERNAL *wb; 1179 SSL3_BUFFER_INTERNAL *wb;
1181 SSL_SESSION *sess; 1180 SSL_SESSION *sess;
1182 int bs; 1181 int mac_size = 0;
1182 int bs, ret;
1183 CBB cbb; 1183 CBB cbb;
1184 1184
1185 memset(&cbb, 0, sizeof(cbb)); 1185 memset(&cbb, 0, sizeof(cbb));
1186 1186
1187 /* first check if there is a SSL3_BUFFER_INTERNAL still being written 1187 /*
1188 * out. This will happen with non blocking IO */ 1188 * First check if there is a SSL3_BUFFER_INTERNAL still being written
1189 * out. This will happen with non blocking IO.
1190 */
1189 if (S3I(s)->wbuf.left != 0) { 1191 if (S3I(s)->wbuf.left != 0) {
1190 OPENSSL_assert(0); /* XDTLS: want to see if we ever get here */ 1192 OPENSSL_assert(0); /* XDTLS: want to see if we ever get here */
1191 return (ssl3_write_pending(s, type, buf, len)); 1193 return (ssl3_write_pending(s, type, buf, len));
1192 } 1194 }
1193 1195
1194 /* If we have an alert to send, lets send it */ 1196 /* If we have an alert to send, let's send it */
1195 if (S3I(s)->alert_dispatch) { 1197 if (S3I(s)->alert_dispatch) {
1196 i = s->method->ssl_dispatch_alert(s); 1198 if ((ret = s->method->ssl_dispatch_alert(s)) <= 0)
1197 if (i <= 0) 1199 return (ret);
1198 return (i); 1200 /* If it went, fall through and send more stuff. */
1199 /* if it went, fall through and send more stuff */
1200 } 1201 }
1201 1202
1202 if (len == 0) 1203 if (len == 0)
@@ -1206,15 +1207,9 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len)
1206 wb = &(S3I(s)->wbuf); 1207 wb = &(S3I(s)->wbuf);
1207 sess = s->session; 1208 sess = s->session;
1208 1209
1209 if ((sess == NULL) || (s->internal->enc_write_ctx == NULL) || 1210 if (sess != NULL && s->internal->enc_write_ctx != NULL &&
1210 (EVP_MD_CTX_md(s->internal->write_hash) == NULL)) 1211 EVP_MD_CTX_md(s->internal->write_hash) != NULL) {
1211 clear = 1; 1212 if ((mac_size = EVP_MD_CTX_size(s->internal->write_hash)) < 0)
1212
1213 if (clear)
1214 mac_size = 0;
1215 else {
1216 mac_size = EVP_MD_CTX_size(s->internal->write_hash);
1217 if (mac_size < 0)
1218 goto err; 1213 goto err;
1219 } 1214 }
1220 1215