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