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