Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl35/ssl/statem/extensions_cust.c
Line
Count
Source
1
/*
2
 * Copyright 2014-2025 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
/* Custom extension utility functions */
11
12
#include <openssl/ct.h>
13
#include "../ssl_local.h"
14
#include "internal/cryptlib.h"
15
#include "internal/ssl_unwrap.h"
16
#include "statem_local.h"
17
18
typedef struct {
19
    void *add_arg;
20
    custom_ext_add_cb add_cb;
21
    custom_ext_free_cb free_cb;
22
} custom_ext_add_cb_wrap;
23
24
typedef struct {
25
    void *parse_arg;
26
    custom_ext_parse_cb parse_cb;
27
} custom_ext_parse_cb_wrap;
28
29
/*
30
 * Provide thin wrapper callbacks which convert new style arguments to old style
31
 */
32
static int custom_ext_add_old_cb_wrap(SSL *s, unsigned int ext_type,
33
    unsigned int context,
34
    const unsigned char **out,
35
    size_t *outlen, X509 *x, size_t chainidx,
36
    int *al, void *add_arg)
37
0
{
38
0
    custom_ext_add_cb_wrap *add_cb_wrap = (custom_ext_add_cb_wrap *)add_arg;
39
40
0
    if (add_cb_wrap->add_cb == NULL)
41
0
        return 1;
42
43
0
    return add_cb_wrap->add_cb(s, ext_type, out, outlen, al,
44
0
        add_cb_wrap->add_arg);
45
0
}
46
47
static void custom_ext_free_old_cb_wrap(SSL *s, unsigned int ext_type,
48
    unsigned int context,
49
    const unsigned char *out, void *add_arg)
50
0
{
51
0
    custom_ext_add_cb_wrap *add_cb_wrap = (custom_ext_add_cb_wrap *)add_arg;
52
53
0
    if (add_cb_wrap->free_cb == NULL)
54
0
        return;
55
56
0
    add_cb_wrap->free_cb(s, ext_type, out, add_cb_wrap->add_arg);
57
0
}
58
59
static int custom_ext_parse_old_cb_wrap(SSL *s, unsigned int ext_type,
60
    unsigned int context,
61
    const unsigned char *in,
62
    size_t inlen, X509 *x, size_t chainidx,
63
    int *al, void *parse_arg)
64
0
{
65
0
    custom_ext_parse_cb_wrap *parse_cb_wrap = (custom_ext_parse_cb_wrap *)parse_arg;
66
67
0
    if (parse_cb_wrap->parse_cb == NULL)
68
0
        return 1;
69
70
0
    return parse_cb_wrap->parse_cb(s, ext_type, in, inlen, al,
71
0
        parse_cb_wrap->parse_arg);
72
0
}
73
74
/*
75
 * Find a custom extension from the list. The |role| param is there to
76
 * support the legacy API where custom extensions for client and server could
77
 * be set independently on the same SSL_CTX. It is set to ENDPOINT_SERVER if we
78
 * are trying to find a method relevant to the server, ENDPOINT_CLIENT for the
79
 * client, or ENDPOINT_BOTH for either
80
 */
81
custom_ext_method *custom_ext_find(const custom_ext_methods *exts,
82
    ENDPOINT role, unsigned int ext_type,
83
    size_t *idx)
84
201k
{
85
201k
    size_t i;
86
201k
    custom_ext_method *meth = exts->meths;
87
88
205k
    for (i = 0; i < exts->meths_count; i++, meth++) {
89
43.8k
        if (ext_type == meth->ext_type
90
40.2k
            && (role == ENDPOINT_BOTH || role == meth->role
91
40.2k
                || meth->role == ENDPOINT_BOTH)) {
92
40.2k
            if (idx != NULL)
93
20.1k
                *idx = i;
94
40.2k
            return meth;
95
40.2k
        }
96
43.8k
    }
97
161k
    return NULL;
98
201k
}
99
100
/*
101
 * Initialise custom extensions flags to indicate neither sent nor received.
102
 */
103
void custom_ext_init(custom_ext_methods *exts)
104
160k
{
105
160k
    size_t i;
106
160k
    custom_ext_method *meth = exts->meths;
107
108
211k
    for (i = 0; i < exts->meths_count; i++, meth++)
109
50.4k
        meth->ext_flags &= ~(SSL_EXT_FLAG_SENT | SSL_EXT_FLAG_RECEIVED);
110
160k
}
111
112
/* Pass received custom extension data to the application for parsing. */
113
int custom_ext_parse(SSL_CONNECTION *s, unsigned int context,
114
    unsigned int ext_type,
115
    const unsigned char *ext_data, size_t ext_size, X509 *x,
116
    size_t chainidx)
