Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 48e7b18efcd77890f36272b46a4603d15a1ac221 authored by Neil Horman on 26 July 2024, 15:01:05 UTC, committed by Neil Horman on 09 August 2024, 12:28:38 UTC
limit bignums to 128 bytes
Keep us from spinning forever doing huge amounts of math in the fuzzer

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/25013)

(cherry picked from commit f0768376e1639d12a328745ef69c90d584138074)
1 parent 67c6330
  • Files
  • Changes
  • 6cdbfeb
  • /
  • test
  • /
  • ssl_handshake_rtt_test.c
Raw File
Cook and download a directory from the Software Heritage Vault

You have requested the cooking of the directory with identifier None into a standard tar.gz archive.

Are you sure you want to continue ?

Download a directory from the Software Heritage Vault

You have requested the download of the directory with identifier None as a standard tar.gz archive.

Are you sure you want to continue ?

Cook and download a revision from the Software Heritage Vault

You have requested the cooking of the history heading to revision with identifier swh:1:rev:48e7b18efcd77890f36272b46a4603d15a1ac221 into a bare git archive.

Are you sure you want to continue ?

Download a revision from the Software Heritage Vault

You have requested the download of the history heading to revision with identifier swh:1:rev:48e7b18efcd77890f36272b46a4603d15a1ac221 as a bare git archive.

Are you sure you want to continue ?

Invalid Email !

The provided email is not well-formed.

Download link has expired

The requested archive is no longer available for download from the Software Heritage Vault.

Do you want to cook it again ?

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • content
revision badge
swh:1:rev:48e7b18efcd77890f36272b46a4603d15a1ac221
content badge Iframe embedding
swh:1:cnt:0e54284f04a43fc5c0da76ce6902ed7cb4d69b4a
ssl_handshake_rtt_test.c
/*
 * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

/*
 * We need access to the deprecated low level HMAC APIs for legacy purposes
 * when the deprecated calls are not hidden
 */
#ifndef OPENSSL_NO_DEPRECATED_3_0
# define OPENSSL_SUPPRESS_DEPRECATED
#endif

#include <stdio.h>
#include <string.h>

#include <openssl/opensslconf.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <openssl/engine.h>

#include "helpers/ssltestlib.h"
#include "testutil.h"
#include "testutil/output.h"
#include "internal/ktls.h"
#include "../ssl/ssl_local.h"
#include "../ssl/statem/statem_local.h"

static OSSL_LIB_CTX *libctx = NULL;
static char *cert = NULL;
static char *privkey = NULL;

/*
 * Test 0: Clientside handshake RTT (TLSv1.2)
 * Test 1: Serverside handshake RTT (TLSv1.2)
 * Test 2: Clientside handshake RTT (TLSv1.3)
 * Test 3: Serverside handshake RTT (TLSv1.3)
 * Test 4: Clientside handshake RTT with Early Data (TLSv1.3)
 */
static int test_handshake_rtt(int tst)
{
    SSL_CTX *cctx = NULL, *sctx = NULL;
    SSL *clientssl = NULL, *serverssl = NULL;
    int testresult = 0;
    SSL_CONNECTION *s = NULL;
    OSSL_STATEM *st = NULL;
    uint64_t rtt;

#ifdef OPENSSL_NO_TLS1_2
    if (tst <= 1)
        return 1;
#endif
#ifdef OSSL_NO_USABLE_TLS1_3
    if (tst >= 2)
        return 1;
#endif

    if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
                                       TLS_client_method(),
                                       TLS1_VERSION,
                                       (tst <= 1) ? TLS1_2_VERSION
                                                  : TLS1_3_VERSION,
                                       &sctx, &cctx, cert, privkey))
            || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
                                             NULL, NULL)))
        goto end;

    s = SSL_CONNECTION_FROM_SSL(tst % 2 == 0 ? clientssl : serverssl);
    if (!TEST_ptr(s) || !TEST_ptr(st = &s->statem))
        return 0;

    /* implicitly set handshake rtt with a delay */
    switch (tst) {
    case 0:
        st->hand_state = TLS_ST_CW_CLNT_HELLO;
        ossl_statem_client_write_transition(s);
        OSSL_sleep(1);
        st->hand_state = TLS_ST_CR_SRVR_DONE;
        ossl_statem_client_write_transition(s);
        break;
    case 1:
        st->hand_state = TLS_ST_SW_SRVR_DONE;
        ossl_statem_server_write_transition(s);
        OSSL_sleep(1);
        st->hand_state = TLS_ST_SR_FINISHED;
        ossl_statem_server_write_transition(s);
        break;
    case 2:
        st->hand_state = TLS_ST_CW_CLNT_HELLO;
        ossl_statem_client_write_transition(s);
        OSSL_sleep(1);
        st->hand_state = TLS_ST_CR_SRVR_DONE;
        ossl_statem_client_write_transition(s);
        break;
    case 3:
        st->hand_state = TLS_ST_SW_SRVR_DONE;
        ossl_statem_server_write_transition(s);
        OSSL_sleep(1);
        st->hand_state = TLS_ST_SR_FINISHED;
        ossl_statem_server_write_transition(s);
        break;
    case 4:
        st->hand_state = TLS_ST_EARLY_DATA;
        ossl_statem_client_write_transition(s);
        OSSL_sleep(1);
        st->hand_state = TLS_ST_CR_SRVR_DONE;
        ossl_statem_client_write_transition(s);
        break;
    }

    if (!TEST_int_gt(SSL_get_handshake_rtt(SSL_CONNECTION_GET_SSL(s), &rtt), 0))
        goto end;
    /* 1 millisec is the absolute minimum it could be given the delay */
    if (!TEST_uint64_t_ge(rtt, 1000))
        goto end;

    testresult = 1;

 end:
    SSL_free(serverssl);
    SSL_free(clientssl);
    SSL_CTX_free(sctx);
    SSL_CTX_free(cctx);

    return testresult;
}

int setup_tests(void)
{
    ADD_ALL_TESTS(test_handshake_rtt, 5);

    return 1;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top