xref: /netbsd-src/crypto/external/bsd/openssl/dist/test/sysdefaulttest.c (revision b0d1725196a7921d003d2c66a14f186abda4176b)
113d40330Schristos /*
213d40330Schristos  * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
313d40330Schristos  *
4*b0d17251Schristos  * Licensed under the Apache License 2.0 (the "License").  You may not use
513d40330Schristos  * this file except in compliance with the License.  You can obtain a copy
613d40330Schristos  * in the file LICENSE in the source distribution or at
713d40330Schristos  * https://www.openssl.org/source/license.html
813d40330Schristos  */
913d40330Schristos 
1013d40330Schristos #include <stdio.h>
1113d40330Schristos #include <openssl/opensslconf.h>
1213d40330Schristos 
1313d40330Schristos #include <string.h>
1413d40330Schristos #include <openssl/evp.h>
1513d40330Schristos #include <openssl/ssl.h>
1613d40330Schristos #include <openssl/tls1.h>
1713d40330Schristos #include "testutil.h"
1813d40330Schristos 
1913d40330Schristos static SSL_CTX *ctx;
2013d40330Schristos 
test_func(void)2113d40330Schristos static int test_func(void)
2213d40330Schristos {
2313d40330Schristos     if (!TEST_int_eq(SSL_CTX_get_min_proto_version(ctx), TLS1_2_VERSION)
2413d40330Schristos         && !TEST_int_eq(SSL_CTX_get_max_proto_version(ctx), TLS1_2_VERSION)) {
2513d40330Schristos         TEST_info("min/max version setting incorrect");
2613d40330Schristos         return 0;
2713d40330Schristos     }
2813d40330Schristos     return 1;
2913d40330Schristos }
3013d40330Schristos 
global_init(void)3113d40330Schristos int global_init(void)
3213d40330Schristos {
3313d40330Schristos     if (!OPENSSL_init_ssl(OPENSSL_INIT_ENGINE_ALL_BUILTIN
3413d40330Schristos                           | OPENSSL_INIT_LOAD_CONFIG, NULL))
3513d40330Schristos         return 0;
3613d40330Schristos     return 1;
3713d40330Schristos }
3813d40330Schristos 
setup_tests(void)3913d40330Schristos int setup_tests(void)
4013d40330Schristos {
4113d40330Schristos     if (!TEST_ptr(ctx = SSL_CTX_new(TLS_method())))
4213d40330Schristos         return 0;
4313d40330Schristos     ADD_TEST(test_func);
4413d40330Schristos     return 1;
4513d40330Schristos }
4613d40330Schristos 
cleanup_tests(void)4713d40330Schristos void cleanup_tests(void)
4813d40330Schristos {
4913d40330Schristos     SSL_CTX_free(ctx);
5013d40330Schristos }
51