2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
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
10 #include "internal/nelem.h"
11 #include "../ssl/ssl_local.h"
12 #include "../ssl/statem/statem_local.h"
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 }
25 /* The order here does matter! */
26 static EXT_LIST ext_list[] = {
28 EXT_ENTRY(renegotiate),
29 EXT_ENTRY(server_name),
30 EXT_ENTRY(max_fragment_length),
31 #ifndef OPENSSL_NO_SRP
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),
42 EXT_EXCEPTION(status_request),
44 #ifndef OPENSSL_NO_NEXTPROTONEG
45 EXT_ENTRY(next_proto_neg),
47 EXT_EXCEPTION(next_proto_neg),
49 EXT_ENTRY(application_layer_protocol_negotiation),
50 #ifndef OPENSSL_NO_SRTP
53 EXT_EXCEPTION(use_srtp),
55 EXT_ENTRY(encrypt_then_mac),
57 EXT_ENTRY(signed_certificate_timestamp),
59 EXT_EXCEPTION(signed_certificate_timestamp),
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),
69 EXT_ENTRY(cryptopro_bug),
70 EXT_ENTRY(compress_certificate),
71 EXT_ENTRY(early_data),
72 EXT_ENTRY(certificate_authorities),
78 static int test_extension_list(void)
80 size_t n = OSSL_NELEM(ext_list);
85 for (i = 0; i < n; i++) {
86 if (!TEST_size_t_eq(i, ext_list[i].idx)) {
88 TEST_error("TLSEXT_IDX_%s=%zd, found at=%zd\n",
89 ext_list[i].name, ext_list[i].idx, i);
91 type = ossl_get_extension_type(ext_list[i].idx);
92 if (!TEST_uint_eq(type, ext_list[i].type)) {
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,
102 int setup_tests(void)
104 ADD_TEST(test_extension_list);