summaryrefslogtreecommitdiffstats
path: root/lib/libssl/d1_both.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2016-12-06 13:38:11 +0000
committerjsing <jsing@openbsd.org>2016-12-06 13:38:11 +0000
commite77172482eaed607d24ac90b9055e6eca4090b2f (patch)
tree2b03bbf30fc4e7add94a5bb866df6fda03b61117 /lib/libssl/d1_both.c
parentConvert certificate handshake message generation to CBB, with some clean (diff)
downloadwireguard-openbsd-e77172482eaed607d24ac90b9055e6eca4090b2f.tar.xz
wireguard-openbsd-e77172482eaed607d24ac90b9055e6eca4090b2f.zip
Now that ssl3_send_{client,server}_certificate() are using the common
handshake functions, we can remove more copied code from DTLS.
Diffstat (limited to 'lib/libssl/d1_both.c')
-rw-r--r--lib/libssl/d1_both.c76
1 files changed, 1 insertions, 75 deletions
diff --git a/lib/libssl/d1_both.c b/lib/libssl/d1_both.c
index bce084f1eef..7f9d5af4ce9 100644
--- a/lib/libssl/d1_both.c
+++ b/lib/libssl/d1_both.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: d1_both.c,v 1.39 2016/03/06 14:52:15 beck Exp $ */
+/* $OpenBSD: d1_both.c,v 1.40 2016/12/06 13:38:11 jsing Exp $ */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -936,80 +936,6 @@ dtls1_send_change_cipher_spec(SSL *s, int a, int b)
return (dtls1_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC));
}
-static int
-dtls1_add_cert_to_buf(BUF_MEM *buf, unsigned long *l, X509 *x)
-{
- int n;
- unsigned char *p;
-
- n = i2d_X509(x, NULL);
- if (!BUF_MEM_grow_clean(buf, n + (*l) + 3)) {
- SSLerr(SSL_F_DTLS1_ADD_CERT_TO_BUF, ERR_R_BUF_LIB);
- return 0;
- }
- p = (unsigned char *)&(buf->data[*l]);
- l2n3(n, p);
- i2d_X509(x, &p);
- *l += n + 3;
-
- return 1;
-}
-
-unsigned long
-dtls1_output_cert_chain(SSL *s, X509 *x)
-{
- unsigned char *p;
- int i;
- unsigned long l = 3 + DTLS1_HM_HEADER_LENGTH;
- BUF_MEM *buf;
-
- /* TLSv1 sends a chain with nothing in it, instead of an alert */
- buf = s->init_buf;
- if (!BUF_MEM_grow_clean(buf, 10)) {
- SSLerr(SSL_F_DTLS1_OUTPUT_CERT_CHAIN, ERR_R_BUF_LIB);
- return (0);
- }
- if (x != NULL) {
- X509_STORE_CTX xs_ctx;
-
- if (!X509_STORE_CTX_init(&xs_ctx, s->ctx->cert_store,
- x, NULL)) {
- SSLerr(SSL_F_DTLS1_OUTPUT_CERT_CHAIN, ERR_R_X509_LIB);
- return (0);
- }
-
- X509_verify_cert(&xs_ctx);
- /* Don't leave errors in the queue */
- ERR_clear_error();
- for (i = 0; i < sk_X509_num(xs_ctx.chain); i++) {
- x = sk_X509_value(xs_ctx.chain, i);
-
- if (!dtls1_add_cert_to_buf(buf, &l, x)) {
- X509_STORE_CTX_cleanup(&xs_ctx);
- return 0;
- }
- }
- X509_STORE_CTX_cleanup(&xs_ctx);
- }
- /* Thawte special :-) */
- for (i = 0; i < sk_X509_num(s->ctx->extra_certs); i++) {
- x = sk_X509_value(s->ctx->extra_certs, i);
- if (!dtls1_add_cert_to_buf(buf, &l, x))
- return 0;
- }
-
- l -= (3 + DTLS1_HM_HEADER_LENGTH);
-
- p = (unsigned char *)&(buf->data[DTLS1_HM_HEADER_LENGTH]);
- l2n3(l, p);
- l += 3;
- p = (unsigned char *)&(buf->data[0]);
- p = dtls1_set_message_header(s, p, SSL3_MT_CERTIFICATE, l, 0, l);
-
- l += DTLS1_HM_HEADER_LENGTH;
- return (l);
-}
-
int
dtls1_read_failed(SSL *s, int code)
{