diff options
author | jsing <> | 2020-03-12 17:01:53 +0000 |
---|---|---|
committer | jsing <> | 2020-03-12 17:01:53 +0000 |
commit | cf38ddcaf43a2f6fd1de2405aa74feca6523733c (patch) | |
tree | 1386c6711648c45e415953677ee13b17cdc299a3 | |
parent | e0c848b5bda852697d7b956ff1f7b8eb68b7ad18 (diff) | |
download | openbsd-cf38ddcaf43a2f6fd1de2405aa74feca6523733c.tar.gz openbsd-cf38ddcaf43a2f6fd1de2405aa74feca6523733c.tar.bz2 openbsd-cf38ddcaf43a2f6fd1de2405aa74feca6523733c.zip |
Use internal versions of SSL3_BUFFER, SSL3_RECORD and DTLS1_RECORD_DATA.
SSL3_BUFFER, SSL3_RECORD and DTLS1_RECORD_DATA are currently still in
public headers, even though their usage is internal. This moves to
using _INTERNAL suffixed versions that are in internal headers, which
then allows us to change them without any potential public API fallout.
ok inoguchi@ tb@
-rw-r--r-- | src/lib/libssl/d1_enc.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/d1_lib.c | 10 | ||||
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 39 | ||||
-rw-r--r-- | src/lib/libssl/dtls1.h | 6 | ||||
-rw-r--r-- | src/lib/libssl/s3_cbc.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/ssl3.h | 4 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 39 | ||||
-rw-r--r-- | src/lib/libssl/ssl_pkt.c | 20 | ||||
-rw-r--r-- | src/lib/libssl/t1_enc.c | 6 |
9 files changed, 83 insertions, 53 deletions
diff --git a/src/lib/libssl/d1_enc.c b/src/lib/libssl/d1_enc.c index 20686d2963..3927fbfe0d 100644 --- a/src/lib/libssl/d1_enc.c +++ b/src/lib/libssl/d1_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_enc.c,v 1.14 2017/01/23 08:08:06 beck Exp $ */ | 1 | /* $OpenBSD: d1_enc.c,v 1.15 2020/03/12 17:01:53 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. |
@@ -132,7 +132,7 @@ | |||
132 | int | 132 | int |
133 | dtls1_enc(SSL *s, int send) | 133 | dtls1_enc(SSL *s, int send) |
134 | { | 134 | { |
135 | SSL3_RECORD *rec; | 135 | SSL3_RECORD_INTERNAL *rec; |
136 | EVP_CIPHER_CTX *ds; | 136 | EVP_CIPHER_CTX *ds; |
137 | unsigned long l; | 137 | unsigned long l; |
138 | int bs, i, j, k, mac_size = 0; | 138 | int bs, i, j, k, mac_size = 0; |
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c index 6171035d23..b7ba6b1092 100644 --- a/src/lib/libssl/d1_lib.c +++ b/src/lib/libssl/d1_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_lib.c,v 1.44 2020/03/10 17:02:21 jsing Exp $ */ | 1 | /* $OpenBSD: d1_lib.c,v 1.45 2020/03/12 17:01:53 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. |
@@ -136,17 +136,17 @@ dtls1_clear_queues(SSL *s) | |||
136 | { | 136 | { |
137 | pitem *item = NULL; | 137 | pitem *item = NULL; |
138 | hm_fragment *frag = NULL; | 138 | hm_fragment *frag = NULL; |
139 | DTLS1_RECORD_DATA *rdata; | 139 | DTLS1_RECORD_DATA_INTERNAL *rdata; |
140 | 140 | ||
141 | while ((item = pqueue_pop(D1I(s)->unprocessed_rcds.q)) != NULL) { | 141 | while ((item = pqueue_pop(D1I(s)->unprocessed_rcds.q)) != NULL) { |
142 | rdata = (DTLS1_RECORD_DATA *) item->data; | 142 | rdata = (DTLS1_RECORD_DATA_INTERNAL *) item->data; |
143 | free(rdata->rbuf.buf); | 143 | free(rdata->rbuf.buf); |
144 | free(item->data); | 144 | free(item->data); |
145 | pitem_free(item); | 145 | pitem_free(item); |
146 | } | 146 | } |
147 | 147 | ||
148 | while ((item = pqueue_pop(D1I(s)->processed_rcds.q)) != NULL) { | 148 | while ((item = pqueue_pop(D1I(s)->processed_rcds.q)) != NULL) { |
149 | rdata = (DTLS1_RECORD_DATA *) item->data; | 149 | rdata = (DTLS1_RECORD_DATA_INTERNAL *) item->data; |
150 | free(rdata->rbuf.buf); | 150 | free(rdata->rbuf.buf); |
151 | free(item->data); | 151 | free(item->data); |
152 | pitem_free(item); | 152 | pitem_free(item); |
@@ -167,7 +167,7 @@ dtls1_clear_queues(SSL *s) | |||
167 | } | 167 | } |
168 | 168 | ||
169 | while ((item = pqueue_pop(D1I(s)->buffered_app_data.q)) != NULL) { | 169 | while ((item = pqueue_pop(D1I(s)->buffered_app_data.q)) != NULL) { |
170 | rdata = (DTLS1_RECORD_DATA *) item->data; | 170 | rdata = (DTLS1_RECORD_DATA_INTERNAL *) item->data; |
171 | free(rdata->rbuf.buf); | 171 | free(rdata->rbuf.buf); |
172 | free(item->data); | 172 | free(item->data); |
173 | pitem_free(item); | 173 | pitem_free(item); |
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 101017449c..31415b7c3a 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.70 2020/03/10 17:02:21 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.71 2020/03/12 17:01:53 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. |
@@ -186,7 +186,7 @@ static int have_handshake_fragment(SSL *s, int type, unsigned char *buf, | |||
186 | int len, int peek); | 186 | int len, int peek); |
187 | static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap); | 187 | static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap); |
188 | static void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap); | 188 | static void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap); |
189 | static DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr, | 189 | static DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD_INTERNAL *rr, |
190 | unsigned int *is_next_epoch); | 190 | unsigned int *is_next_epoch); |
191 | static int dtls1_buffer_record(SSL *s, record_pqueue *q, | 191 | static int dtls1_buffer_record(SSL *s, record_pqueue *q, |
192 | unsigned char *priority); | 192 | unsigned char *priority); |
@@ -196,16 +196,16 @@ static int dtls1_process_record(SSL *s); | |||
196 | static int | 196 | static int |
197 | dtls1_copy_record(SSL *s, pitem *item) | 197 | dtls1_copy_record(SSL *s, pitem *item) |
198 | { | 198 | { |
199 | DTLS1_RECORD_DATA *rdata; | 199 | DTLS1_RECORD_DATA_INTERNAL *rdata; |
200 | 200 | ||
201 | rdata = (DTLS1_RECORD_DATA *)item->data; | 201 | rdata = (DTLS1_RECORD_DATA_INTERNAL *)item->data; |
202 | 202 | ||
203 | free(S3I(s)->rbuf.buf); | 203 | free(S3I(s)->rbuf.buf); |
204 | 204 | ||
205 | s->internal->packet = rdata->packet; | 205 | s->internal->packet = rdata->packet; |
206 | s->internal->packet_length = rdata->packet_length; | 206 | s->internal->packet_length = rdata->packet_length; |
207 | memcpy(&(S3I(s)->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER)); | 207 | memcpy(&(S3I(s)->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); |
208 | memcpy(&(S3I(s)->rrec), &(rdata->rrec), sizeof(SSL3_RECORD)); | 208 | memcpy(&(S3I(s)->rrec), &(rdata->rrec), sizeof(SSL3_RECORD_INTERNAL)); |
209 | 209 | ||
210 | /* Set proper sequence number for mac calculation */ | 210 | /* Set proper sequence number for mac calculation */ |
211 | memcpy(&(S3I(s)->read_sequence[2]), &(rdata->packet[5]), 6); | 211 | memcpy(&(S3I(s)->read_sequence[2]), &(rdata->packet[5]), 6); |
@@ -217,30 +217,29 @@ dtls1_copy_record(SSL *s, pitem *item) | |||
217 | static int | 217 | static int |
218 | dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) | 218 | dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) |
219 | { | 219 | { |
220 | DTLS1_RECORD_DATA *rdata; | 220 | DTLS1_RECORD_DATA_INTERNAL *rdata; |
221 | pitem *item; | 221 | pitem *item; |
222 | 222 | ||
223 | /* Limit the size of the queue to prevent DOS attacks */ | 223 | /* Limit the size of the queue to prevent DOS attacks */ |
224 | if (pqueue_size(queue->q) >= 100) | 224 | if (pqueue_size(queue->q) >= 100) |
225 | return 0; | 225 | return 0; |
226 | 226 | ||
227 | rdata = malloc(sizeof(DTLS1_RECORD_DATA)); | 227 | rdata = malloc(sizeof(DTLS1_RECORD_DATA_INTERNAL)); |
228 | item = pitem_new(priority, rdata); | 228 | item = pitem_new(priority, rdata); |
229 | if (rdata == NULL || item == NULL) | 229 | if (rdata == NULL || item == NULL) |
230 | goto init_err; | 230 | goto init_err; |
231 | 231 | ||
232 | rdata->packet = s->internal->packet; | 232 | rdata->packet = s->internal->packet; |
233 | rdata->packet_length = s->internal->packet_length; | 233 | rdata->packet_length = s->internal->packet_length; |
234 | memcpy(&(rdata->rbuf), &(S3I(s)->rbuf), sizeof(SSL3_BUFFER)); | 234 | memcpy(&(rdata->rbuf), &(S3I(s)->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); |
235 | memcpy(&(rdata->rrec), &(S3I(s)->rrec), sizeof(SSL3_RECORD)); | 235 | memcpy(&(rdata->rrec), &(S3I(s)->rrec), sizeof(SSL3_RECORD_INTERNAL)); |
236 | 236 | ||
237 | item->data = rdata; | 237 | item->data = rdata; |
238 | 238 | ||
239 | |||
240 | s->internal->packet = NULL; | 239 | s->internal->packet = NULL; |
241 | s->internal->packet_length = 0; | 240 | s->internal->packet_length = 0; |
242 | memset(&(S3I(s)->rbuf), 0, sizeof(SSL3_BUFFER)); | 241 | memset(&(S3I(s)->rbuf), 0, sizeof(SSL3_BUFFER_INTERNAL)); |
243 | memset(&(S3I(s)->rrec), 0, sizeof(SSL3_RECORD)); | 242 | memset(&(S3I(s)->rrec), 0, sizeof(SSL3_RECORD_INTERNAL)); |
244 | 243 | ||
245 | if (!ssl3_setup_buffers(s)) | 244 | if (!ssl3_setup_buffers(s)) |
246 | goto err; | 245 | goto err; |
@@ -329,7 +328,7 @@ dtls1_process_record(SSL *s) | |||
329 | int i, al; | 328 | int i, al; |
330 | int enc_err; | 329 | int enc_err; |
331 | SSL_SESSION *sess; | 330 | SSL_SESSION *sess; |
332 | SSL3_RECORD *rr; | 331 | SSL3_RECORD_INTERNAL *rr; |
333 | unsigned int mac_size, orig_len; | 332 | unsigned int mac_size, orig_len; |
334 | unsigned char md[EVP_MAX_MD_SIZE]; | 333 | unsigned char md[EVP_MAX_MD_SIZE]; |
335 | 334 | ||
@@ -467,7 +466,7 @@ err: | |||
467 | int | 466 | int |
468 | dtls1_get_record(SSL *s) | 467 | dtls1_get_record(SSL *s) |
469 | { | 468 | { |
470 | SSL3_RECORD *rr; | 469 | SSL3_RECORD_INTERNAL *rr; |
471 | unsigned char *p = NULL; | 470 | unsigned char *p = NULL; |
472 | DTLS1_BITMAP *bitmap; | 471 | DTLS1_BITMAP *bitmap; |
473 | unsigned int is_next_epoch; | 472 | unsigned int is_next_epoch; |
@@ -638,7 +637,7 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
638 | { | 637 | { |
639 | int al, i, j, ret; | 638 | int al, i, j, ret; |
640 | unsigned int n; | 639 | unsigned int n; |
641 | SSL3_RECORD *rr; | 640 | SSL3_RECORD_INTERNAL *rr; |
642 | void (*cb)(const SSL *ssl, int type2, int val) = NULL; | 641 | void (*cb)(const SSL *ssl, int type2, int val) = NULL; |
643 | 642 | ||
644 | if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */ | 643 | if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */ |
@@ -1178,15 +1177,15 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
1178 | { | 1177 | { |
1179 | unsigned char *p; | 1178 | unsigned char *p; |
1180 | int i, mac_size, clear = 0; | 1179 | int i, mac_size, clear = 0; |
1181 | SSL3_RECORD *wr; | 1180 | SSL3_RECORD_INTERNAL *wr; |
1182 | SSL3_BUFFER *wb; | 1181 | SSL3_BUFFER_INTERNAL *wb; |
1183 | SSL_SESSION *sess; | 1182 | SSL_SESSION *sess; |
1184 | int bs; | 1183 | int bs; |
1185 | CBB cbb; | 1184 | CBB cbb; |
1186 | 1185 | ||
1187 | memset(&cbb, 0, sizeof(cbb)); | 1186 | memset(&cbb, 0, sizeof(cbb)); |
1188 | 1187 | ||
1189 | /* first check if there is a SSL3_BUFFER still being written | 1188 | /* first check if there is a SSL3_BUFFER_INTERNAL still being written |
1190 | * out. This will happen with non blocking IO */ | 1189 | * out. This will happen with non blocking IO */ |
1191 | if (S3I(s)->wbuf.left != 0) { | 1190 | if (S3I(s)->wbuf.left != 0) { |
1192 | OPENSSL_assert(0); /* XDTLS: want to see if we ever get here */ | 1191 | OPENSSL_assert(0); /* XDTLS: want to see if we ever get here */ |
@@ -1408,7 +1407,7 @@ dtls1_dispatch_alert(SSL *s) | |||
1408 | 1407 | ||
1409 | 1408 | ||
1410 | static DTLS1_BITMAP * | 1409 | static DTLS1_BITMAP * |
1411 | dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr, unsigned int *is_next_epoch) | 1410 | dtls1_get_bitmap(SSL *s, SSL3_RECORD_INTERNAL *rr, unsigned int *is_next_epoch) |
1412 | { | 1411 | { |
1413 | 1412 | ||
1414 | *is_next_epoch = 0; | 1413 | *is_next_epoch = 0; |
diff --git a/src/lib/libssl/dtls1.h b/src/lib/libssl/dtls1.h index cc672a5934..1ed7c2dc30 100644 --- a/src/lib/libssl/dtls1.h +++ b/src/lib/libssl/dtls1.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dtls1.h,v 1.22 2018/08/24 19:35:05 jsing Exp $ */ | 1 | /* $OpenBSD: dtls1.h,v 1.23 2020/03/12 17:01:53 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. |
@@ -161,6 +161,8 @@ typedef struct dtls1_state_st { | |||
161 | struct dtls1_state_internal_st *internal; | 161 | struct dtls1_state_internal_st *internal; |
162 | } DTLS1_STATE; | 162 | } DTLS1_STATE; |
163 | 163 | ||
164 | #ifndef LIBRESSL_INTERNAL | ||
165 | |||
164 | typedef struct dtls1_record_data_st { | 166 | typedef struct dtls1_record_data_st { |
165 | unsigned char *packet; | 167 | unsigned char *packet; |
166 | unsigned int packet_length; | 168 | unsigned int packet_length; |
@@ -170,6 +172,8 @@ typedef struct dtls1_record_data_st { | |||
170 | 172 | ||
171 | #endif | 173 | #endif |
172 | 174 | ||
175 | #endif | ||
176 | |||
173 | /* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ | 177 | /* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ |
174 | #define DTLS1_TMO_READ_COUNT 2 | 178 | #define DTLS1_TMO_READ_COUNT 2 |
175 | #define DTLS1_TMO_WRITE_COUNT 2 | 179 | #define DTLS1_TMO_WRITE_COUNT 2 |
diff --git a/src/lib/libssl/s3_cbc.c b/src/lib/libssl/s3_cbc.c index 4b66e1f17a..371c68cfcc 100644 --- a/src/lib/libssl/s3_cbc.c +++ b/src/lib/libssl/s3_cbc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_cbc.c,v 1.18 2020/02/21 16:07:00 jsing Exp $ */ | 1 | /* $OpenBSD: s3_cbc.c,v 1.19 2020/03/12 17:01:53 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2012 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2012 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -113,8 +113,8 @@ constant_time_eq_8(unsigned a, unsigned b) | |||
113 | * 1: if the padding was valid | 113 | * 1: if the padding was valid |
114 | * -1: otherwise. */ | 114 | * -1: otherwise. */ |
115 | int | 115 | int |
116 | tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size, | 116 | tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD_INTERNAL *rec, |
117 | unsigned mac_size) | 117 | unsigned block_size, unsigned mac_size) |
118 | { | 118 | { |
119 | unsigned padding_length, good, to_check, i; | 119 | unsigned padding_length, good, to_check, i; |
120 | const unsigned overhead = 1 /* padding length byte */ + mac_size; | 120 | const unsigned overhead = 1 /* padding length byte */ + mac_size; |
@@ -194,7 +194,7 @@ tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size, | |||
194 | #define CBC_MAC_ROTATE_IN_PLACE | 194 | #define CBC_MAC_ROTATE_IN_PLACE |
195 | 195 | ||
196 | void | 196 | void |
197 | ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD *rec, | 197 | ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD_INTERNAL *rec, |
198 | unsigned md_size, unsigned orig_len) | 198 | unsigned md_size, unsigned orig_len) |
199 | { | 199 | { |
200 | #if defined(CBC_MAC_ROTATE_IN_PLACE) | 200 | #if defined(CBC_MAC_ROTATE_IN_PLACE) |
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h index cadf7fd387..30dc4c5d7d 100644 --- a/src/lib/libssl/ssl3.h +++ b/src/lib/libssl/ssl3.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl3.h,v 1.49 2018/11/08 22:28:52 jsing Exp $ */ | 1 | /* $OpenBSD: ssl3.h,v 1.50 2020/03/12 17:01:53 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 | * |
@@ -314,6 +314,7 @@ extern "C" { | |||
314 | #define TLS1_HB_RESPONSE 2 | 314 | #define TLS1_HB_RESPONSE 2 |
315 | 315 | ||
316 | #ifndef OPENSSL_NO_SSL_INTERN | 316 | #ifndef OPENSSL_NO_SSL_INTERN |
317 | #ifndef LIBRESSL_INTERNAL | ||
317 | 318 | ||
318 | typedef struct ssl3_record_st { | 319 | typedef struct ssl3_record_st { |
319 | /*r */ int type; /* type of record */ | 320 | /*r */ int type; /* type of record */ |
@@ -334,6 +335,7 @@ typedef struct ssl3_buffer_st { | |||
334 | } SSL3_BUFFER; | 335 | } SSL3_BUFFER; |
335 | 336 | ||
336 | #endif | 337 | #endif |
338 | #endif | ||
337 | 339 | ||
338 | #define SSL3_CT_RSA_SIGN 1 | 340 | #define SSL3_CT_RSA_SIGN 1 |
339 | #define SSL3_CT_DSS_SIGN 2 | 341 | #define SSL3_CT_DSS_SIGN 2 |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index 77c1a51798..a696ef99b1 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.267 2020/03/10 17:02:21 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.268 2020/03/12 17:01:53 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 | * |
@@ -776,6 +776,24 @@ typedef struct ssl_internal_st { | |||
776 | int empty_record_count; | 776 | int empty_record_count; |
777 | } SSL_INTERNAL; | 777 | } SSL_INTERNAL; |
778 | 778 | ||
779 | typedef struct ssl3_record_internal_st { | ||
780 | int type; /* type of record */ | ||
781 | unsigned int length; /* How many bytes available */ | ||
782 | unsigned int off; /* read/write offset into 'buf' */ | ||
783 | unsigned char *data; /* pointer to the record data */ | ||
784 | unsigned char *input; /* where the decode bytes are */ | ||
785 | unsigned long epoch; /* epoch number, needed by DTLS1 */ | ||
786 | unsigned char seq_num[8]; /* sequence number, needed by DTLS1 */ | ||
787 | } SSL3_RECORD_INTERNAL; | ||
788 | |||
789 | typedef struct ssl3_buffer_internal_st { | ||
790 | unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, | ||
791 | * see ssl3_setup_buffers() */ | ||
792 | size_t len; /* buffer size */ | ||
793 | int offset; /* where to 'copy from' */ | ||
794 | int left; /* how many bytes left */ | ||
795 | } SSL3_BUFFER_INTERNAL; | ||
796 | |||
779 | typedef struct ssl3_state_internal_st { | 797 | typedef struct ssl3_state_internal_st { |
780 | unsigned char read_sequence[SSL3_SEQUENCE_SIZE]; | 798 | unsigned char read_sequence[SSL3_SEQUENCE_SIZE]; |
781 | int read_mac_secret_size; | 799 | int read_mac_secret_size; |
@@ -784,8 +802,8 @@ typedef struct ssl3_state_internal_st { | |||
784 | int write_mac_secret_size; | 802 | int write_mac_secret_size; |
785 | unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; | 803 | unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; |
786 | 804 | ||
787 | SSL3_BUFFER rbuf; /* read IO goes into here */ | 805 | SSL3_BUFFER_INTERNAL rbuf; /* read IO goes into here */ |
788 | SSL3_BUFFER wbuf; /* write IO goes into here */ | 806 | SSL3_BUFFER_INTERNAL wbuf; /* write IO goes into here */ |
789 | 807 | ||
790 | /* we allow one fatal and one warning alert to be outstanding, | 808 | /* we allow one fatal and one warning alert to be outstanding, |
791 | * send close alert via the warning alert */ | 809 | * send close alert via the warning alert */ |
@@ -796,8 +814,8 @@ typedef struct ssl3_state_internal_st { | |||
796 | int need_empty_fragments; | 814 | int need_empty_fragments; |
797 | int empty_fragment_done; | 815 | int empty_fragment_done; |
798 | 816 | ||
799 | SSL3_RECORD rrec; /* each decoded record goes in here */ | 817 | SSL3_RECORD_INTERNAL rrec; /* each decoded record goes in here */ |
800 | SSL3_RECORD wrec; /* goes out from here */ | 818 | SSL3_RECORD_INTERNAL wrec; /* goes out from here */ |
801 | 819 | ||
802 | /* storage for Alert/Handshake protocol data received but not | 820 | /* storage for Alert/Handshake protocol data received but not |
803 | * yet processed by ssl3_read_bytes: */ | 821 | * yet processed by ssl3_read_bytes: */ |
@@ -897,6 +915,13 @@ typedef struct ssl3_state_internal_st { | |||
897 | } SSL3_STATE_INTERNAL; | 915 | } SSL3_STATE_INTERNAL; |
898 | #define S3I(s) (s->s3->internal) | 916 | #define S3I(s) (s->s3->internal) |
899 | 917 | ||
918 | typedef struct dtls1_record_data_internal_st { | ||
919 | unsigned char *packet; | ||
920 | unsigned int packet_length; | ||
921 | SSL3_BUFFER_INTERNAL rbuf; | ||
922 | SSL3_RECORD_INTERNAL rrec; | ||
923 | } DTLS1_RECORD_DATA_INTERNAL; | ||
924 | |||
900 | typedef struct dtls1_state_internal_st { | 925 | typedef struct dtls1_state_internal_st { |
901 | unsigned int send_cookie; | 926 | unsigned int send_cookie; |
902 | unsigned char cookie[DTLS1_COOKIE_LENGTH]; | 927 | unsigned char cookie[DTLS1_COOKIE_LENGTH]; |
@@ -1346,9 +1371,9 @@ long ssl_get_algorithm2(SSL *s); | |||
1346 | int tls1_check_ec_server_key(SSL *s); | 1371 | int tls1_check_ec_server_key(SSL *s); |
1347 | 1372 | ||
1348 | /* s3_cbc.c */ | 1373 | /* s3_cbc.c */ |
1349 | void ssl3_cbc_copy_mac(unsigned char *out, const SSL3_RECORD *rec, | 1374 | void ssl3_cbc_copy_mac(unsigned char *out, const SSL3_RECORD_INTERNAL *rec, |
1350 | unsigned md_size, unsigned orig_len); | 1375 | unsigned md_size, unsigned orig_len); |
1351 | int tls1_cbc_remove_padding(const SSL *s, SSL3_RECORD *rec, | 1376 | int tls1_cbc_remove_padding(const SSL *s, SSL3_RECORD_INTERNAL *rec, |
1352 | unsigned block_size, unsigned mac_size); | 1377 | unsigned block_size, unsigned mac_size); |
1353 | char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); | 1378 | char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); |
1354 | int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char *md_out, | 1379 | int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char *md_out, |
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c index 8126c42d1d..4302794d94 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.21 2020/03/10 17:02:21 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_pkt.c,v 1.22 2020/03/12 17:01:53 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 | * |
@@ -152,7 +152,7 @@ ssl3_read_n(SSL *s, int n, int max, int extend) | |||
152 | int i, len, left; | 152 | int i, len, left; |
153 | size_t align; | 153 | size_t align; |
154 | unsigned char *pkt; | 154 | unsigned char *pkt; |
155 | SSL3_BUFFER *rb; | 155 | SSL3_BUFFER_INTERNAL *rb; |
156 | 156 | ||
157 | if (n <= 0) | 157 | if (n <= 0) |
158 | return n; | 158 | return n; |
@@ -329,7 +329,7 @@ ssl3_get_record(SSL *s) | |||
329 | { | 329 | { |
330 | int al; | 330 | int al; |
331 | int enc_err, n, i, ret = -1; | 331 | int enc_err, n, i, ret = -1; |
332 | SSL3_RECORD *rr; | 332 | SSL3_RECORD_INTERNAL *rr; |
333 | SSL_SESSION *sess; | 333 | SSL_SESSION *sess; |
334 | unsigned char md[EVP_MAX_MD_SIZE]; | 334 | unsigned char md[EVP_MAX_MD_SIZE]; |
335 | unsigned mac_size, orig_len; | 335 | unsigned mac_size, orig_len; |
@@ -360,7 +360,7 @@ ssl3_get_record(SSL *s) | |||
360 | 360 | ||
361 | CBS_init(&header, s->internal->packet, SSL3_RT_HEADER_LENGTH); | 361 | CBS_init(&header, s->internal->packet, SSL3_RT_HEADER_LENGTH); |
362 | 362 | ||
363 | /* Pull apart the header into the SSL3_RECORD */ | 363 | /* Pull apart the header into the SSL3_RECORD_INTERNAL */ |
364 | if (!CBS_get_u8(&header, &type) || | 364 | if (!CBS_get_u8(&header, &type) || |
365 | !CBS_get_u16(&header, &ssl_version) || | 365 | !CBS_get_u16(&header, &ssl_version) || |
366 | !CBS_get_u16(&header, &len)) { | 366 | !CBS_get_u16(&header, &len)) { |
@@ -621,7 +621,7 @@ static int | |||
621 | ssl3_create_record(SSL *s, unsigned char *p, int type, const unsigned char *buf, | 621 | ssl3_create_record(SSL *s, unsigned char *p, int type, const unsigned char *buf, |
622 | unsigned int len) | 622 | unsigned int len) |
623 | { | 623 | { |
624 | SSL3_RECORD *wr = &(S3I(s)->wrec); | 624 | SSL3_RECORD_INTERNAL *wr = &(S3I(s)->wrec); |
625 | SSL_SESSION *sess = s->session; | 625 | SSL_SESSION *sess = s->session; |
626 | int eivlen, mac_size; | 626 | int eivlen, mac_size; |
627 | uint16_t version; | 627 | uint16_t version; |
@@ -729,8 +729,8 @@ ssl3_create_record(SSL *s, unsigned char *p, int type, const unsigned char *buf, | |||
729 | static int | 729 | static int |
730 | do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | 730 | do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) |
731 | { | 731 | { |
732 | SSL3_RECORD *wr = &(S3I(s)->wrec); | 732 | SSL3_RECORD_INTERNAL *wr = &(S3I(s)->wrec); |
733 | SSL3_BUFFER *wb = &(S3I(s)->wbuf); | 733 | SSL3_BUFFER_INTERNAL *wb = &(S3I(s)->wbuf); |
734 | SSL_SESSION *sess = s->session; | 734 | SSL_SESSION *sess = s->session; |
735 | unsigned char *p; | 735 | unsigned char *p; |
736 | int i, clear = 0; | 736 | int i, clear = 0; |
@@ -741,7 +741,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
741 | if (!ssl3_setup_write_buffer(s)) | 741 | if (!ssl3_setup_write_buffer(s)) |
742 | return -1; | 742 | return -1; |
743 | 743 | ||
744 | /* first check if there is a SSL3_BUFFER still being written | 744 | /* first check if there is a SSL3_BUFFER_INTERNAL still being written |
745 | * out. This will happen with non blocking IO */ | 745 | * out. This will happen with non blocking IO */ |
746 | if (wb->left != 0) | 746 | if (wb->left != 0) |
747 | return (ssl3_write_pending(s, type, buf, len)); | 747 | return (ssl3_write_pending(s, type, buf, len)); |
@@ -830,7 +830,7 @@ int | |||
830 | ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) | 830 | ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) |
831 | { | 831 | { |
832 | int i; | 832 | int i; |
833 | SSL3_BUFFER *wb = &(S3I(s)->wbuf); | 833 | SSL3_BUFFER_INTERNAL *wb = &(S3I(s)->wbuf); |
834 | 834 | ||
835 | /* XXXX */ | 835 | /* XXXX */ |
836 | if ((S3I(s)->wpend_tot > (int)len) || ((S3I(s)->wpend_buf != buf) && | 836 | if ((S3I(s)->wpend_tot > (int)len) || ((S3I(s)->wpend_buf != buf) && |
@@ -906,7 +906,7 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
906 | void (*cb)(const SSL *ssl, int type2, int val) = NULL; | 906 | void (*cb)(const SSL *ssl, int type2, int val) = NULL; |
907 | int al, i, j, ret, rrcount = 0; | 907 | int al, i, j, ret, rrcount = 0; |
908 | unsigned int n; | 908 | unsigned int n; |
909 | SSL3_RECORD *rr; | 909 | SSL3_RECORD_INTERNAL *rr; |
910 | 910 | ||
911 | if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */ | 911 | if (S3I(s)->rbuf.buf == NULL) /* Not initialized yet */ |
912 | if (!ssl3_setup_read_buffer(s)) | 912 | if (!ssl3_setup_read_buffer(s)) |
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index 1eaa087383..b399f2bd3c 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t1_enc.c,v 1.118 2019/05/13 22:48:30 bcook Exp $ */ | 1 | /* $OpenBSD: t1_enc.c,v 1.119 2020/03/12 17:01:53 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 | * |
@@ -668,7 +668,7 @@ tls1_enc(SSL *s, int send) | |||
668 | const SSL_AEAD_CTX *aead; | 668 | const SSL_AEAD_CTX *aead; |
669 | const EVP_CIPHER *enc; | 669 | const EVP_CIPHER *enc; |
670 | EVP_CIPHER_CTX *ds; | 670 | EVP_CIPHER_CTX *ds; |
671 | SSL3_RECORD *rec; | 671 | SSL3_RECORD_INTERNAL *rec; |
672 | unsigned char *seq; | 672 | unsigned char *seq; |
673 | unsigned long l; | 673 | unsigned long l; |
674 | int bs, i, j, k, ret, mac_size = 0; | 674 | int bs, i, j, k, ret, mac_size = 0; |
@@ -931,7 +931,7 @@ tls1_final_finish_mac(SSL *s, const char *str, int str_len, unsigned char *out) | |||
931 | int | 931 | int |
932 | tls1_mac(SSL *ssl, unsigned char *md, int send) | 932 | tls1_mac(SSL *ssl, unsigned char *md, int send) |
933 | { | 933 | { |
934 | SSL3_RECORD *rec; | 934 | SSL3_RECORD_INTERNAL *rec; |
935 | unsigned char *seq; | 935 | unsigned char *seq; |
936 | EVP_MD_CTX *hash; | 936 | EVP_MD_CTX *hash; |
937 | size_t md_size, orig_len; | 937 | size_t md_size, orig_len; |