summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_tlsext.c
diff options
context:
space:
mode:
authorjsing <>2019-03-25 17:21:18 +0000
committerjsing <>2019-03-25 17:21:18 +0000
commite54e43a6f31368338de68eeea77a87ad2be5b85f (patch)
treeeb5e58a5d9b8198b8475b96156e908c92c86e532 /src/lib/libssl/ssl_tlsext.c
parentd6a095cfa3d05c1eea376148faa4717ae6179ef0 (diff)
downloadopenbsd-e54e43a6f31368338de68eeea77a87ad2be5b85f.tar.gz
openbsd-e54e43a6f31368338de68eeea77a87ad2be5b85f.tar.bz2
openbsd-e54e43a6f31368338de68eeea77a87ad2be5b85f.zip
Defer sigalgs selection until the certificate is known.
Previously the signature algorithm was selected when the TLS extension was parsed (or the client received a certificate request), however the actual certificate to be used is not known at this stage. This leads to various problems, including the selection of a signature algorithm that cannot be used with the certificate key size (as found by jeremy@ via ruby regress). Instead, store the signature algorithms list and only select a signature algorithm when we're ready to do signature generation. Joint work with beck@.
Diffstat (limited to 'src/lib/libssl/ssl_tlsext.c')
-rw-r--r--src/lib/libssl/ssl_tlsext.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index de9fabd4c7..0e37cc3cc0 100644
--- a/src/lib/libssl/ssl_tlsext.c
+++ b/src/lib/libssl/ssl_tlsext.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_tlsext.c,v 1.43 2019/03/19 16:53:03 jsing Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.44 2019/03/25 17:21:18 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -556,19 +556,16 @@ tlsext_sigalgs_client_build(SSL *s, CBB *cbb)
556int 556int
557tlsext_sigalgs_server_parse(SSL *s, CBS *cbs, int *alert) 557tlsext_sigalgs_server_parse(SSL *s, CBS *cbs, int *alert)
558{ 558{
559 uint16_t *tls_sigalgs = tls12_sigalgs;
560 size_t tls_sigalgs_len = tls12_sigalgs_len;
561 CBS sigalgs; 559 CBS sigalgs;
562 560
563 if (s->version >= TLS1_3_VERSION) {
564 tls_sigalgs = tls13_sigalgs;
565 tls_sigalgs_len = tls13_sigalgs_len;
566 }
567
568 if (!CBS_get_u16_length_prefixed(cbs, &sigalgs)) 561 if (!CBS_get_u16_length_prefixed(cbs, &sigalgs))
569 return 0; 562 return 0;
563 if (CBS_len(&sigalgs) % 2 != 0 || CBS_len(&sigalgs) > 64)
564 return 0;
565 if (!CBS_stow(&sigalgs, &S3I(s)->hs.sigalgs, &S3I(s)->hs.sigalgs_len))
566 return 0;
570 567
571 return tls1_process_sigalgs(s, &sigalgs, tls_sigalgs, tls_sigalgs_len); 568 return 1;
572} 569}
573 570
574int 571int