Home | History | Annotate | Line # | Download | only in test
      1      1.1  christos /*
      2      1.1  christos  * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
      3      1.1  christos  *
      4      1.1  christos  * Licensed under the Apache License 2.0 (the "License").  You may not use
      5      1.1  christos  * this file except in compliance with the License.  You can obtain a copy
      6      1.1  christos  * in the file LICENSE in the source distribution or at
      7      1.1  christos  * https://www.openssl.org/source/license.html
      8      1.1  christos  */
      9      1.1  christos 
     10      1.1  christos #include <openssl/ssl.h>
     11      1.1  christos #include <string.h>
     12      1.1  christos #include "helpers/ssltestlib.h"
     13      1.1  christos #include "testutil.h"
     14      1.1  christos #include "internal/packet.h"
     15      1.1  christos 
     16      1.1  christos static char *cert = NULL;
     17      1.1  christos static char *privkey = NULL;
     18      1.1  christos 
     19      1.1  christos static BIO *s_to_c_fbio = NULL, *c_to_s_fbio = NULL;
     20      1.1  christos static int chseen = 0, shseen = 0, sccsseen = 0, ccsaftersh = 0;
     21      1.1  christos static int ccsbeforesh = 0, sappdataseen = 0, cappdataseen = 0, badccs = 0;
     22      1.1  christos static int badvers = 0, badsessid = 0;
     23      1.1  christos 
     24      1.1  christos static unsigned char chsessid[SSL_MAX_SSL_SESSION_ID_LENGTH];
     25      1.1  christos static size_t chsessidlen = 0;
     26      1.1  christos 
     27      1.1  christos static int watchccs_new(BIO *bi);
     28      1.1  christos static int watchccs_free(BIO *a);
     29      1.1  christos static int watchccs_read(BIO *b, char *out, int outl);
     30      1.1  christos static int watchccs_write(BIO *b, const char *in, int inl);
     31      1.1  christos static long watchccs_ctrl(BIO *b, int cmd, long num, void *ptr);
     32      1.1  christos static int watchccs_gets(BIO *bp, char *buf, int size);
     33      1.1  christos static int watchccs_puts(BIO *bp, const char *str);
     34      1.1  christos 
     35      1.1  christos /* Choose a sufficiently large type likely to be unused for this custom BIO */
     36  1.1.1.2  christos #define BIO_TYPE_WATCHCCS_FILTER (0x80 | BIO_TYPE_FILTER)
     37      1.1  christos 
     38      1.1  christos static BIO_METHOD *method_watchccs = NULL;
     39      1.1  christos 
     40      1.1  christos static const BIO_METHOD *bio_f_watchccs_filter(void)
     41      1.1  christos {
     42      1.1  christos     if (method_watchccs == NULL) {
     43      1.1  christos         method_watchccs = BIO_meth_new(BIO_TYPE_WATCHCCS_FILTER,
     44  1.1.1.2  christos             "Watch CCS filter");
     45      1.1  christos         if (method_watchccs == NULL
     46      1.1  christos             || !BIO_meth_set_write(method_watchccs, watchccs_write)
     47      1.1  christos             || !BIO_meth_set_read(method_watchccs, watchccs_read)
     48      1.1  christos             || !BIO_meth_set_puts(method_watchccs, watchccs_puts)
     49      1.1  christos             || !BIO_meth_set_gets(method_watchccs, watchccs_gets)
     50      1.1  christos             || !BIO_meth_set_ctrl(method_watchccs, watchccs_ctrl)
     51      1.1  christos             || !BIO_meth_set_create(method_watchccs, watchccs_new)
     52      1.1  christos             || !BIO_meth_set_destroy(method_watchccs, watchccs_free))
     53      1.1  christos             return NULL;
     54      1.1  christos     }
     55      1.1  christos     return method_watchccs;
     56      1.1  christos }
     57      1.1  christos 
     58      1.1  christos static int watchccs_new(BIO *bio)
     59      1.1  christos {
     60      1.1  christos     BIO_set_init(bio, 1);
     61      1.1  christos     return 1;
     62      1.1  christos }
     63      1.1  christos 
     64      1.1  christos static int watchccs_free(BIO *bio)
     65      1.1  christos {
     66      1.1  christos     BIO_set_init(bio, 0);
     67      1.1  christos     return 1;
     68      1.1  christos }
     69      1.1  christos 
     70      1.1  christos static int watchccs_read(BIO *bio, char *out, int outl)
     71      1.1  christos {
     72      1.1  christos     int ret = 0;
     73      1.1  christos     BIO *next = BIO_next(bio);
     74      1.1  christos 
     75      1.1  christos     if (outl <= 0)
     76      1.1  christos         return 0;
     77      1.1  christos     if (next == NULL)
     78      1.1  christos         return 0;
     79      1.1  christos 
     80      1.1  christos     BIO_clear_retry_flags(bio);
     81      1.1  christos 
     82      1.1  christos     ret = BIO_read(next, out, outl);
     83      1.1  christos     if (ret <= 0 && BIO_should_read(next))
     84      1.1  christos         BIO_set_retry_read(bio);
     85      1.1  christos 
     86      1.1  christos     return ret;
     87      1.1  christos }
     88      1.1  christos 
     89      1.1  christos static int watchccs_write(BIO *bio, const char *in, int inl)
     90      1.1  christos {
     91      1.1  christos     int ret = 0;
     92      1.1  christos     BIO *next = BIO_next(bio);
     93      1.1  christos     PACKET pkt, msg, msgbody, sessionid;
     94      1.1  christos     unsigned int rectype, recvers, msgtype, expectedrecvers;
     95      1.1  christos 
     96      1.1  christos     if (inl <= 0)
     97      1.1  christos         return 0;
     98      1.1  christos     if (next == NULL)
     99      1.1  christos         return 0;
    100      1.1  christos 
    101      1.1  christos     BIO_clear_retry_flags(bio);
    102      1.1  christos 
    103      1.1  christos     if (!PACKET_buf_init(&pkt, (const unsigned char *)in, inl))
    104      1.1  christos         return 0;
    105      1.1  christos 
    106      1.1  christos     /* We assume that we always write complete records each time */
    107      1.1  christos     while (PACKET_remaining(&pkt)) {
    108      1.1  christos         if (!PACKET_get_1(&pkt, &rectype)
    109  1.1.1.2  christos             || !PACKET_get_net_2(&pkt, &recvers)
    110  1.1.1.2  christos             || !PACKET_get_length_prefixed_2(&pkt, &msg))
    111      1.1  christos             return 0;
    112      1.1  christos 
    113      1.1  christos         expectedrecvers = TLS1_2_VERSION;
    114      1.1  christos 
    115      1.1  christos         if (rectype == SSL3_RT_HANDSHAKE) {
    116      1.1  christos             if (!PACKET_get_1(&msg, &msgtype)
    117  1.1.1.2  christos                 || !PACKET_get_length_prefixed_3(&msg, &msgbody))
    118      1.1  christos                 return 0;
    119      1.1  christos             if (msgtype == SSL3_MT_CLIENT_HELLO) {
    120      1.1  christos                 chseen++;
    121      1.1  christos 
    122      1.1  christos                 /*
    123      1.1  christos                  * Skip legacy_version (2 bytes) and Random (32 bytes) to read
    124      1.1  christos                  * session_id.
    125      1.1  christos                  */
    126      1.1  christos                 if (!PACKET_forward(&msgbody, 34)
    127  1.1.1.2  christos                     || !PACKET_get_length_prefixed_1(&msgbody, &sessionid))
    128      1.1  christos                     return 0;
    129      1.1  christos 
    130      1.1  christos                 if (chseen == 1) {
    131      1.1  christos                     expectedrecvers = TLS1_VERSION;
    132      1.1  christos 
    133      1.1  christos                     /* Save the session id for later */
    134      1.1  christos                     chsessidlen = PACKET_remaining(&sessionid);
    135      1.1  christos                     if (!PACKET_copy_bytes(&sessionid, chsessid, chsessidlen))
    136      1.1  christos                         return 0;
    137      1.1  christos                 } else {
    138      1.1  christos                     /*
    139      1.1  christos                      * Check the session id for the second ClientHello is the
    140      1.1  christos                      * same as the first one.
    141      1.1  christos                      */
    142      1.1  christos                     if (PACKET_remaining(&sessionid) != chsessidlen
    143  1.1.1.2  christos                         || (chsessidlen > 0
    144  1.1.1.2  christos                             && memcmp(chsessid, PACKET_data(&sessionid),
    145  1.1.1.2  christos                                    chsessidlen)
    146  1.1.1.2  christos                                 != 0))
    147      1.1  christos                         badsessid = 1;
    148      1.1  christos                 }
    149      1.1  christos             } else if (msgtype == SSL3_MT_SERVER_HELLO) {
    150      1.1  christos                 shseen++;
    151      1.1  christos                 /*
    152      1.1  christos                  * Skip legacy_version (2 bytes) and Random (32 bytes) to read
    153      1.1  christos                  * session_id.
    154      1.1  christos                  */
    155      1.1  christos                 if (!PACKET_forward(&msgbody, 34)
    156  1.1.1.2  christos                     || !PACKET_get_length_prefixed_1(&msgbody, &sessionid))
    157      1.1  christos                     return 0;
    158      1.1  christos 
    159      1.1  christos                 /*
    160      1.1  christos                  * Check the session id is the same as the one in the
    161      1.1  christos                  * ClientHello
    162      1.1  christos                  */
    163      1.1  christos                 if (PACKET_remaining(&sessionid) != chsessidlen
    164  1.1.1.2  christos                     || (chsessidlen > 0
    165  1.1.1.2  christos                         && memcmp(chsessid, PACKET_data(&sessionid),
    166  1.1.1.2  christos                                chsessidlen)
    167  1.1.1.2  christos                             != 0))
    168      1.1  christos                     badsessid = 1;
    169      1.1  christos             }
    170      1.1  christos         } else if (rectype == SSL3_RT_CHANGE_CIPHER_SPEC) {
    171      1.1  christos             if (bio == s_to_c_fbio) {
    172      1.1  christos                 /*
    173      1.1  christos                  * Server writing. We shouldn't have written any app data
    174      1.1  christos                  * yet, and we should have seen both the ClientHello and the
    175      1.1  christos                  * ServerHello
    176      1.1  christos                  */
    177      1.1  christos                 if (!sappdataseen
    178  1.1.1.2  christos                     && chseen == 1
    179  1.1.1.2  christos                     && shseen == 1
    180  1.1.1.2  christos                     && !sccsseen)
    181      1.1  christos                     sccsseen = 1;
    182      1.1  christos                 else
    183      1.1  christos                     badccs = 1;
    184      1.1  christos             } else if (!cappdataseen) {
    185      1.1  christos                 /*
    186      1.1  christos                  * Client writing. We shouldn't have written any app data
    187      1.1  christos                  * yet, and we should have seen the ClientHello
    188      1.1  christos                  */
    189      1.1  christos                 if (shseen == 1 && !ccsaftersh)
    190      1.1  christos                     ccsaftersh = 1;
    191      1.1  christos                 else if (shseen == 0 && !ccsbeforesh)
    192      1.1  christos                     ccsbeforesh = 1;
    193      1.1  christos                 else
    194      1.1  christos                     badccs = 1;
    195      1.1  christos             } else {
    196      1.1  christos                 badccs = 1;
    197      1.1  christos             }
    198      1.1  christos         } else if (rectype == SSL3_RT_APPLICATION_DATA) {
    199      1.1  christos             if (bio == s_to_c_fbio)
    200      1.1  christos                 sappdataseen = 1;
    201      1.1  christos             else
    202      1.1  christos                 cappdataseen = 1;
    203      1.1  christos         }
    204      1.1  christos         if (recvers != expectedrecvers)
    205      1.1  christos             badvers = 1;
    206      1.1  christos     }
    207      1.1  christos 
    208      1.1  christos     ret = BIO_write(next, in, inl);
    209      1.1  christos     if (ret <= 0 && BIO_should_write(next))
    210      1.1  christos         BIO_set_retry_write(bio);
    211      1.1  christos 
    212      1.1  christos     return ret;
    213      1.1  christos }
    214      1.1  christos 
    215      1.1  christos static long watchccs_ctrl(BIO *bio, int cmd, long num, void *ptr)
    216      1.1  christos {
    217      1.1  christos     long ret;
    218      1.1  christos     BIO *next = BIO_next(bio);
    219      1.1  christos 
    220      1.1  christos     if (next == NULL)
    221      1.1  christos         return 0;
    222      1.1  christos 
    223      1.1  christos     switch (cmd) {
    224      1.1  christos     case BIO_CTRL_DUP:
    225      1.1  christos         ret = 0;
    226      1.1  christos         break;
    227      1.1  christos     default:
    228      1.1  christos         ret = BIO_ctrl(next, cmd, num, ptr);
    229      1.1  christos         break;
    230      1.1  christos     }
    231      1.1  christos     return ret;
    232      1.1  christos }
    233      1.1  christos 
    234      1.1  christos static int watchccs_gets(BIO *bio, char *buf, int size)
    235      1.1  christos {
    236      1.1  christos     /* We don't support this - not needed anyway */
    237      1.1  christos     return -1;
    238      1.1  christos }
    239      1.1  christos 
    240      1.1  christos static int watchccs_puts(BIO *bio, const char *str)
    241      1.1  christos {
    242      1.1  christos     return watchccs_write(bio, str, strlen(str));
    243      1.1  christos }
    244      1.1  christos 
    245      1.1  christos static int test_tls13ccs(int tst)
    246      1.1  christos {
    247      1.1  christos     SSL_CTX *sctx = NULL, *cctx = NULL;
    248      1.1  christos     SSL *sssl = NULL, *cssl = NULL;
    249      1.1  christos     int ret = 0;
    250      1.1  christos     const char msg[] = "Dummy data";
    251      1.1  christos     char buf[80];
    252      1.1  christos     size_t written, readbytes;
    253      1.1  christos     SSL_SESSION *sess = NULL;
    254      1.1  christos 
    255      1.1  christos     chseen = shseen = sccsseen = ccsaftersh = ccsbeforesh = 0;
    256      1.1  christos     sappdataseen = cappdataseen = badccs = badvers = badsessid = 0;
    257      1.1  christos     chsessidlen = 0;
    258      1.1  christos 
    259      1.1  christos     if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
    260  1.1.1.2  christos             TLS_client_method(), TLS1_VERSION, 0,
    261  1.1.1.2  christos             &sctx, &cctx, cert, privkey))
    262      1.1  christos         || !TEST_true(SSL_CTX_set_max_early_data(sctx,
    263  1.1.1.2  christos             SSL3_RT_MAX_PLAIN_LENGTH)))
    264      1.1  christos         goto err;
    265      1.1  christos 
    266      1.1  christos     /*
    267      1.1  christos      * Test 0: Simple Handshake
    268      1.1  christos      * Test 1: Simple Handshake, client middlebox compat mode disabled
    269      1.1  christos      * Test 2: Simple Handshake, server middlebox compat mode disabled
    270      1.1  christos      * Test 3: HRR Handshake
    271      1.1  christos      * Test 4: HRR Handshake, client middlebox compat mode disabled
    272      1.1  christos      * Test 5: HRR Handshake, server middlebox compat mode disabled
    273      1.1  christos      * Test 6: Early data handshake
    274      1.1  christos      * Test 7: Early data handshake, client middlebox compat mode disabled
    275      1.1  christos      * Test 8: Early data handshake, server middlebox compat mode disabled
    276      1.1  christos      * Test 9: Early data then HRR
    277      1.1  christos      * Test 10: Early data then HRR, client middlebox compat mode disabled
    278      1.1  christos      * Test 11: Early data then HRR, server middlebox compat mode disabled
    279      1.1  christos      */
    280      1.1  christos     switch (tst) {
    281      1.1  christos     case 0:
    282      1.1  christos     case 3:
    283      1.1  christos     case 6:
    284      1.1  christos     case 9:
    285      1.1  christos         break;
    286      1.1  christos     case 1:
    287      1.1  christos     case 4:
    288      1.1  christos     case 7:
    289      1.1  christos     case 10:
    290      1.1  christos         SSL_CTX_clear_options(cctx, SSL_OP_ENABLE_MIDDLEBOX_COMPAT);
    291      1.1  christos         break;
    292      1.1  christos     case 2:
    293      1.1  christos     case 5:
    294      1.1  christos     case 8:
    295      1.1  christos     case 11:
    296      1.1  christos         SSL_CTX_clear_options(sctx, SSL_OP_ENABLE_MIDDLEBOX_COMPAT);
    297      1.1  christos         break;
    298      1.1  christos     default:
    299      1.1  christos         TEST_error("Invalid test value");
    300      1.1  christos         goto err;
    301      1.1  christos     }
    302      1.1  christos 
    303      1.1  christos     if (tst >= 6) {
    304      1.1  christos         /* Get a session suitable for early_data */
    305      1.1  christos         if (!TEST_true(create_ssl_objects(sctx, cctx, &sssl, &cssl, NULL, NULL))
    306  1.1.1.2  christos             || !TEST_true(create_ssl_connection(sssl, cssl, SSL_ERROR_NONE)))
    307      1.1  christos             goto err;
    308      1.1  christos         sess = SSL_get1_session(cssl);
    309      1.1  christos         if (!TEST_ptr(sess))
    310      1.1  christos             goto err;
    311      1.1  christos         SSL_shutdown(cssl);
    312      1.1  christos         SSL_shutdown(sssl);
    313      1.1  christos         SSL_free(sssl);
    314      1.1  christos         SSL_free(cssl);
    315      1.1  christos         sssl = cssl = NULL;
    316      1.1  christos     }
    317      1.1  christos 
    318      1.1  christos     if ((tst >= 3 && tst <= 5) || tst >= 9) {
    319      1.1  christos         /* HRR handshake */
    320      1.1  christos #if defined(OPENSSL_NO_EC)
    321  1.1.1.2  christos #if !defined(OPENSSL_NO_DH)
    322      1.1  christos         if (!TEST_true(SSL_CTX_set1_groups_list(sctx, "ffdhe3072")))
    323      1.1  christos             goto err;
    324  1.1.1.2  christos #endif
    325      1.1  christos #else
    326      1.1  christos         if (!TEST_true(SSL_CTX_set1_groups_list(sctx, "P-384")))
    327      1.1  christos             goto err;
    328      1.1  christos #endif
    329      1.1  christos     }
    330      1.1  christos 
    331      1.1  christos     s_to_c_fbio = BIO_new(bio_f_watchccs_filter());
    332      1.1  christos     c_to_s_fbio = BIO_new(bio_f_watchccs_filter());
    333      1.1  christos     if (!TEST_ptr(s_to_c_fbio)
    334  1.1.1.2  christos         || !TEST_ptr(c_to_s_fbio)) {
    335      1.1  christos         BIO_free(s_to_c_fbio);
    336      1.1  christos         BIO_free(c_to_s_fbio);
    337      1.1  christos         goto err;
    338      1.1  christos     }
    339      1.1  christos 
    340      1.1  christos     /* BIOs get freed on error */
    341      1.1  christos     if (!TEST_true(create_ssl_objects(sctx, cctx, &sssl, &cssl, s_to_c_fbio,
    342  1.1.1.2  christos             c_to_s_fbio)))
    343      1.1  christos         goto err;
    344      1.1  christos 
    345      1.1  christos     if (tst >= 6) {
    346      1.1  christos         /* Early data */
    347      1.1  christos         if (!TEST_true(SSL_set_session(cssl, sess))
    348  1.1.1.2  christos             || !TEST_true(SSL_write_early_data(cssl, msg, strlen(msg),
    349  1.1.1.2  christos                 &written))
    350  1.1.1.2  christos             || (tst <= 8
    351  1.1.1.2  christos                 && !TEST_int_eq(SSL_read_early_data(sssl, buf, sizeof(buf),
    352  1.1.1.2  christos                                     &readbytes),
    353  1.1.1.2  christos                     SSL_READ_EARLY_DATA_SUCCESS)))
    354      1.1  christos             goto err;
    355      1.1  christos         if (tst <= 8) {
    356      1.1  christos             if (!TEST_int_gt(SSL_connect(cssl), 0))
    357      1.1  christos                 goto err;
    358      1.1  christos         } else {
    359      1.1  christos             if (!TEST_int_le(SSL_connect(cssl), 0))
    360      1.1  christos                 goto err;
    361      1.1  christos         }
    362  1.1.1.2  christos         if (!TEST_int_eq(SSL_read_early_data(sssl, buf, sizeof(buf),
    363  1.1.1.2  christos                              &readbytes),
    364  1.1.1.2  christos                 SSL_READ_EARLY_DATA_FINISH))
    365      1.1  christos             goto err;
    366      1.1  christos     }
    367      1.1  christos 
    368      1.1  christos     /* Perform handshake (or complete it if doing early data ) */
    369      1.1  christos     if (!TEST_true(create_ssl_connection(sssl, cssl, SSL_ERROR_NONE)))
    370      1.1  christos         goto err;
    371      1.1  christos 
    372      1.1  christos     /*
    373      1.1  christos      * Check there were no unexpected CCS messages, all record versions
    374      1.1  christos      * were as expected, and that the session ids were reflected by the server
    375      1.1  christos      * correctly.
    376      1.1  christos      */
    377      1.1  christos     if (!TEST_false(badccs) || !TEST_false(badvers) || !TEST_false(badsessid))
    378      1.1  christos         goto err;
    379      1.1  christos 
    380      1.1  christos     switch (tst) {
    381      1.1  christos     case 0:
    382      1.1  christos         if (!TEST_true(sccsseen)
    383  1.1.1.2  christos             || !TEST_true(ccsaftersh)
    384  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    385  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    386      1.1  christos             goto err;
    387      1.1  christos         break;
    388      1.1  christos 
    389      1.1  christos     case 1:
    390      1.1  christos         if (!TEST_true(sccsseen)
    391  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    392  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    393  1.1.1.2  christos             || !TEST_size_t_eq(chsessidlen, 0))
    394      1.1  christos             goto err;
    395      1.1  christos         break;
    396      1.1  christos 
    397      1.1  christos     case 2:
    398      1.1  christos         if (!TEST_false(sccsseen)
    399  1.1.1.2  christos             || !TEST_true(ccsaftersh)
    400  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    401  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    402      1.1  christos             goto err;
    403      1.1  christos         break;
    404      1.1  christos 
    405      1.1  christos     case 3:
    406      1.1  christos         if (!TEST_true(sccsseen)
    407  1.1.1.2  christos             || !TEST_true(ccsaftersh)
    408  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    409  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    410      1.1  christos             goto err;
    411      1.1  christos         break;
    412      1.1  christos 
    413      1.1  christos     case 4:
    414      1.1  christos         if (!TEST_true(sccsseen)
    415  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    416  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    417  1.1.1.2  christos             || !TEST_size_t_eq(chsessidlen, 0))
    418      1.1  christos             goto err;
    419      1.1  christos         break;
    420      1.1  christos 
    421      1.1  christos     case 5:
    422      1.1  christos         if (!TEST_false(sccsseen)
    423  1.1.1.2  christos             || !TEST_true(ccsaftersh)
    424  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    425  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    426      1.1  christos             goto err;
    427      1.1  christos         break;
    428      1.1  christos 
    429      1.1  christos     case 6:
    430      1.1  christos         if (!TEST_true(sccsseen)
    431  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    432  1.1.1.2  christos             || !TEST_true(ccsbeforesh)
    433  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    434      1.1  christos             goto err;
    435      1.1  christos         break;
    436      1.1  christos 
    437      1.1  christos     case 7:
    438      1.1  christos         if (!TEST_true(sccsseen)
    439  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    440  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    441  1.1.1.2  christos             || !TEST_size_t_eq(chsessidlen, 0))
    442      1.1  christos             goto err;
    443      1.1  christos         break;
    444      1.1  christos 
    445      1.1  christos     case 8:
    446      1.1  christos         if (!TEST_false(sccsseen)
    447  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    448  1.1.1.2  christos             || !TEST_true(ccsbeforesh)
    449  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    450      1.1  christos             goto err;
    451      1.1  christos         break;
    452      1.1  christos 
    453      1.1  christos     case 9:
    454      1.1  christos         if (!TEST_true(sccsseen)
    455  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    456  1.1.1.2  christos             || !TEST_true(ccsbeforesh)
    457  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    458      1.1  christos             goto err;
    459      1.1  christos         break;
    460      1.1  christos 
    461      1.1  christos     case 10:
    462      1.1  christos         if (!TEST_true(sccsseen)
    463  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    464  1.1.1.2  christos             || !TEST_false(ccsbeforesh)
    465  1.1.1.2  christos             || !TEST_size_t_eq(chsessidlen, 0))
    466      1.1  christos             goto err;
    467      1.1  christos         break;
    468      1.1  christos 
    469      1.1  christos     case 11:
    470      1.1  christos         if (!TEST_false(sccsseen)
    471  1.1.1.2  christos             || !TEST_false(ccsaftersh)
    472  1.1.1.2  christos             || !TEST_true(ccsbeforesh)
    473  1.1.1.2  christos             || !TEST_size_t_gt(chsessidlen, 0))
    474      1.1  christos             goto err;
    475      1.1  christos         break;
    476      1.1  christos     }
    477      1.1  christos 
    478      1.1  christos     ret = 1;
    479  1.1.1.2  christos err:
    480      1.1  christos     SSL_SESSION_free(sess);
    481      1.1  christos     SSL_free(sssl);
    482      1.1  christos     SSL_free(cssl);
    483      1.1  christos     SSL_CTX_free(sctx);
    484      1.1  christos     SSL_CTX_free(cctx);
    485      1.1  christos 
    486      1.1  christos     return ret;
    487      1.1  christos }
    488      1.1  christos 
    489      1.1  christos OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
    490      1.1  christos 
    491      1.1  christos int setup_tests(void)
    492      1.1  christos {
    493      1.1  christos     if (!test_skip_common_options()) {
    494      1.1  christos         TEST_error("Error parsing test options\n");
    495      1.1  christos         return 0;
    496      1.1  christos     }
    497      1.1  christos 
    498      1.1  christos     if (!TEST_ptr(cert = test_get_argument(0))
    499  1.1.1.2  christos         || !TEST_ptr(privkey = test_get_argument(1)))
    500      1.1  christos         return 0;
    501      1.1  christos 
    502      1.1  christos     ADD_ALL_TESTS(test_tls13ccs, 12);
    503      1.1  christos 
    504      1.1  christos     return 1;
    505      1.1  christos }
    506      1.1  christos 
    507      1.1  christos void cleanup_tests(void)
    508      1.1  christos {
    509      1.1  christos     BIO_meth_free(method_watchccs);
    510      1.1  christos }
    511