From 91c389f89015a024212e73f5ec6e24166955ab6e Mon Sep 17 00:00:00 2001 From: beck <> Date: Tue, 7 Feb 2017 02:08:38 +0000 Subject: Change SSLerror() back to taking two args, with the first one being an SSL *. Make a table of "function codes" which maps the internal state of the SSL * to something like a useful name so in a typical error in the connection you know in what sort of place in the handshake things happened. (instead of by arcane function name). Add SSLerrorx() for when we don't have an SSL * ok jsing@ after us both being prodded by bluhm@ to make it not terrible --- src/lib/libssl/ssl_both.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/lib/libssl/ssl_both.c') diff --git a/src/lib/libssl/ssl_both.c b/src/lib/libssl/ssl_both.c index 2d79c24c86..14fd121d53 100644 --- a/src/lib/libssl/ssl_both.c +++ b/src/lib/libssl/ssl_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_both.c,v 1.5 2017/01/29 15:20:18 jsing Exp $ */ +/* $OpenBSD: ssl_both.c,v 1.6 2017/02/07 02:08:38 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -244,7 +244,7 @@ ssl3_get_finished(SSL *s, int a, int b) /* If this occurs, we have missed a message */ if (!S3I(s)->change_cipher_spec) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerror(SSL_R_GOT_A_FIN_BEFORE_A_CCS); + SSLerror(s, SSL_R_GOT_A_FIN_BEFORE_A_CCS); goto f_err; } S3I(s)->change_cipher_spec = 0; @@ -253,7 +253,7 @@ ssl3_get_finished(SSL *s, int a, int b) if (n < 0) { al = SSL_AD_DECODE_ERROR; - SSLerror(SSL_R_BAD_DIGEST_LENGTH); + SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); goto f_err; } @@ -262,13 +262,13 @@ ssl3_get_finished(SSL *s, int a, int b) if (S3I(s)->tmp.peer_finish_md_len != md_len || CBS_len(&cbs) != md_len) { al = SSL_AD_DECODE_ERROR; - SSLerror(SSL_R_BAD_DIGEST_LENGTH); + SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); goto f_err; } if (!CBS_mem_equal(&cbs, S3I(s)->tmp.peer_finish_md, CBS_len(&cbs))) { al = SSL_AD_DECRYPT_ERROR; - SSLerror(SSL_R_DIGEST_CHECK_FAILED); + SSLerror(s, SSL_R_DIGEST_CHECK_FAILED); goto f_err; } @@ -365,7 +365,7 @@ ssl3_output_cert_chain(SSL *s, CBB *cbb, X509 *x) if (!X509_STORE_CTX_init(&xs_ctx, s->ctx->cert_store, x, NULL)) { - SSLerror(ERR_R_X509_LIB); + SSLerror(s, ERR_R_X509_LIB); goto err; } X509_verify_cert(&xs_ctx); @@ -419,7 +419,7 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) S3I(s)->tmp.reuse_message = 0; if ((mt >= 0) && (S3I(s)->tmp.message_type != mt)) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerror(SSL_R_UNEXPECTED_MESSAGE); + SSLerror(s, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } *ok = 1; @@ -471,25 +471,25 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) if ((mt >= 0) && (*p != mt)) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerror(SSL_R_UNEXPECTED_MESSAGE); + SSLerror(s, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } CBS_init(&cbs, p, 4); if (!CBS_get_u8(&cbs, &u8) || !CBS_get_u24(&cbs, &l)) { - SSLerror(ERR_R_BUF_LIB); + SSLerror(s, ERR_R_BUF_LIB); goto err; } S3I(s)->tmp.message_type = u8; if (l > (unsigned long)max) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerror(SSL_R_EXCESSIVE_MESSAGE_SIZE); + SSLerror(s, SSL_R_EXCESSIVE_MESSAGE_SIZE); goto f_err; } if (l && !BUF_MEM_grow_clean(s->internal->init_buf, l + 4)) { - SSLerror(ERR_R_BUF_LIB); + SSLerror(s, ERR_R_BUF_LIB); goto err; } S3I(s)->tmp.message_size = l; @@ -679,7 +679,7 @@ ssl3_setup_read_buffer(SSL *s) return 1; err: - SSLerror(ERR_R_MALLOC_FAILURE); + SSLerror(s, ERR_R_MALLOC_FAILURE); return 0; } @@ -712,7 +712,7 @@ ssl3_setup_write_buffer(SSL *s) return 1; err: - SSLerror(ERR_R_MALLOC_FAILURE); + SSLerror(s, ERR_R_MALLOC_FAILURE); return 0; } -- cgit v1.2.3-55-g6feb