2 * Copyright 1995-2023 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(client_cert_type
),
65 EXT_ENTRY(server_cert_type
),
66 EXT_ENTRY(signature_algorithms
),
67 EXT_ENTRY(supported_versions
),
68 EXT_ENTRY(psk_kex_modes
),
71 EXT_ENTRY(cryptopro_bug
),
72 EXT_ENTRY(compress_certificate
),
73 EXT_ENTRY(early_data
),
74 EXT_ENTRY(certificate_authorities
),
80 static int test_extension_list(void)
82 size_t n
= OSSL_NELEM(ext_list
);
87 for (i
= 0; i
< n
; i
++) {
88 if (!TEST_size_t_eq(i
, ext_list
[i
].idx
)) {
90 TEST_error("TLSEXT_IDX_%s=%zd, found at=%zd\n",
91 ext_list
[i
].name
, ext_list
[i
].idx
, i
);
93 type
= ossl_get_extension_type(ext_list
[i
].idx
);
94 if (!TEST_uint_eq(type
, ext_list
[i
].type
)) {
96 TEST_error("TLSEXT_IDX_%s=%zd expected=0x%05X got=0x%05X",
97 ext_list
[i
].name
, ext_list
[i
].idx
, ext_list
[i
].type
,
104 int setup_tests(void)
106 ADD_TEST(test_extension_list
);