Exemplo n.º 1
0
int s2n_connection_kill(struct s2n_connection *conn)
{
    conn->closed = 1;

    /* Delay between 10 and 30 seconds in nanoseconds */
    int64_t min = TEN_S, max = 3 * TEN_S;

    /* Keep track of the delay so that it can be enforced */
    conn->delay = min + s2n_public_random(max - min);

    /* Restart the write timer */
    GUARD(s2n_timer_start(conn->config, &conn->write_timer));

    if (conn->blinding == S2N_BUILT_IN_BLINDING) {
        struct timespec sleep_time = { .tv_sec = conn->delay / ONE_S, .tv_nsec = conn->delay % ONE_S };
        int r;

        do {
            r = nanosleep(&sleep_time, &sleep_time);
        }
        while (r != 0);
    }

    return 0;
}

const uint8_t *s2n_connection_get_ocsp_response(struct s2n_connection *conn, uint32_t *length)
{
    if (!length) {
        return NULL;
    }

    *length = conn->status_response.size;
    return conn->status_response.data;
}
Exemplo n.º 2
0
int s2n_connection_get_delay(struct s2n_connection *conn)
{
    /* Delay between 1ms and 10 seconds in microseconds */
    int min = 1000, max = 10 * 1000 * 1000;
    return min + s2n_public_random(max - min);
}
Exemplo n.º 3
0
int64_t s2n_connection_get_delay(struct s2n_connection *conn)
{
    /* Delay between 1ms and 10 seconds in nanoseconds */
    int64_t min = ONE_MS, max = TEN_S;
    return min + s2n_public_random(max - min);
}