117
23.9k
{
118
23.9k
    int al = 0;
119
23.9k
    custom_ext_methods *exts = &s->cert->custext;
120
23.9k
    custom_ext_method *meth;
121
23.9k
    ENDPOINT role = ENDPOINT_BOTH;
122
123
23.9k
    if ((context & (SSL_EXT_CLIENT_HELLO | SSL_EXT_TLS1_2_SERVER_HELLO)) != 0)
124
3.78k
        role = s->server ? ENDPOINT_SERVER : ENDPOINT_CLIENT;
125
126
23.9k
    meth = custom_ext_find(exts, role, ext_type, NULL);
127
    /* If not found return success */
128
23.9k
    if (!meth)
129
3.83k
        return 1;
130
131
    /* Check if extension is defined for our protocol. If not, skip */
132
20.0k
    if (!extension_is_relevant(s, meth->context, context))
133
0
        return 1;
134
135
20.0k
    if ((context & (SSL_EXT_TLS1_2_SERVER_HELLO | SSL_EXT_TLS1_3_SERVER_HELLO | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS)) != 0) {
136
        /*
137
         * If it's ServerHello or EncryptedExtensions we can't have any
138
         * extensions not sent in ClientHello.
139
         */
140
20.0k
        if ((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0) {
141
0
            SSLfatal(s, TLS1_AD_UNSUPPORTED_EXTENSION, SSL_R_BAD_EXTENSION);
142
0
            return 0;
143
0
        }
144
20.0k
    }
145
146
    /*
147
     * Extensions received in the ClientHello or CertificateRequest are marked
148
     * with the SSL_EXT_FLAG_RECEIVED. This is so we know to add the equivalent
149
     * extensions in the response messages
150
     */
151
20.0k
    if ((context & (SSL_EXT_CLIENT_HELLO | SSL_EXT_TLS1_3_CERTIFICATE_REQUEST))
152
20.0k
        != 0)
153
0
        meth->ext_flags |= SSL_EXT_FLAG_RECEIVED;
154
155
    /* If no parse function set return success */
156
20.0k
    if (meth->parse_cb == NULL)
157
0
        return 1;
158
159
20.0k
    if (meth->parse_cb(SSL_CONNECTION_GET_USER_SSL(s), ext_type, context, ext_data,
160
20.0k
            ext_size, x, chainidx, &al, meth->parse_arg)
161
20.0k
        <= 0) {
162
1.12k
        SSLfatal(s, al, SSL_R_BAD_EXTENSION);
163
1.12k
        return 0;
164
1.12k
    }
165
166
18.9k
    return 1;
167
20.0k
}
168
169
/*
170
 * Request custom extension data from the application and add to the return
171
 * buffer.
172
 */
173
int custom_ext_add(SSL_CONNECTION *s, int context, WPACKET *pkt, X509 *x,
174
    size_t chainidx, int maxversion)
175
143k
{
176
143k
    custom_ext_methods *exts = &s->cert->custext;
177
143k
    custom_ext_method *meth;
178
143k
    size_t i;
179
143k
    int al;
180
143k
    int for_comp = (context & SSL_EXT_TLS1_3_CERTIFICATE_COMPRESSION) != 0;
181
182
193k
    for (i = 0; i < exts->meths_count; i++) {
183
50.4k
        const unsigned char *out = NULL;
184
50.4k
        size_t outlen = 0;
185
186
50.4k
        meth = exts->meths + i;
187
188
50.4k
        if (!should_add_extension(s, meth->context, context, maxversion))
189
0
            continue;
190
191
50.4k
        if ((context & (SSL_EXT_TLS1_2_SERVER_HELLO | SSL_EXT_TLS1_3_SERVER_HELLO | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS | SSL_EXT_TLS1_3_CERTIFICATE | SSL_EXT_TLS1_3_RAW_PUBLIC_KEY | SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST)) != 0) {
192
            /* Only send extensions present in ClientHello/CertificateRequest */
193
0
            if (!(meth->ext_flags & SSL_EXT_FLAG_RECEIVED))
194
0
                continue;
195
0
        }
196
        /*
197
         * We skip it if the callback is absent - except for a ClientHello where
198
         * we add an empty extension.
199
         */
200
50.4k
        if ((context & SSL_EXT_CLIENT_HELLO) == 0 && meth->add_cb == NULL)
201
0
            continue;
202
203
50.4k
        if (meth->add_cb != NULL) {
204
50.4k
            int cb_retval = meth->add_cb(SSL_CONNECTION_GET_USER_SSL(s),
205
50.4k
                meth->ext_type, context, &out,
206
50.4k
                &outlen, x, chainidx, &al,
207
50.4k
                meth->add_arg);
208
209
50.4k
            if (cb_retval < 0) {
210
0
                if (!for_comp)
211
0
                    SSLfatal(s, al, SSL_R_CALLBACK_FAILED);
212
0
                return 0; /* error */
213
0
            }
214
50.4k
            if (cb_retval == 0)
215
0
                continue; /* skip this extension */
216
50.4k
        }
217
218
50.4k
        if (!WPACKET_put_bytes_u16(pkt, meth->ext_type)
219
50.4k
            || !WPACKET_start_sub_packet_u16(pkt)
220
50.4k
            || (outlen > 0 && !WPACKET_memcpy(pkt, out, outlen))
221
50.4k
            || !WPACKET_close(pkt)) {
222
0
            if (meth->free_cb != NULL)
223
0
                meth->free_cb(SSL_CONNECTION_GET_USER_SSL(s), meth->ext_type,
224
0
                    context, out, meth->add_arg);
225
0
            if (!for_comp)
226
0
                SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
227
0
            return 0;
228
0
        }
229
50.4k
        if ((context & SSL_EXT_CLIENT_HELLO) != 0) {
230
            /*
231
             * We can't send duplicates: code logic should prevent this.
232
             */
233
50.4k
            if (!ossl_assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0)) {
234
0
                if (meth->free_cb != NULL)
235
0
                    meth->free_cb(SSL_CONNECTION_GET_USER_SSL(s), meth->ext_type,
236
0
                        context, out, meth->add_arg);
237
0
                if (!for_comp)
238
0
                    SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
239
0
                return 0;
240
0
            }
241
            /*
242
             * Indicate extension has been sent: this is both a sanity check to
243
             * ensure we don't send duplicate extensions and indicates that it
244
             * is not an error if the extension is present in ServerHello.
245
             */
246
50.4k
            meth->ext_flags |= SSL_EXT_FLAG_SENT;
247
50.4k
        }
248
50.4k
        if (meth->free_cb != NULL)
249
50.4k
            meth->free_cb(SSL_CONNECTION_GET_USER_SSL(s), meth->ext_type,
250
50.4k
                context, out, meth->add_arg);
251
50.4k
    }
252
143k
    return 1;
253
143k
}
254
255
/* Copy the flags from src to dst for any extensions that exist in both */
256
int custom_exts_copy_flags(custom_ext_methods *dst,
257
    const custom_ext_methods *src)
