summary refs log tree commit diff
path: root/crypto/src/tls/ExtensionType.cs
blob: f879bd6e1be95137b2d9cfee99fa79f7833d9f05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
using System;

namespace Org.BouncyCastle.Tls
{
    public abstract class ExtensionType
    {
        /*
         * RFC 2546 2.3.
         */
        public const int server_name = 0;
        public const int max_fragment_length = 1;
        public const int client_certificate_url = 2;
        public const int trusted_ca_keys = 3;
        public const int truncated_hmac = 4;
        public const int status_request = 5;

        /*
         * RFC 4681
         */
        public const int user_mapping = 6;

        /*
         * RFC 5878
         */
        public const int client_authz = 7;
        public const int server_authz = 8;

        /*
         * RFC 6091
         */
        public const int cert_type = 9;

        /*
         * RFC 7919 (originally 'elliptic_curves' from RFC 4492)
         */
        public const int supported_groups = 10;

        /*
         * RFC 4492 5.1.
         */
        public const int ec_point_formats = 11;

        /*
         * RFC 5054 2.8.1.
         */
        public const int srp = 12;

        /*
         * RFC 5246 7.4.1.4.
         */
        public const int signature_algorithms = 13;

        /*
         * RFC 5764 9.
         */
        public const int use_srtp = 14;

        /*
         * RFC 6520 6.
         */
        public const int heartbeat = 15;

        /*
         * RFC 7301
         */
        public const int application_layer_protocol_negotiation = 16;

        /*
         * RFC 6961
         */
        public const int status_request_v2 = 17;

        /*
         * RFC 6962
         */
        public const int signed_certificate_timestamp = 18;

        /*
         * RFC 7250
         */
        public const int client_certificate_type = 19;
        public const int server_certificate_type = 20;

        /*
         * RFC 7685
         */
        public const int padding = 21;

        /*
         * RFC 7366
         */
        public const int encrypt_then_mac = 22;

        /*
         * RFC 7627
         */
        public const int extended_master_secret = 23;

        /*
         * RFC 8472
         */
        public const int token_binding = 24;

        /*
         * RFC 7924
         */
        public const int cached_info = 25;

        /*
         * RFC 8879
         */
        public const int compress_certificate = 27;

        /*
         * RFC 8449
         */
        public const int record_size_limit = 28;

        /*
         * RFC 5077 7.
         */
        public const int session_ticket = 35;

        /*
         * RFC 8446
         */
        public const int pre_shared_key = 41;
        public const int early_data = 42;
        public const int supported_versions = 43;
        public const int cookie = 44;
        public const int psk_key_exchange_modes = 45;
        public const int certificate_authorities = 47;
        public const int oid_filters = 48;
        public const int post_handshake_auth = 49;
        public const int signature_algorithms_cert = 50;
        public const int key_share = 51;

        /*
         * RFC 9146
         */
        public const int connection_id = 54;

        /*
         * RFC 5746 3.2.
         */
        public const int renegotiation_info = 0xff01;

        public static string GetName(int extensionType)
        {
            switch (extensionType)
            {
            case server_name:
                return "server_name";
            case max_fragment_length:
                return "max_fragment_length";
            case client_certificate_url:
                return "client_certificate_url";
            case trusted_ca_keys:
                return "trusted_ca_keys";
            case truncated_hmac:
                return "truncated_hmac";
            case status_request:
                return "status_request";
            case user_mapping:
                return "user_mapping";
            case client_authz:
                return "client_authz";
            case server_authz:
                return "server_authz";
            case cert_type:
                return "cert_type";
            case supported_groups:
                return "supported_groups";
            case ec_point_formats:
                return "ec_point_formats";
            case srp:
                return "srp";
            case signature_algorithms:
                return "signature_algorithms";
            case use_srtp:
                return "use_srtp";
            case heartbeat:
                return "heartbeat";
            case application_layer_protocol_negotiation:
                return "application_layer_protocol_negotiation";
            case status_request_v2:
                return "status_request_v2";
            case signed_certificate_timestamp:
                return "signed_certificate_timestamp";
            case client_certificate_type:
                return "client_certificate_type";
            case server_certificate_type:
                return "server_certificate_type";
            case padding:
                return "padding";
            case encrypt_then_mac:
                return "encrypt_then_mac";
            case extended_master_secret:
                return "extended_master_secret";
            case token_binding:
                return "token_binding";
            case cached_info:
                return "cached_info";
            case compress_certificate:
                return "compress_certificate";
            case record_size_limit:
                return "record_size_limit";
            case session_ticket:
                return "session_ticket";
            case pre_shared_key:
                return "pre_shared_key";
            case early_data:
                return "early_data";
            case supported_versions:
                return "supported_versions";
            case cookie:
                return "cookie";
            case psk_key_exchange_modes:
                return "psk_key_exchange_modes";
            case certificate_authorities:
                return "certificate_authorities";
            case oid_filters:
                return "oid_filters";
            case post_handshake_auth:
                return "post_handshake_auth";
            case signature_algorithms_cert:
                return "signature_algorithms_cert";
            case key_share:
                return "key_share";
            case connection_id:
                return "connection_id";
            case renegotiation_info:
                return "renegotiation_info";
            default:
                return "UNKNOWN";
            }
        }

        public static string GetText(int extensionType)
        {
            return GetName(extensionType) + "(" + extensionType + ")";
        }

        public static bool IsRecognized(int extensionType)
        {
            switch (extensionType)
            {
            case server_name:
            case max_fragment_length:
            case client_certificate_url:
            case trusted_ca_keys:
            case truncated_hmac:
            case status_request:
            case user_mapping:
            case client_authz:
            case server_authz:
            case cert_type:
            case supported_groups:
            case ec_point_formats:
            case srp:
            case signature_algorithms:
            case use_srtp:
            case heartbeat:
            case application_layer_protocol_negotiation:
            case status_request_v2:
            case signed_certificate_timestamp:
            case client_certificate_type:
            case server_certificate_type:
            case padding:
            case encrypt_then_mac:
            case extended_master_secret:
            case token_binding:
            case cached_info:
            case compress_certificate:
            case record_size_limit:
            case session_ticket:
            case pre_shared_key:
            case early_data:
            case supported_versions:
            case cookie:
            case psk_key_exchange_modes:
            case certificate_authorities:
            case oid_filters:
            case post_handshake_auth:
            case signature_algorithms_cert:
            case key_share:
            case connection_id:
            case renegotiation_info:
                return true;
            default:
                return false;
            }
        }
    }
}