diff options
author | jsing <> | 2020-03-12 17:09:02 +0000 |
---|---|---|
committer | jsing <> | 2020-03-12 17:09:02 +0000 |
commit | 8a5e591492888ac3f5e804aaef546ffe93f39818 (patch) | |
tree | 61a0513c2ec7ebe3d441481d66f9efe8b9bba584 | |
parent | cf38ddcaf43a2f6fd1de2405aa74feca6523733c (diff) | |
download | openbsd-8a5e591492888ac3f5e804aaef546ffe93f39818.tar.gz openbsd-8a5e591492888ac3f5e804aaef546ffe93f39818.tar.bz2 openbsd-8a5e591492888ac3f5e804aaef546ffe93f39818.zip |
Stop overloading the record type for padding length.
Currently the CBC related code stuffs the padding length in the upper bits
of the type field... stop doing that and add a padding_length field to the
record struct instead.
ok inoguchi@ tb@
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/s3_cbc.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_pkt.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/t1_enc.c | 6 |
5 files changed, 10 insertions, 13 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 31415b7c3a..524cfc3351 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.71 2020/03/12 17:01:53 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.72 2020/03/12 17:09:02 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. |
@@ -380,8 +380,7 @@ dtls1_process_record(SSL *s) | |||
380 | mac_size = EVP_MD_CTX_size(s->read_hash); | 380 | mac_size = EVP_MD_CTX_size(s->read_hash); |
381 | OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); | 381 | OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); |
382 | 382 | ||
383 | /* kludge: *_cbc_remove_padding passes padding length in rr->type */ | 383 | orig_len = rr->length + rr->padding_length; |
384 | orig_len = rr->length + ((unsigned int)rr->type >> 8); | ||
385 | 384 | ||
386 | /* orig_len is the length of the record before any padding was | 385 | /* orig_len is the length of the record before any padding was |
387 | * removed. This is public information, as is the MAC in use, | 386 | * removed. This is public information, as is the MAC in use, |
diff --git a/src/lib/libssl/s3_cbc.c b/src/lib/libssl/s3_cbc.c index 371c68cfcc..8ae87d7303 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.19 2020/03/12 17:01:53 jsing Exp $ */ | 1 | /* $OpenBSD: s3_cbc.c,v 1.20 2020/03/12 17:09:02 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 | * |
@@ -169,7 +169,7 @@ tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD_INTERNAL *rec, | |||
169 | 169 | ||
170 | padding_length = good & (padding_length + 1); | 170 | padding_length = good & (padding_length + 1); |
171 | rec->length -= padding_length; | 171 | rec->length -= padding_length; |
172 | rec->type |= padding_length<<8; /* kludge: pass padding length */ | 172 | rec->padding_length = padding_length; |
173 | 173 | ||
174 | return (int)((good & 1) | (~good & -1)); | 174 | return (int)((good & 1) | (~good & -1)); |
175 | } | 175 | } |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index a696ef99b1..6604768485 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.268 2020/03/12 17:01:53 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.269 2020/03/12 17:09:02 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 | * |
@@ -779,6 +779,7 @@ typedef struct ssl_internal_st { | |||
779 | typedef struct ssl3_record_internal_st { | 779 | typedef struct ssl3_record_internal_st { |
780 | int type; /* type of record */ | 780 | int type; /* type of record */ |
781 | unsigned int length; /* How many bytes available */ | 781 | unsigned int length; /* How many bytes available */ |
782 | unsigned int padding_length; /* Number of padding bytes. */ | ||
782 | unsigned int off; /* read/write offset into 'buf' */ | 783 | unsigned int off; /* read/write offset into 'buf' */ |
783 | unsigned char *data; /* pointer to the record data */ | 784 | unsigned char *data; /* pointer to the record data */ |
784 | unsigned char *input; /* where the decode bytes are */ | 785 | unsigned char *input; /* where the decode bytes are */ |
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c index 4302794d94..0d1d4f78c7 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.22 2020/03/12 17:01:53 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_pkt.c,v 1.23 2020/03/12 17:09:02 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 | * |
@@ -451,8 +451,7 @@ ssl3_get_record(SSL *s) | |||
451 | mac_size = EVP_MD_CTX_size(s->read_hash); | 451 | mac_size = EVP_MD_CTX_size(s->read_hash); |
452 | OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); | 452 | OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); |
453 | 453 | ||
454 | /* kludge: *_cbc_remove_padding passes padding length in rr->type */ | 454 | orig_len = rr->length + rr->padding_length; |
455 | orig_len = rr->length + ((unsigned int)rr->type >> 8); | ||
456 | 455 | ||
457 | /* orig_len is the length of the record before any padding was | 456 | /* orig_len is the length of the record before any padding was |
458 | * removed. This is public information, as is the MAC in use, | 457 | * removed. This is public information, as is the MAC in use, |
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index b399f2bd3c..347d34d455 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.119 2020/03/12 17:01:53 jsing Exp $ */ | 1 | /* $OpenBSD: t1_enc.c,v 1.120 2020/03/12 17:09:02 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 | * |
@@ -971,9 +971,7 @@ tls1_mac(SSL *ssl, unsigned char *md, int send) | |||
971 | else | 971 | else |
972 | memcpy(header, seq, SSL3_SEQUENCE_SIZE); | 972 | memcpy(header, seq, SSL3_SEQUENCE_SIZE); |
973 | 973 | ||
974 | /* kludge: tls1_cbc_remove_padding passes padding length in rec->type */ | 974 | orig_len = rec->length + md_size + rec->padding_length; |
975 | orig_len = rec->length + md_size + ((unsigned int)rec->type >> 8); | ||
976 | rec->type &= 0xff; | ||
977 | 975 | ||
978 | header[8] = rec->type; | 976 | header[8] = rec->type; |
979 | header[9] = (unsigned char)(ssl->version >> 8); | 977 | header[9] = (unsigned char)(ssl->version >> 8); |