258
0
{
259
0
    size_t i;
260
0
    custom_ext_method *methsrc = src->meths;
261
262
0
    for (i = 0; i < src->meths_count; i++, methsrc++) {
263
0
        custom_ext_method *methdst = custom_ext_find(dst, methsrc->role,
264
0
            methsrc->ext_type, NULL);
265
266
0
        if (methdst == NULL)
267
0
            continue;
268
269
0
        methdst->ext_flags = methsrc->ext_flags;
270
0
    }
271
272
0
    return 1;
273
0
}
274
275
/* Copy old style API wrapper arguments */
276
static void custom_ext_copy_old_cb(custom_ext_method *methdst,
277
    const custom_ext_method *methsrc,
278
    int *err)
279
0
{
280
0
    if (methsrc->add_cb != custom_ext_add_old_cb_wrap)
281
0
        return;
282
283
0
    if (*err) {
284
0
        methdst->add_arg = NULL;
285
0
        methdst->parse_arg = NULL;
286
0
        return;
287
0
    }
288
289
0
    methdst->add_arg = OPENSSL_memdup(methsrc->add_arg,
290
0
        sizeof(custom_ext_add_cb_wrap));
291
0
    methdst->parse_arg = OPENSSL_memdup(methsrc->parse_arg,
292
0
        sizeof(custom_ext_parse_cb_wrap));
293
294
0
    if (methdst->add_arg == NULL || methdst->parse_arg == NULL)
295
0
        *err = 1;
296
297
0
    return;
298
0
}
299
300
/* Copy table of custom extensions */
301
int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src)
302
90.4k
{
303
90.4k
    size_t i;
304
90.4k
    int err = 0;
305
306
90.4k
    if (src->meths_count > 0) {
307
0
        dst->meths = OPENSSL_memdup(src->meths,
308
0
            sizeof(*src->meths) * src->meths_count);
309
0
        if (dst->meths == NULL)
310
0
            return 0;
311
0
        dst->meths_count = src->meths_count;
312
313
0
        for (i = 0; i < src->meths_count; i++)
314
0
            custom_ext_copy_old_cb(&dst->meths[i], &src->meths[i], &err);
315
0
    }
316
317
90.4k
    if (err) {
318
0
        custom_exts_free(dst);
319
0
        return 0;
320
0
    }
321
322
90.4k
    return 1;
323
90.4k
}
324
325
/* Copy custom extensions that were set on connection */
326
int custom_exts_copy_conn(custom_ext_methods *dst,
327
    const custom_ext_methods *src)
