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