diff options
| author | jsing <> | 2020-04-21 16:55:17 +0000 |
|---|---|---|
| committer | jsing <> | 2020-04-21 16:55:17 +0000 |
| commit | 42c5871ed78a8963973e34ae0a824160f749b262 (patch) | |
| tree | 594de8fcf4c008ddd95ad2790318a2c619af7a78 | |
| parent | fab181bd11bd26ebdc8c777b21768f05fcc6d7e1 (diff) | |
| download | openbsd-42c5871ed78a8963973e34ae0a824160f749b262.tar.gz openbsd-42c5871ed78a8963973e34ae0a824160f749b262.tar.bz2 openbsd-42c5871ed78a8963973e34ae0a824160f749b262.zip | |
Consolidate TLSv1.3 constants.
Move all of the TLSv1.3 constants to the top of tls13_lib.c. Also mark
these all as const so that they end up in .rodata rather than .data.
ok tb@
| -rw-r--r-- | src/lib/libssl/tls13_client.c | 12 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_internal.h | 13 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_lib.c | 62 |
3 files changed, 47 insertions, 40 deletions
diff --git a/src/lib/libssl/tls13_client.c b/src/lib/libssl/tls13_client.c index 5cd588875e..0da08f62c3 100644 --- a/src/lib/libssl/tls13_client.c +++ b/src/lib/libssl/tls13_client.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_client.c,v 1.49 2020/04/17 17:16:53 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_client.c,v 1.50 2020/04/21 16:55:17 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 | * |
| @@ -251,16 +251,6 @@ tls13_client_hello_sent(struct tls13_ctx *ctx) | |||
| 251 | return 1; | 251 | return 1; |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | /* | ||
| 255 | * HelloRetryRequest hash - RFC 8446 section 4.1.3. | ||
| 256 | */ | ||
| 257 | static const uint8_t tls13_hello_retry_request_hash[] = { | ||
| 258 | 0xcf, 0x21, 0xad, 0x74, 0xe5, 0x9a, 0x61, 0x11, | ||
| 259 | 0xbe, 0x1d, 0x8c, 0x02, 0x1e, 0x65, 0xb8, 0x91, | ||
| 260 | 0xc2, 0xa2, 0x11, 0x16, 0x7a, 0xbb, 0x8c, 0x5e, | ||
| 261 | 0x07, 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c, | ||
| 262 | }; | ||
| 263 | |||
| 264 | static int | 254 | static int |
| 265 | tls13_server_hello_is_legacy(CBS *cbs) | 255 | tls13_server_hello_is_legacy(CBS *cbs) |
| 266 | { | 256 | { |
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index 6f5f5197d0..c5b893bc16 100644 --- a/src/lib/libssl/tls13_internal.h +++ b/src/lib/libssl/tls13_internal.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_internal.h,v 1.63 2020/04/18 14:07:56 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.64 2020/04/21 16:55:17 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
| 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
| @@ -339,11 +339,12 @@ int tls13_error_setx(struct tls13_error *error, int code, int subcode, | |||
| 339 | tls13_error_setx(&(ctx)->error, (code), (subcode), __FILE__, __LINE__, \ | 339 | tls13_error_setx(&(ctx)->error, (code), (subcode), __FILE__, __LINE__, \ |
| 340 | (fmt), __VA_ARGS__) | 340 | (fmt), __VA_ARGS__) |
| 341 | 341 | ||
| 342 | extern uint8_t tls13_downgrade_12[8]; | 342 | extern const uint8_t tls13_downgrade_12[8]; |
| 343 | extern uint8_t tls13_downgrade_11[8]; | 343 | extern const uint8_t tls13_downgrade_11[8]; |
| 344 | extern uint8_t tls13_cert_verify_pad[64]; | 344 | extern const uint8_t tls13_hello_retry_request_hash[32]; |
| 345 | extern uint8_t tls13_cert_client_verify_context[]; | 345 | extern const uint8_t tls13_cert_verify_pad[64]; |
| 346 | extern uint8_t tls13_cert_server_verify_context[]; | 346 | extern const uint8_t tls13_cert_client_verify_context[]; |
| 347 | extern const uint8_t tls13_cert_server_verify_context[]; | ||
| 347 | 348 | ||
| 348 | __END_HIDDEN_DECLS | 349 | __END_HIDDEN_DECLS |
| 349 | 350 | ||
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index bdf547c8d9..044a0c5634 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_lib.c,v 1.34 2020/02/15 14:40:38 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.35 2020/04/21 16:55:17 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 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> |
| @@ -24,12 +24,45 @@ | |||
| 24 | #include "tls13_internal.h" | 24 | #include "tls13_internal.h" |
| 25 | 25 | ||
| 26 | /* | 26 | /* |
| 27 | * RFC 8446 section 4.1.3, magic values which must be set by the | 27 | * Downgrade sentinels - RFC 8446 section 4.1.3, magic values which must be set |
| 28 | * server in server random if it is willing to downgrade but supports | 28 | * by the server in server random if it is willing to downgrade but supports |
| 29 | * tls v1.3 | 29 | * TLSv1.3 |
| 30 | */ | 30 | */ |
| 31 | uint8_t tls13_downgrade_12[8] = {0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x01}; | 31 | const uint8_t tls13_downgrade_12[8] = { |
| 32 | uint8_t tls13_downgrade_11[8] = {0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x00}; | 32 | 0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x01, |
| 33 | }; | ||
| 34 | const uint8_t tls13_downgrade_11[8] = { | ||
| 35 | 0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x00, | ||
| 36 | }; | ||
| 37 | |||
| 38 | /* | ||
| 39 | * HelloRetryRequest hash - RFC 8446 section 4.1.3. | ||
| 40 | */ | ||
| 41 | const uint8_t tls13_hello_retry_request_hash[32] = { | ||
| 42 | 0xcf, 0x21, 0xad, 0x74, 0xe5, 0x9a, 0x61, 0x11, | ||
| 43 | 0xbe, 0x1d, 0x8c, 0x02, 0x1e, 0x65, 0xb8, 0x91, | ||
| 44 | 0xc2, 0xa2, 0x11, 0x16, 0x7a, 0xbb, 0x8c, 0x5e, | ||
| 45 | 0x07, 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c, | ||
| 46 | }; | ||
| 47 | |||
| 48 | /* | ||
| 49 | * Certificate Verify padding - RFC 8446 section 4.4.3. | ||
| 50 | */ | ||
| 51 | const uint8_t tls13_cert_verify_pad[64] = { | ||
| 52 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 53 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 54 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 55 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 56 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 57 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 58 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 59 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 60 | }; | ||
| 61 | |||
| 62 | const uint8_t tls13_cert_client_verify_context[] = | ||
| 63 | "TLS 1.3, client CertificateVerify"; | ||
| 64 | const uint8_t tls13_cert_server_verify_context[] = | ||
| 65 | "TLS 1.3, server CertificateVerify"; | ||
| 33 | 66 | ||
| 34 | const EVP_AEAD * | 67 | const EVP_AEAD * |
| 35 | tls13_cipher_aead(const SSL_CIPHER *cipher) | 68 | tls13_cipher_aead(const SSL_CIPHER *cipher) |
| @@ -311,23 +344,6 @@ tls13_ctx_free(struct tls13_ctx *ctx) | |||
| 311 | freezero(ctx, sizeof(struct tls13_ctx)); | 344 | freezero(ctx, sizeof(struct tls13_ctx)); |
| 312 | } | 345 | } |
| 313 | 346 | ||
| 314 | /* | ||
| 315 | * Certificate Verify padding - RFC 8446 section 4.4.3. | ||
| 316 | */ | ||
| 317 | uint8_t tls13_cert_verify_pad[64] = { | ||
| 318 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 319 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 320 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 321 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 322 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 323 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 324 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 325 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
| 326 | }; | ||
| 327 | |||
| 328 | uint8_t tls13_cert_client_verify_context[] = "TLS 1.3, client CertificateVerify"; | ||
| 329 | uint8_t tls13_cert_server_verify_context[] = "TLS 1.3, server CertificateVerify"; | ||
| 330 | |||
| 331 | int | 347 | int |
| 332 | tls13_cert_add(CBB *cbb, X509 *cert) | 348 | tls13_cert_add(CBB *cbb, X509 *cert) |
| 333 | { | 349 | { |