328
0
{
329
0
    size_t i;
330
0
    int err = 0;
331
332
0
    if (src->meths_count > 0) {
333
0
        size_t meths_count = 0;
334
335
0
        for (i = 0; i < src->meths_count; i++)
336
0
            if ((src->meths[i].ext_flags & SSL_EXT_FLAG_CONN) != 0)
337
0
                meths_count++;
338
339
0
        if (meths_count > 0) {
340
0
            custom_ext_method *methdst = OPENSSL_realloc(dst->meths,
341
0
                (dst->meths_count + meths_count) * sizeof(custom_ext_method));
342
343
0
            if (methdst == NULL)
344
0
                return 0;
345
346
0
            for (i = 0; i < dst->meths_count; i++)
347
0
                custom_ext_copy_old_cb(&methdst[i], &dst->meths[i], &err);
348
349
0
            dst->meths = methdst;
350
0
            methdst += dst->meths_count;
351
352
0
            for (i = 0; i < src->meths_count; i++) {
353
0
                custom_ext_method *methsrc = &src->meths[i];
354
355
0
                if ((methsrc->ext_flags & SSL_EXT_FLAG_CONN) == 0)
356
0
                    continue;
357
358
0
                memcpy(methdst, methsrc, sizeof(custom_ext_method));
359
0
                custom_ext_copy_old_cb(methdst, methsrc, &err);
360
0
                methdst++;
361
0
            }
362
363
0
            dst->meths_count += meths_count;
364
0
        }
365
0
    }
366
367
0
    if (err) {
368
0
        custom_exts_free(dst);
369
0
        return 0;
370
0
    }
371
372
0
    return 1;
373
0
}
374
375
void custom_exts_free(custom_ext_methods *exts)
376
326k
{
377
326k
    size_t i;
378
326k
    custom_ext_method *meth;
379
380
377k
    for (i = 0, meth = exts->meths; i < exts->meths_count; i++, meth++) {
381
50.4k
        if (meth->add_cb != custom_ext_add_old_cb_wrap)
382
50.4k
            continue;
383
384
        /* Old style API wrapper. Need to free the arguments too */
385
0
        OPENSSL_free(meth->add_arg);
386
0
        OPENSSL_free(meth->parse_arg);
387
0
    }
388
326k
    OPENSSL_free(exts->meths);
389
326k
    exts->meths = NULL;
390
326k
    exts->meths_count = 0;
391
326k
}
392
393
/* Return true if a client custom extension exists, false otherwise */
394
int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx, unsigned int ext_type)
395
0
{
396
0
    return custom_ext_find(&ctx->cert->custext, ENDPOINT_CLIENT, ext_type,
397
0
               NULL)
398
0
        != NULL;
399
0
}
400
401
int ossl_tls_add_custom_ext_intern(SSL_CTX *ctx, custom_ext_methods *exts,
402
    ENDPOINT role, unsigned int ext_type,
403
    unsigned int context,
404
    SSL_custom_ext_add_cb_ex add_cb,
405
    SSL_custom_ext_free_cb_ex free_cb,
406
    void *add_arg,
407
    SSL_custom_ext_parse_cb_ex parse_cb,
408
    void *parse_arg)
