1*e0c4386eSCy Schubert /* 2*e0c4386eSCy Schubert * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. 3*e0c4386eSCy Schubert * 4*e0c4386eSCy Schubert * Licensed under the Apache License 2.0 (the "License"). You may not use 5*e0c4386eSCy Schubert * this file except in compliance with the License. You can obtain a copy 6*e0c4386eSCy Schubert * in the file LICENSE in the source distribution or at 7*e0c4386eSCy Schubert * https://www.openssl.org/source/license.html 8*e0c4386eSCy Schubert */ 9*e0c4386eSCy Schubert 10*e0c4386eSCy Schubert #ifndef OSSL_TEST_HANDSHAKE_HELPER_H 11*e0c4386eSCy Schubert #define OSSL_TEST_HANDSHAKE_HELPER_H 12*e0c4386eSCy Schubert 13*e0c4386eSCy Schubert #include "ssl_test_ctx.h" 14*e0c4386eSCy Schubert 15*e0c4386eSCy Schubert typedef struct ctx_data_st { 16*e0c4386eSCy Schubert unsigned char *npn_protocols; 17*e0c4386eSCy Schubert size_t npn_protocols_len; 18*e0c4386eSCy Schubert unsigned char *alpn_protocols; 19*e0c4386eSCy Schubert size_t alpn_protocols_len; 20*e0c4386eSCy Schubert char *srp_user; 21*e0c4386eSCy Schubert char *srp_password; 22*e0c4386eSCy Schubert char *session_ticket_app_data; 23*e0c4386eSCy Schubert } CTX_DATA; 24*e0c4386eSCy Schubert 25*e0c4386eSCy Schubert typedef struct handshake_result { 26*e0c4386eSCy Schubert ssl_test_result_t result; 27*e0c4386eSCy Schubert /* These alerts are in the 2-byte format returned by the info_callback. */ 28*e0c4386eSCy Schubert /* (Latest) alert sent by the client; 0 if no alert. */ 29*e0c4386eSCy Schubert int client_alert_sent; 30*e0c4386eSCy Schubert /* Number of fatal or close_notify alerts sent. */ 31*e0c4386eSCy Schubert int client_num_fatal_alerts_sent; 32*e0c4386eSCy Schubert /* (Latest) alert received by the server; 0 if no alert. */ 33*e0c4386eSCy Schubert int client_alert_received; 34*e0c4386eSCy Schubert /* (Latest) alert sent by the server; 0 if no alert. */ 35*e0c4386eSCy Schubert int server_alert_sent; 36*e0c4386eSCy Schubert /* Number of fatal or close_notify alerts sent. */ 37*e0c4386eSCy Schubert int server_num_fatal_alerts_sent; 38*e0c4386eSCy Schubert /* (Latest) alert received by the client; 0 if no alert. */ 39*e0c4386eSCy Schubert int server_alert_received; 40*e0c4386eSCy Schubert /* Negotiated protocol. On success, these should always match. */ 41*e0c4386eSCy Schubert int server_protocol; 42*e0c4386eSCy Schubert int client_protocol; 43*e0c4386eSCy Schubert /* Server connection */ 44*e0c4386eSCy Schubert ssl_servername_t servername; 45*e0c4386eSCy Schubert /* Session ticket status */ 46*e0c4386eSCy Schubert ssl_session_ticket_t session_ticket; 47*e0c4386eSCy Schubert int compression; 48*e0c4386eSCy Schubert /* Was this called on the second context? */ 49*e0c4386eSCy Schubert int session_ticket_do_not_call; 50*e0c4386eSCy Schubert char *client_npn_negotiated; 51*e0c4386eSCy Schubert char *server_npn_negotiated; 52*e0c4386eSCy Schubert char *client_alpn_negotiated; 53*e0c4386eSCy Schubert char *server_alpn_negotiated; 54*e0c4386eSCy Schubert /* Was the handshake resumed? */ 55*e0c4386eSCy Schubert int client_resumed; 56*e0c4386eSCy Schubert int server_resumed; 57*e0c4386eSCy Schubert /* Temporary key type */ 58*e0c4386eSCy Schubert int tmp_key_type; 59*e0c4386eSCy Schubert /* server certificate key type */ 60*e0c4386eSCy Schubert int server_cert_type; 61*e0c4386eSCy Schubert /* server signing hash */ 62*e0c4386eSCy Schubert int server_sign_hash; 63*e0c4386eSCy Schubert /* server signature type */ 64*e0c4386eSCy Schubert int server_sign_type; 65*e0c4386eSCy Schubert /* server CA names */ 66*e0c4386eSCy Schubert STACK_OF(X509_NAME) *server_ca_names; 67*e0c4386eSCy Schubert /* client certificate key type */ 68*e0c4386eSCy Schubert int client_cert_type; 69*e0c4386eSCy Schubert /* client signing hash */ 70*e0c4386eSCy Schubert int client_sign_hash; 71*e0c4386eSCy Schubert /* client signature type */ 72*e0c4386eSCy Schubert int client_sign_type; 73*e0c4386eSCy Schubert /* Client CA names */ 74*e0c4386eSCy Schubert STACK_OF(X509_NAME) *client_ca_names; 75*e0c4386eSCy Schubert /* Session id status */ 76*e0c4386eSCy Schubert ssl_session_id_t session_id; 77*e0c4386eSCy Schubert char *cipher; 78*e0c4386eSCy Schubert /* session ticket application data */ 79*e0c4386eSCy Schubert char *result_session_ticket_app_data; 80*e0c4386eSCy Schubert } HANDSHAKE_RESULT; 81*e0c4386eSCy Schubert 82*e0c4386eSCy Schubert HANDSHAKE_RESULT *HANDSHAKE_RESULT_new(void); 83*e0c4386eSCy Schubert void HANDSHAKE_RESULT_free(HANDSHAKE_RESULT *result); 84*e0c4386eSCy Schubert 85*e0c4386eSCy Schubert /* Do a handshake and report some information about the result. */ 86*e0c4386eSCy Schubert HANDSHAKE_RESULT *do_handshake(SSL_CTX *server_ctx, SSL_CTX *server2_ctx, 87*e0c4386eSCy Schubert SSL_CTX *client_ctx, SSL_CTX *resume_server_ctx, 88*e0c4386eSCy Schubert SSL_CTX *resume_client_ctx, 89*e0c4386eSCy Schubert const SSL_TEST_CTX *test_ctx); 90*e0c4386eSCy Schubert 91*e0c4386eSCy Schubert int configure_handshake_ctx_for_srp(SSL_CTX *server_ctx, SSL_CTX *server2_ctx, 92*e0c4386eSCy Schubert SSL_CTX *client_ctx, 93*e0c4386eSCy Schubert const SSL_TEST_EXTRA_CONF *extra, 94*e0c4386eSCy Schubert CTX_DATA *server_ctx_data, 95*e0c4386eSCy Schubert CTX_DATA *server2_ctx_data, 96*e0c4386eSCy Schubert CTX_DATA *client_ctx_data); 97*e0c4386eSCy Schubert 98*e0c4386eSCy Schubert #endif /* OSSL_TEST_HANDSHAKE_HELPER_H */ 99