9aaa4cea505473bb6cf65900fb831b8a6d776421
[openssl.git] / test / ssl_test_ctx.h
1 /*
2  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL licenses, (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * https://www.openssl.org/source/license.html
8  * or in the file LICENSE in the source distribution.
9  */
10
11 #ifndef HEADER_SSL_TEST_CTX_H
12 #define HEADER_SSL_TEST_CTX_H
13
14 #include <openssl/conf.h>
15 #include <openssl/ssl.h>
16
17 typedef enum {
18     SSL_TEST_SUCCESS = 0,  /* Default */
19     SSL_TEST_SERVER_FAIL,
20     SSL_TEST_CLIENT_FAIL,
21     SSL_TEST_INTERNAL_ERROR
22 } ssl_test_result_t;
23
24 typedef enum {
25     SSL_TEST_VERIFY_NONE = 0, /* Default */
26     SSL_TEST_VERIFY_ACCEPT_ALL,
27     SSL_TEST_VERIFY_REJECT_ALL
28 } ssl_verify_callback_t;
29
30 typedef struct ssl_test_ctx {
31     /* Test expectations. */
32     /* Defaults to SUCCESS. */
33     ssl_test_result_t expected_result;
34     /* Alerts. 0 if no expectation. */
35     /* See ssl.h for alert codes. */
36     /* Alert sent by the client / received by the server. */
37     int client_alert;
38     /* Alert sent by the server / received by the client. */
39     int server_alert;
40     /* Negotiated protocol version. 0 if no expectation. */
41     /* See ssl.h for protocol versions. */
42     int protocol;
43     /* One of a number of predefined custom callbacks. */
44     ssl_verify_callback_t client_verify_callback;
45 } SSL_TEST_CTX;
46
47 const char *ssl_test_result_name(ssl_test_result_t result);
48 const char *ssl_alert_name(int alert);
49 const char *ssl_protocol_name(int protocol);
50 const char *ssl_verify_callback_name(ssl_verify_callback_t verify_callback);
51
52 /*
53  * Load the test case context from |conf|.
54  * See test/README.ssl_test for details on the conf file format.
55  */
56 SSL_TEST_CTX *SSL_TEST_CTX_create(const CONF *conf, const char *test_section);
57
58 SSL_TEST_CTX *SSL_TEST_CTX_new(void);
59
60 void SSL_TEST_CTX_free(SSL_TEST_CTX *ctx);
61
62 #endif  /* HEADER_SSL_TEST_CTX_H */