409
29.4k
{
410
29.4k
    custom_ext_method *meth, *tmp;
411
412
    /*
413
     * Check application error: if add_cb is not set free_cb will never be
414
     * called.
415
     */
416
29.4k
    if (add_cb == NULL && free_cb != NULL)
417
0
        return 0;
418
419
29.4k
    if (exts == NULL)
420
0
        exts = &ctx->cert->custext;
421
422
29.4k
#ifndef OPENSSL_NO_CT
423
    /*
424
     * We don't want applications registering callbacks for SCT extensions
425
     * whilst simultaneously using the built-in SCT validation features, as
426
     * these two things may not play well together.
427
     */
428
29.4k
    if (ext_type == TLSEXT_TYPE_signed_certificate_timestamp
429
0
        && (context & SSL_EXT_CLIENT_HELLO) != 0
430
0
        && ctx != NULL
431
0
        && SSL_CTX_ct_is_enabled(ctx))
432
0
        return 0;
433
29.4k
#endif
434
435
    /*
436
     * Don't add if extension supported internally, but make exception
437
     * for extension types that previously were not supported, but now are.
438
     */
439
29.4k
    if (SSL_extension_supported(ext_type)
440
0
        && ext_type != TLSEXT_TYPE_signed_certificate_timestamp)
441
0
        return 0;
442
443
    /* Extension type must fit in 16 bits */
444
29.4k
    if (ext_type > 0xffff)
445
0
        return 0;
446
    /* Search for duplicate */
447
29.4k
    if (custom_ext_find(exts, role, ext_type, NULL))
448
0
        return 0;
449
29.4k
    tmp = OPENSSL_realloc(exts->meths,
450
29.4k
        (exts->meths_count + 1) * sizeof(custom_ext_method));
451
29.4k
    if (tmp == NULL)
452
0
        return 0;
453
454
29.4k
    exts->meths = tmp;
455
29.4k
    meth = exts->meths + exts->meths_count;
456
29.4k
    memset(meth, 0, sizeof(*meth));
457
29.4k
    meth->role = role;
458
29.4k
    meth->context = context;
459
29.4k
    meth->parse_cb = parse_cb;
460
29.4k
    meth->add_cb = add_cb;
461
29.4k
    meth->free_cb = free_cb;
462
29.4k
    meth->ext_type = ext_type;
463
29.4k
    meth->ext_flags = (ctx == NULL) ? SSL_EXT_FLAG_CONN : 0;
464
29.4k
    meth->add_arg = add_arg;
465
29.4k
    meth->parse_arg = parse_arg;
466
29.4k
    exts->meths_count++;
467
29.4k
    return 1;
468
29.4k
}
469
470
static int add_old_custom_ext(SSL_CTX *ctx, ENDPOINT role,
471
    unsigned int ext_type,
472
    unsigned int context,
473
    custom_ext_add_cb add_cb,
474
    custom_ext_free_cb free_cb,
475
    void *add_arg,
476
    custom_ext_parse_cb parse_cb, void *parse_arg)
477
0
{
478
0
    custom_ext_add_cb_wrap *add_cb_wrap
479
0
        = OPENSSL_malloc(sizeof(*add_cb_wrap));
480
0
    custom_ext_parse_cb_wrap *parse_cb_wrap
481
0
        = OPENSSL_malloc(sizeof(*parse_cb_wrap));
482
0
    int ret;
483
484
0
    if (add_cb_wrap == NULL || parse_cb_wrap == NULL) {
485
0
        OPENSSL_free(add_cb_wrap);
486
0
        OPENSSL_free(parse_cb_wrap);
487
0
        return 0;
488
0
    }
489
490
0
    add_cb_wrap->add_arg = add_arg;
491
0
    add_cb_wrap->add_cb = add_cb;
492
0
    add_cb_wrap->free_cb = free_cb;
493
0
    parse_cb_wrap->parse_arg = parse_arg;
494
0
    parse_cb_wrap->parse_cb = parse_cb;
495
496
0
    ret = ossl_tls_add_custom_ext_intern(ctx, NULL, role, ext_type,
497
0
        context,
498
0
        custom_ext_add_old_cb_wrap,
499
0
        custom_ext_free_old_cb_wrap,
500
0
        add_cb_wrap,
501
0
        custom_ext_parse_old_cb_wrap,
502
0
        parse_cb_wrap);
503
504
0
    if (!ret) {
505
0
        OPENSSL_free(add_cb_wrap);
506
0
        OPENSSL_free(parse_cb_wrap);
507
0
    }
508
509
0
    return ret;
510
0
}
511
512
/* Application level functions to add the old custom extension callbacks */
513
int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
514
    custom_ext_add_cb add_cb,
