Commit b2cc7f31 authored by Matt Caswell's avatar Matt Caswell
Browse files

Implement client side parsing of the early_data extension

parent e0655186
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -138,8 +138,8 @@ static const EXTENSION_DEFINITION ext_defs[] = {
    {
        TLSEXT_TYPE_early_data,
        EXT_CLIENT_HELLO | EXT_TLS1_3_ENCRYPTED_EXTENSIONS,
        NULL, tls_parse_ctos_early_data, NULL, tls_construct_stoc_early_data,
        tls_construct_ctos_early_data, NULL
        NULL, tls_parse_ctos_early_data, tls_parse_stoc_early_data,
        tls_construct_stoc_early_data, tls_construct_ctos_early_data, NULL
    },
#ifndef OPENSSL_NO_EC
    {
+28 −0
Original line number Diff line number Diff line
@@ -125,6 +125,12 @@ int tls_construct_ctos_early_data(SSL *s, WPACKET *pkt, unsigned int context,
        return 0;
    }

    /*
     * We set this to rejected here. Later, if the server acknowledges the
     * extension, we set it to accepted.
     */
    s->ext.early_data = SSL_EARLY_DATA_REJECTED;

    return 1;
}

@@ -917,6 +923,28 @@ int tls_parse_stoc_early_data_info(SSL *s, PACKET *pkt, unsigned int context,
    return 1;
}

int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
                              X509 *x, size_t chainidx, int *al)
{
    if (PACKET_remaining(pkt) != 0) {
        *al = SSL_AD_DECODE_ERROR;
        return 0;
    }

    if (s->ext.early_data != SSL_EARLY_DATA_REJECTED) {
        /*
         * If we get here then we didn't send early data, so the server should
         * not be accepting it.
         */
        *al = SSL_AD_ILLEGAL_PARAMETER;
        return 0;
    }

    s->ext.early_data = SSL_EARLY_DATA_ACCEPTED;

    return 1;
}

#ifndef OPENSSL_NO_EC
int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
                                 X509 *x, size_t chainidx, int *al)
+2 −0
Original line number Diff line number Diff line
@@ -339,6 +339,8 @@ int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context,
                               X509 *x, size_t chainidx, int *al);
int tls_parse_stoc_early_data_info(SSL *s, PACKET *pkt, unsigned int context,
                              X509 *x, size_t chainidx, int *al);
int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
                              X509 *x, size_t chainidx, int *al);
#ifndef OPENSSL_NO_EC
int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
                                 X509 *x, size_t chainidx, int *al);