diff options
author | Rich Salz <rsalz@openssl.org> | 2016-12-11 15:01:28 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-01-09 22:26:47 -0500 |
commit | 8cbfcc70bf37886064ef852dda9e1bf40e904756 (patch) | |
tree | 5e6a20b59466db5e1a60442d7614e4d9358a8185 /ssl | |
parent | aff8c126fd8db84fa4ef623997a8c4200a14a44f (diff) |
Use typedefs for PSK, NPN, ALPN callback functions
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2052)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/ssl_lib.c | 51 | ||||
-rw-r--r-- | ssl/ssl_locl.h | 28 | ||||
-rw-r--r-- | ssl/statem/extensions.c | 24 | ||||
-rw-r--r-- | ssl/statem/statem_clnt.c | 8 | ||||
-rw-r--r-- | ssl/statem/statem_srvr.c | 13 |
5 files changed, 24 insertions, 100 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index ddc2ff78e7..58873456c8 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2267,10 +2267,7 @@ void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, * ServerHello. */ void SSL_CTX_set_npn_advertised_cb(SSL_CTX *ctx, - int (*cb) (SSL *ssl, - const unsigned char **out, - unsigned int *outlen, - void *arg), + SSL_CTX_npn_advertised_cb_func cb, void *arg) { ctx->ext.npn_advertised_cb = cb; @@ -2288,11 +2285,7 @@ void SSL_CTX_set_npn_advertised_cb(SSL_CTX *ctx, * a value other than SSL_TLSEXT_ERR_OK. */ void SSL_CTX_set_npn_select_cb(SSL_CTX *ctx, - int (*cb) (SSL *s, unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, - void *arg), + SSL_CTX_npn_select_cb_func cb, void *arg) { ctx->ext.npn_select_cb = cb; @@ -2344,12 +2337,8 @@ int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, * from the client's list of offered protocols. */ void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, - int (*cb) (SSL *ssl, - const unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, - void *arg), void *arg) + SSL_CTX_alpn_select_cb_func cb, + void *arg) { ctx->ext.alpn_select_cb = cb; ctx->ext.alpn_select_cb_arg = arg; @@ -3726,46 +3715,22 @@ const char *SSL_get_psk_identity(const SSL *s) return (s->session->psk_identity); } -void SSL_set_psk_client_callback(SSL *s, - unsigned int (*cb) (SSL *ssl, - const char *hint, - char *identity, - unsigned int - max_identity_len, - unsigned char *psk, - unsigned int max_psk_len)) +void SSL_set_psk_client_callback(SSL *s, SSL_psk_client_cb_func cb) { s->psk_client_callback = cb; } -void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, - unsigned int (*cb) (SSL *ssl, - const char *hint, - char *identity, - unsigned int - max_identity_len, - unsigned char *psk, - unsigned int - max_psk_len)) +void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb) { ctx->psk_client_callback = cb; } -void SSL_set_psk_server_callback(SSL *s, - unsigned int (*cb) (SSL *ssl, - const char *identity, - unsigned char *psk, - unsigned int max_psk_len)) +void SSL_set_psk_server_callback(SSL *s, SSL_psk_server_cb_func cb) { s->psk_server_callback = cb; } -void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, - unsigned int (*cb) (SSL *ssl, - const char *identity, - unsigned char *psk, - unsigned int - max_psk_len)) +void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb) { ctx->psk_server_callback = cb; } diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 06557bb4b2..84a91a125f 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -843,30 +843,20 @@ struct ssl_ctx_st { * For a server, this contains a callback function by which the set of * advertised protocols can be provided. */ - int (*npn_advertised_cb) (SSL *s, const unsigned char **buf, - unsigned int *len, void *arg); + SSL_CTX_npn_advertised_cb_func npn_advertised_cb; void *npn_advertised_cb_arg; /* * For a client, this contains a callback function that selects the next * protocol from the list provided by the server. */ - int (*npn_select_cb) (SSL *s, unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, void *arg); + SSL_CTX_npn_select_cb_func npn_select_cb; void *npn_select_cb_arg; # endif } ext; # ifndef OPENSSL_NO_PSK - unsigned int (*psk_client_callback) (SSL *ssl, const char *hint, - char *identity, - unsigned int max_identity_len, - unsigned char *psk, - unsigned int max_psk_len); - unsigned int (*psk_server_callback) (SSL *ssl, const char *identity, - unsigned char *psk, - unsigned int max_psk_len); + SSL_psk_client_cb_func psk_client_callback; + SSL_psk_server_cb_func psk_server_callback; # endif # ifndef OPENSSL_NO_SRP @@ -1002,14 +992,8 @@ struct ssl_st { /* actual code */ int error_code; # ifndef OPENSSL_NO_PSK - unsigned int (*psk_client_callback) (SSL *ssl, const char *hint, - char *identity, - unsigned int max_identity_len, - unsigned char *psk, - unsigned int max_psk_len); - unsigned int (*psk_server_callback) (SSL *ssl, const char *identity, - unsigned char *psk, - unsigned int max_psk_len); + SSL_psk_client_cb_func psk_client_callback; + SSL_psk_server_cb_func psk_server_callback; # endif SSL_CTX *ctx; /* Verified chain of peer */ diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c index 2568ac6573..a68dd48835 100644 --- a/ssl/statem/extensions.c +++ b/ssl/statem/extensions.c @@ -799,31 +799,13 @@ static int init_status_request(SSL *s, unsigned int context) * Ensure we get sensible values passed to tlsext_status_cb in the event * that we don't receive a status message */ - OPENSSL_free(s->tlsext_ocsp_resp); - s->ext.ocsp_resp = NULL; - s->ext.ocsp_resplen = 0; + OPENSSL_free(s->ext.ocsp.resp); + s->ext.ocsp.resp = NULL; + s->ext.ocsp.resp_len = 0; } return 1; } - -static int final_status_request(SSL *s, unsigned int context, int sent, - int *al) -{ - if (s->server) - return 1; - - /* - * Ensure we get sensible values passed to ext.status_cb in the event - * that we don't receive a status message - */ - OPENSSL_free(s->ext.ocsp.resp); - s->ext.ocsp.resp = NULL; - s->ext.ocsp.resp_len = 0; ->>>>>>> Move extension data into sub-structs - - return 1; -} #endif #ifndef OPENSSL_NO_NEXTPROTONEG diff --git a/ssl/statem/statem_clnt.c b/ssl/statem/statem_clnt.c index 82713d2dfb..9fa16b1417 100644 --- a/ssl/statem/statem_clnt.c +++ b/ssl/statem/statem_clnt.c @@ -2204,18 +2204,18 @@ int tls_process_cert_status_body(SSL *s, PACKET *pkt, int *al) SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS_BODY, SSL_R_LENGTH_MISMATCH); return 0; } - s->tlsext_ocsp_resp = OPENSSL_malloc(resplen); - if (s->ext.ocsp_resp == NULL) { + s->ext.ocsp.resp = OPENSSL_malloc(resplen); + if (s->ext.ocsp.resp == NULL) { *al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS_BODY, ERR_R_MALLOC_FAILURE); return 0; } - if (!PACKET_copy_bytes(pkt, s->ext.ocsp_resp, resplen)) { + if (!PACKET_copy_bytes(pkt, s->ext.ocsp.resp, resplen)) { *al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS_BODY, SSL_R_LENGTH_MISMATCH); return 0; } - s->ext.ocsp_resplen = resplen; + s->ext.ocsp.resp_len = resplen; return 1; } diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c index 475f405768..224b158192 100644 --- a/ssl/statem/statem_srvr.c +++ b/ssl/statem/statem_srvr.c @@ -3465,10 +3465,9 @@ int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt) */ int tls_construct_cert_status_body(SSL *s, WPACKET *pkt) { -<<<<<<< 3b72dcd5fb4d2c756a830dba1fc34f4a7ae61b73 - if (!WPACKET_put_bytes_u8(pkt, s->tlsext_status_type) - || !WPACKET_sub_memcpy_u24(pkt, s->tlsext_ocsp_resp, - s->tlsext_ocsp_resplen)) { + if (!WPACKET_put_bytes_u8(pkt, s->ext.status_type) + || !WPACKET_sub_memcpy_u24(pkt, s->ext.ocsp.resp, + s->ext.ocsp.resp_len)) { SSLerr(SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY, ERR_R_INTERNAL_ERROR); return 0; } @@ -3479,12 +3478,6 @@ int tls_construct_cert_status_body(SSL *s, WPACKET *pkt) int tls_construct_cert_status(SSL *s, WPACKET *pkt) { if (!tls_construct_cert_status_body(s, pkt)) { -======= - if (!WPACKET_put_bytes_u8(pkt, s->ext.status_type) - || !WPACKET_sub_memcpy_u24(pkt, s->ext.ocsp.resp, - s->ext.ocsp.resp_len)) { - SSLerr(SSL_F_TLS_CONSTRUCT_CERT_STATUS, ERR_R_INTERNAL_ERROR); ->>>>>>> Move extension data into sub-structs ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); return 0; } |