]>
Commit | Line | Data |
---|---|---|
ac44deaf TS |
1 | /* |
2 | * Copyright 1995-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 | #include "internal/nelem.h" | |
11 | #include "../ssl/ssl_local.h" | |
12 | #include "../ssl/statem/statem_local.h" | |
13 | #include "testutil.h" | |
14 | ||
15 | #define EXT_ENTRY(name) { TLSEXT_IDX_##name, TLSEXT_TYPE_##name, #name } | |
16 | #define EXT_EXCEPTION(name) { TLSEXT_IDX_##name, TLSEXT_TYPE_invalid, #name } | |
17 | #define EXT_END(name) { TLSEXT_IDX_##name, TLSEXT_TYPE_out_of_range, #name } | |
18 | ||
19 | typedef struct { | |
20 | size_t idx; | |
21 | unsigned int type; | |
22 | char *name; | |
23 | } EXT_LIST; | |
24 | ||
25 | /* The order here does matter! */ | |
26 | static EXT_LIST ext_list[] = { | |
27 | ||
28 | EXT_ENTRY(renegotiate), | |
29 | EXT_ENTRY(server_name), | |
30 | EXT_ENTRY(max_fragment_length), | |
31 | #ifndef OPENSSL_NO_SRP | |
32 | EXT_ENTRY(srp), | |
33 | #else | |
34 | EXT_EXCEPTION(srp), | |
35 | #endif | |
36 | EXT_ENTRY(ec_point_formats), | |
37 | EXT_ENTRY(supported_groups), | |
38 | EXT_ENTRY(session_ticket), | |
39 | #ifndef OPENSSL_NO_OCSP | |
40 | EXT_ENTRY(status_request), | |
41 | #else | |
42 | EXT_EXCEPTION(status_request), | |
43 | #endif | |
44 | #ifndef OPENSSL_NO_NEXTPROTONEG | |
45 | EXT_ENTRY(next_proto_neg), | |
46 | #else | |
47 | EXT_EXCEPTION(next_proto_neg), | |
48 | #endif | |
49 | EXT_ENTRY(application_layer_protocol_negotiation), | |
50 | #ifndef OPENSSL_NO_SRTP | |
51 | EXT_ENTRY(use_srtp), | |
52 | #else | |
53 | EXT_EXCEPTION(use_srtp), | |
54 | #endif | |
55 | EXT_ENTRY(encrypt_then_mac), | |
56 | #ifndef OPENSSL_NO_CT | |
57 | EXT_ENTRY(signed_certificate_timestamp), | |
58 | #else | |
59 | EXT_EXCEPTION(signed_certificate_timestamp), | |
60 | #endif | |
61 | EXT_ENTRY(extended_master_secret), | |
62 | EXT_ENTRY(signature_algorithms_cert), | |
63 | EXT_ENTRY(post_handshake_auth), | |
64 | EXT_ENTRY(signature_algorithms), | |
65 | EXT_ENTRY(supported_versions), | |
66 | EXT_ENTRY(psk_kex_modes), | |
67 | EXT_ENTRY(key_share), | |
68 | EXT_ENTRY(cookie), | |
69 | EXT_ENTRY(cryptopro_bug), | |
b67cb09f | 70 | EXT_ENTRY(compress_certificate), |
ac44deaf TS |
71 | EXT_ENTRY(early_data), |
72 | EXT_ENTRY(certificate_authorities), | |
73 | EXT_ENTRY(padding), | |
74 | EXT_ENTRY(psk), | |
75 | EXT_END(num_builtins) | |
76 | }; | |
77 | ||
78 | static int test_extension_list(void) | |
79 | { | |
80 | size_t n = OSSL_NELEM(ext_list); | |
81 | size_t i; | |
82 | unsigned int type; | |
83 | int retval = 1; | |
84 | ||
85 | for (i = 0; i < n; i++) { | |
86 | if (!TEST_size_t_eq(i, ext_list[i].idx)) { | |
87 | retval = 0; | |
88 | TEST_error("TLSEXT_IDX_%s=%zd, found at=%zd\n", | |
89 | ext_list[i].name, ext_list[i].idx, i); | |
90 | } | |
91 | type = ossl_get_extension_type(ext_list[i].idx); | |
92 | if (!TEST_uint_eq(type, ext_list[i].type)) { | |
93 | retval = 0; | |
94 | TEST_error("TLSEXT_IDX_%s=%zd expected=0x%05X got=0x%05X", | |
95 | ext_list[i].name, ext_list[i].idx, ext_list[i].type, | |
96 | type); | |
97 | } | |
98 | } | |
99 | return retval; | |
100 | } | |
101 | ||
102 | int setup_tests(void) | |
103 | { | |
104 | ADD_TEST(test_extension_list); | |
105 | return 1; | |
106 | } |