Coverage Report

Created: 2025-12-31 06:58

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