515
    custom_ext_free_cb free_cb,
516
    void *add_arg,
517
    custom_ext_parse_cb parse_cb, void *parse_arg)
518
0
{
519
0
    return add_old_custom_ext(ctx, ENDPOINT_CLIENT, ext_type,
520
0
        SSL_EXT_TLS1_2_AND_BELOW_ONLY
521
0
            | SSL_EXT_CLIENT_HELLO
522
0
            | SSL_EXT_TLS1_2_SERVER_HELLO
523
0
            | SSL_EXT_IGNORE_ON_RESUMPTION,
524
0
        add_cb, free_cb, add_arg, parse_cb, parse_arg);
525
0
}
526
527
int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
528
    custom_ext_add_cb add_cb,
529
    custom_ext_free_cb free_cb,
530
    void *add_arg,
531
    custom_ext_parse_cb parse_cb, void *parse_arg)
532
0
{
533
0
    return add_old_custom_ext(ctx, ENDPOINT_SERVER, ext_type,
534
0
        SSL_EXT_TLS1_2_AND_BELOW_ONLY
535
0
            | SSL_EXT_CLIENT_HELLO
536
0
            | SSL_EXT_TLS1_2_SERVER_HELLO
537
0
            | SSL_EXT_IGNORE_ON_RESUMPTION,
538
0
        add_cb, free_cb, add_arg, parse_cb, parse_arg);
539
0
}
540
541
int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
542
    unsigned int context,
543
    SSL_custom_ext_add_cb_ex add_cb,
544
    SSL_custom_ext_free_cb_ex free_cb,
545
    void *add_arg,
546
    SSL_custom_ext_parse_cb_ex parse_cb, void *parse_arg)
547
0
{
548
0
    return ossl_tls_add_custom_ext_intern(ctx, NULL, ENDPOINT_BOTH, ext_type,
549
0
        context, add_cb, free_cb, add_arg,
550
0
        parse_cb, parse_arg);
551
0
}
552
553
int SSL_extension_supported(unsigned int ext_type)
554
50.4k
{
555
50.4k
    switch (ext_type) {
556
        /* Internally supported extensions. */
557
0
    case TLSEXT_TYPE_application_layer_protocol_negotiation:
558
0
    case TLSEXT_TYPE_ec_point_formats:
559
0
    case TLSEXT_TYPE_supported_groups:
560
0
    case TLSEXT_TYPE_key_share:
561
0
#ifndef OPENSSL_NO_NEXTPROTONEG
562
0
    case TLSEXT_TYPE_next_proto_neg:
563
0
#endif
564
0
    case TLSEXT_TYPE_padding:
565
0
    case TLSEXT_TYPE_renegotiate:
566
0
    case TLSEXT_TYPE_max_fragment_length:
567
0
    case TLSEXT_TYPE_server_name:
568
0
    case TLSEXT_TYPE_session_ticket:
569
0
    case TLSEXT_TYPE_signature_algorithms:
570
0
#ifndef OPENSSL_NO_SRP
571
0
    case TLSEXT_TYPE_srp:
572
0
#endif
573
0
#ifndef OPENSSL_NO_OCSP
574
0
    case TLSEXT_TYPE_status_request:
575
0
#endif
576
0
#ifndef OPENSSL_NO_CT
577
0
    case TLSEXT_TYPE_signed_certificate_timestamp:
578
0
#endif
579
0
#ifndef OPENSSL_NO_SRTP
580
0
    case TLSEXT_TYPE_use_srtp:
581
0
#endif
582
0
    case TLSEXT_TYPE_encrypt_then_mac:
583
0
    case TLSEXT_TYPE_supported_versions:
584
0
    case TLSEXT_TYPE_extended_master_secret:
585
0
    case TLSEXT_TYPE_psk_kex_modes:
586
0
    case TLSEXT_TYPE_cookie:
587
0
    case TLSEXT_TYPE_early_data:
588
0
    case TLSEXT_TYPE_certificate_authorities:
589
0
    case TLSEXT_TYPE_psk:
590
0
    case TLSEXT_TYPE_post_handshake_auth:
591
0
    case TLSEXT_TYPE_compress_certificate:
592
0
    case TLSEXT_TYPE_client_cert_type:
593
0
    case TLSEXT_TYPE_server_cert_type:
594
0
        return 1;
595
50.4k
    default:
596
50.4k
        return 0;
597
50.4k
    }
598
50.4k
}