xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/test/sysdefaulttest.c (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos /*
2*4724848cSchristos  * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
3*4724848cSchristos  *
4*4724848cSchristos  * Licensed under the OpenSSL license (the "License").  You may not use
5*4724848cSchristos  * this file except in compliance with the License.  You can obtain a copy
6*4724848cSchristos  * in the file LICENSE in the source distribution or at
7*4724848cSchristos  * https://www.openssl.org/source/license.html
8*4724848cSchristos  */
9*4724848cSchristos 
10*4724848cSchristos #include <stdio.h>
11*4724848cSchristos #include <openssl/opensslconf.h>
12*4724848cSchristos 
13*4724848cSchristos #include <string.h>
14*4724848cSchristos #include <openssl/evp.h>
15*4724848cSchristos #include <openssl/ssl.h>
16*4724848cSchristos #include <openssl/tls1.h>
17*4724848cSchristos #include "testutil.h"
18*4724848cSchristos 
19*4724848cSchristos static SSL_CTX *ctx;
20*4724848cSchristos 
test_func(void)21*4724848cSchristos static int test_func(void)
22*4724848cSchristos {
23*4724848cSchristos     if (!TEST_int_eq(SSL_CTX_get_min_proto_version(ctx), TLS1_2_VERSION)
24*4724848cSchristos         && !TEST_int_eq(SSL_CTX_get_max_proto_version(ctx), TLS1_2_VERSION)) {
25*4724848cSchristos         TEST_info("min/max version setting incorrect");
26*4724848cSchristos         return 0;
27*4724848cSchristos     }
28*4724848cSchristos     return 1;
29*4724848cSchristos }
30*4724848cSchristos 
global_init(void)31*4724848cSchristos int global_init(void)
32*4724848cSchristos {
33*4724848cSchristos     if (!OPENSSL_init_ssl(OPENSSL_INIT_ENGINE_ALL_BUILTIN
34*4724848cSchristos                           | OPENSSL_INIT_LOAD_CONFIG, NULL))
35*4724848cSchristos         return 0;
36*4724848cSchristos     return 1;
37*4724848cSchristos }
38*4724848cSchristos 
setup_tests(void)39*4724848cSchristos int setup_tests(void)
40*4724848cSchristos {
41*4724848cSchristos     if (!TEST_ptr(ctx = SSL_CTX_new(TLS_method())))
42*4724848cSchristos         return 0;
43*4724848cSchristos     ADD_TEST(test_func);
44*4724848cSchristos     return 1;
45*4724848cSchristos }
46*4724848cSchristos 
cleanup_tests(void)47*4724848cSchristos void cleanup_tests(void)
48*4724848cSchristos {
49*4724848cSchristos     SSL_CTX_free(ctx);
50*4724848cSchristos }
51