diff options
author | jsing <> | 2020-03-10 17:02:21 +0000 |
---|---|---|
committer | jsing <> | 2020-03-10 17:02:21 +0000 |
commit | 2fc4169a1040fb41912043d6a402741eceda793f (patch) | |
tree | 2214ec4c580fdd9fa5d8199893b2deab09b04e8c /src | |
parent | fb8d28aeb36c4bb18f6fcbfcdb61a6ba1099d7c0 (diff) | |
download | openbsd-2fc4169a1040fb41912043d6a402741eceda793f.tar.gz openbsd-2fc4169a1040fb41912043d6a402741eceda793f.tar.bz2 openbsd-2fc4169a1040fb41912043d6a402741eceda793f.zip |
Remove the enc function pointers.
The enc function pointers do not serve any purpose these days - remove
a layer of indirection and call dtls1_enc()/tls1_enc() directly.
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/d1_lib.c | 3 | ||||
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 10 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_pkt.c | 10 | ||||
-rw-r--r-- | src/lib/libssl/t1_lib.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/tls13_legacy.c | 3 |
6 files changed, 12 insertions, 22 deletions
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c index 45bbd9b45d..6171035d23 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.43 2020/02/21 16:12:18 jsing Exp $ */ | 1 | /* $OpenBSD: d1_lib.c,v 1.44 2020/03/10 17:02:21 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. |
@@ -73,7 +73,6 @@ | |||
73 | static int dtls1_listen(SSL *s, struct sockaddr *client); | 73 | static int dtls1_listen(SSL *s, struct sockaddr *client); |
74 | 74 | ||
75 | SSL3_ENC_METHOD DTLSv1_enc_data = { | 75 | SSL3_ENC_METHOD DTLSv1_enc_data = { |
76 | .enc = dtls1_enc, | ||
77 | .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV, | 76 | .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV, |
78 | }; | 77 | }; |
79 | 78 | ||
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 2cb2d089c8..101017449c 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.69 2020/02/21 16:15:56 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.70 2020/03/10 17:02:21 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. |
@@ -361,19 +361,17 @@ dtls1_process_record(SSL *s) | |||
361 | /* decrypt in place in 'rr->input' */ | 361 | /* decrypt in place in 'rr->input' */ |
362 | rr->data = rr->input; | 362 | rr->data = rr->input; |
363 | 363 | ||
364 | enc_err = s->method->internal->ssl3_enc->enc(s, 0); | ||
365 | /* enc_err is: | 364 | /* enc_err is: |
366 | * 0: (in non-constant time) if the record is publically invalid. | 365 | * 0: (in non-constant time) if the record is publically invalid. |
367 | * 1: if the padding is valid | 366 | * 1: if the padding is valid |
368 | * -1: if the padding is invalid */ | 367 | * -1: if the padding is invalid */ |
369 | if (enc_err == 0) { | 368 | if ((enc_err = dtls1_enc(s, 0)) == 0) { |
370 | /* For DTLS we simply ignore bad packets. */ | 369 | /* For DTLS we simply ignore bad packets. */ |
371 | rr->length = 0; | 370 | rr->length = 0; |
372 | s->internal->packet_length = 0; | 371 | s->internal->packet_length = 0; |
373 | goto err; | 372 | goto err; |
374 | } | 373 | } |
375 | 374 | ||
376 | |||
377 | /* r->length is now the compressed data plus mac */ | 375 | /* r->length is now the compressed data plus mac */ |
378 | if ((sess != NULL) && (s->enc_read_ctx != NULL) && | 376 | if ((sess != NULL) && (s->enc_read_ctx != NULL) && |
379 | (EVP_MD_CTX_md(s->read_hash) != NULL)) { | 377 | (EVP_MD_CTX_md(s->read_hash) != NULL)) { |
@@ -1286,8 +1284,8 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
1286 | wr->length += bs; | 1284 | wr->length += bs; |
1287 | } | 1285 | } |
1288 | 1286 | ||
1289 | /* ssl3_enc can only have an error on read */ | 1287 | /* dtls1_enc can only have an error on read */ |
1290 | s->method->internal->ssl3_enc->enc(s, 1); | 1288 | dtls1_enc(s, 1); |
1291 | 1289 | ||
1292 | if (!CBB_add_u16(&cbb, wr->length)) | 1290 | if (!CBB_add_u16(&cbb, wr->length)) |
1293 | goto err; | 1291 | goto err; |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index b254ee59a8..77c1a51798 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.266 2020/02/21 16:18:52 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.267 2020/03/10 17:02:21 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 | * |
@@ -1013,7 +1013,6 @@ typedef struct sess_cert_st { | |||
1013 | /*#define RSA_DEBUG */ | 1013 | /*#define RSA_DEBUG */ |
1014 | 1014 | ||
1015 | typedef struct ssl3_enc_method { | 1015 | typedef struct ssl3_enc_method { |
1016 | int (*enc)(SSL *, int); | ||
1017 | unsigned int enc_flags; | 1016 | unsigned int enc_flags; |
1018 | } SSL3_ENC_METHOD; | 1017 | } SSL3_ENC_METHOD; |
1019 | 1018 | ||
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c index c6ec67545d..8126c42d1d 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.20 2020/02/23 17:59:03 tb Exp $ */ | 1 | /* $OpenBSD: ssl_pkt.c,v 1.21 2020/03/10 17:02:21 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 | * |
@@ -431,18 +431,16 @@ ssl3_get_record(SSL *s) | |||
431 | /* decrypt in place in 'rr->input' */ | 431 | /* decrypt in place in 'rr->input' */ |
432 | rr->data = rr->input; | 432 | rr->data = rr->input; |
433 | 433 | ||
434 | enc_err = s->method->internal->ssl3_enc->enc(s, 0); | ||
435 | /* enc_err is: | 434 | /* enc_err is: |
436 | * 0: (in non-constant time) if the record is publically invalid. | 435 | * 0: (in non-constant time) if the record is publically invalid. |
437 | * 1: if the padding is valid | 436 | * 1: if the padding is valid |
438 | * -1: if the padding is invalid */ | 437 | * -1: if the padding is invalid */ |
439 | if (enc_err == 0) { | 438 | if ((enc_err = tls1_enc(s, 0)) == 0) { |
440 | al = SSL_AD_BAD_RECORD_MAC; | 439 | al = SSL_AD_BAD_RECORD_MAC; |
441 | SSLerror(s, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); | 440 | SSLerror(s, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); |
442 | goto f_err; | 441 | goto f_err; |
443 | } | 442 | } |
444 | 443 | ||
445 | |||
446 | /* r->length is now the compressed data plus mac */ | 444 | /* r->length is now the compressed data plus mac */ |
447 | if ((sess != NULL) && (s->enc_read_ctx != NULL) && | 445 | if ((sess != NULL) && (s->enc_read_ctx != NULL) && |
448 | (EVP_MD_CTX_md(s->read_hash) != NULL)) { | 446 | (EVP_MD_CTX_md(s->read_hash) != NULL)) { |
@@ -705,8 +703,8 @@ ssl3_create_record(SSL *s, unsigned char *p, int type, const unsigned char *buf, | |||
705 | wr->length += eivlen; | 703 | wr->length += eivlen; |
706 | } | 704 | } |
707 | 705 | ||
708 | /* ssl3_enc can only have an error on read */ | 706 | /* tls1_enc can only have an error on read */ |
709 | s->method->internal->ssl3_enc->enc(s, 1); | 707 | tls1_enc(s, 1); |
710 | 708 | ||
711 | /* record length after mac and block padding */ | 709 | /* record length after mac and block padding */ |
712 | if (!CBB_add_u16(&cbb, wr->length)) | 710 | if (!CBB_add_u16(&cbb, wr->length)) |
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c index 162cfe5ebb..b265ea089f 100644 --- a/src/lib/libssl/t1_lib.c +++ b/src/lib/libssl/t1_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t1_lib.c,v 1.164 2019/04/25 04:57:36 jsing Exp $ */ | 1 | /* $OpenBSD: t1_lib.c,v 1.165 2020/03/10 17:02:21 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 | * |
@@ -126,17 +126,14 @@ static int tls_decrypt_ticket(SSL *s, CBS *session_id, CBS *ticket, | |||
126 | SSL_SESSION **psess); | 126 | SSL_SESSION **psess); |
127 | 127 | ||
128 | SSL3_ENC_METHOD TLSv1_enc_data = { | 128 | SSL3_ENC_METHOD TLSv1_enc_data = { |
129 | .enc = tls1_enc, | ||
130 | .enc_flags = 0, | 129 | .enc_flags = 0, |
131 | }; | 130 | }; |
132 | 131 | ||
133 | SSL3_ENC_METHOD TLSv1_1_enc_data = { | 132 | SSL3_ENC_METHOD TLSv1_1_enc_data = { |
134 | .enc = tls1_enc, | ||
135 | .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV, | 133 | .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV, |
136 | }; | 134 | }; |
137 | 135 | ||
138 | SSL3_ENC_METHOD TLSv1_2_enc_data = { | 136 | SSL3_ENC_METHOD TLSv1_2_enc_data = { |
139 | .enc = tls1_enc, | ||
140 | .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV|SSL_ENC_FLAG_SIGALGS| | 137 | .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV|SSL_ENC_FLAG_SIGALGS| |
141 | SSL_ENC_FLAG_SHA256_PRF|SSL_ENC_FLAG_TLS1_2_CIPHERS, | 138 | SSL_ENC_FLAG_SHA256_PRF|SSL_ENC_FLAG_TLS1_2_CIPHERS, |
142 | }; | 139 | }; |
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c index 642374af92..747bdc2728 100644 --- a/src/lib/libssl/tls13_legacy.c +++ b/src/lib/libssl/tls13_legacy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_legacy.c,v 1.1 2020/02/15 14:40:38 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_legacy.c,v 1.2 2020/03/10 17:02:21 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -21,7 +21,6 @@ | |||
21 | #include "tls13_internal.h" | 21 | #include "tls13_internal.h" |
22 | 22 | ||
23 | SSL3_ENC_METHOD TLSv1_3_enc_data = { | 23 | SSL3_ENC_METHOD TLSv1_3_enc_data = { |
24 | .enc = NULL, | ||
25 | .enc_flags = SSL_ENC_FLAG_SIGALGS|SSL_ENC_FLAG_TLS1_3_CIPHERS, | 24 | .enc_flags = SSL_ENC_FLAG_SIGALGS|SSL_ENC_FLAG_TLS1_3_CIPHERS, |
26 | }; | 25 | }; |
27 | 26 | ||