/* All about an SSL session ticket */
struct Curl_ssl_session {
- const void *sdata; /* session ticket data, plain bytes */
+ uint8_t *sdata; /* session ticket data, plain bytes */
size_t sdata_len; /* number of bytes in sdata */
curl_off_t valid_until; /* seconds since EPOCH until ticket expires */
int ietf_tls_id; /* TLS protocol identifier negotiated */
char *alpn; /* APLN TLS negotiated protocol string */
size_t earlydata_max; /* max 0-RTT data supported by peer */
- const unsigned char *quic_tp; /* Optional QUIC transport param bytes */
+ uint8_t *quic_tp; /* Optional QUIC transport param bytes */
size_t quic_tp_len; /* number of bytes in quic_tp */
struct Curl_llist_node list; /* internal storage handling */
BIT(sectrust_verified); /* session comes from sectrust verified TLS */
uint16_t val16;
uint32_t val32;
uint64_t val64;
+ size_t dlen;
CURLcode result;
DEBUGASSERT(buf);
switch(val8) {
case CURL_SPACK_ALPN:
+ curlx_free(s->alpn);
result = spack_decstr16(&s->alpn, &buf, end);
if(result)
goto out;
s->ietf_tls_id = val16;
break;
case CURL_SPACK_QUICTP: {
- result = spack_decdata16(&pval8, &s->quic_tp_len, &buf, end);
+ result = spack_decdata16(&pval8, &dlen, &buf, end);
if(result)
goto out;
+ curlx_free(s->quic_tp);
s->quic_tp = pval8;
+ s->quic_tp_len = dlen;
break;
}
case CURL_SPACK_TICKET: {
- result = spack_decdata16(&pval8, &s->sdata_len, &buf, end);
+ result = spack_decdata16(&pval8, &dlen, &buf, end);
if(result)
goto out;
+ curlx_free(s->sdata);
s->sdata = pval8;
+ s->sdata_len = dlen;
break;
}
case CURL_SPACK_VALID_UNTIL:
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "first.h"
+
+#if defined(USE_SSL) && defined(USE_SSLS_EXPORT)
+
+#define T1678_IMPORT_COUNT 64
+#define T1678_FIRST_TICKET_SIZE 4096
+#define T1678_FIRST_QUICTP_SIZE 127
+#define T1678_FIRST_ALPN_SIZE 10
+
+static uint8_t *t1678_make_packet(size_t *packet_len)
+{
+ const size_t t1678_total =
+ 1 + /* format version */
+ 1 + 2 + T1678_FIRST_TICKET_SIZE + /* first ticket */
+ 1 + 2 + T1678_FIRST_QUICTP_SIZE + /* first QUIC traffic params */
+ 1 + 2 + T1678_FIRST_ALPN_SIZE + /* first ALPN params */
+ 1 + 2 + 1 + /* second ticket */
+ 1 + 2 + 1 + /* second ALPN */
+ 1 + 2 + 1; /* second QUIC traffic params */
+
+ uint8_t *packet = curlx_malloc(t1678_total);
+ uint8_t *p;
+
+ if(!packet)
+ return NULL;
+
+ p = packet;
+
+ /* CURL_SPACK_VERSION */
+ *p++ = 0x01;
+
+ /* First CURL_SPACK_TICKET */
+ *p++ = 0x04;
+ *p++ = (uint8_t)(T1678_FIRST_TICKET_SIZE >> 8);
+ *p++ = (uint8_t)(T1678_FIRST_TICKET_SIZE & 0x0ff);
+ memset(p, 'A', T1678_FIRST_TICKET_SIZE);
+ p += T1678_FIRST_TICKET_SIZE;
+
+ /* First CURL_SPACK_QUICTP */
+ *p++ = 0x07;
+ *p++ = (uint8_t)(T1678_FIRST_QUICTP_SIZE >> 8);
+ *p++ = (uint8_t)(T1678_FIRST_QUICTP_SIZE & 0x0ff);
+ memset(p, 'Q', T1678_FIRST_QUICTP_SIZE);
+ p += T1678_FIRST_QUICTP_SIZE;
+
+ /* First CURL_SPACK_ALPN */
+ *p++ = 0x05;
+ *p++ = (uint8_t)(T1678_FIRST_ALPN_SIZE >> 8);
+ *p++ = (uint8_t)(T1678_FIRST_ALPN_SIZE & 0x0ff);
+ memset(p, 'a', T1678_FIRST_ALPN_SIZE);
+ p += T1678_FIRST_ALPN_SIZE;
+
+ /* Second CURL_SPACK_TICKET: one byte. */
+ *p++ = 0x04;
+ *p++ = 0x00;
+ *p++ = 0x01;
+ *p++ = 'B';
+
+ /* Second CURL_SPACK_ALPN: one byte. */
+ *p++ = 0x05;
+ *p++ = 0x00;
+ *p++ = 0x01;
+ *p++ = 'b';
+
+ /* Second CURL_SPACK_QUICTP: one byte. */
+ *p++ = 0x07;
+ *p++ = 0x00;
+ *p++ = 0x01;
+ *p++ = 'R';
+
+ *packet_len = t1678_total;
+ return packet;
+}
+
+static CURLcode test_lib1678(const char *URL)
+{
+ uint8_t *packet;
+ size_t packet_len;
+ CURLSH *share = NULL;
+ CURL *easy = NULL;
+ CURLSHcode shrc;
+ CURLcode result = CURLE_FAILED_INIT;
+ int i;
+
+ (void)URL;
+ packet = t1678_make_packet(&packet_len);
+ if(!packet)
+ goto test_cleanup;
+
+ result = curl_global_init(CURL_GLOBAL_DEFAULT);
+ if(result != CURLE_OK)
+ goto test_cleanup;
+
+ share = curl_share_init();
+ easy = curl_easy_init();
+
+ if(!share || !easy)
+ goto test_cleanup;
+
+ shrc = curl_share_setopt(share,
+ CURLSHOPT_SHARE,
+ CURL_LOCK_DATA_SSL_SESSION);
+ if(shrc != CURLSHE_OK)
+ goto test_cleanup;
+
+ result = curl_easy_setopt(easy, CURLOPT_SHARE, share);
+ if(result)
+ goto test_cleanup;
+
+ for(i = 0; i < T1678_IMPORT_COUNT; ++i) {
+ result = curl_easy_ssls_import(easy,
+ "example.test:443",
+ NULL,
+ 0,
+ packet,
+ packet_len);
+ if(result) {
+ curl_mfprintf(stderr,
+ "import %d failed: %d (%s)\n",
+ i, (int)result,
+ curl_easy_strerror(result));
+ break;
+ }
+ }
+
+test_cleanup:
+ curlx_free(packet);
+ curl_easy_cleanup(easy);
+ curl_share_cleanup(share);
+ curl_global_cleanup();
+
+ return result;
+}
+#else
+static CURLcode test_lib1678(const char *URL)
+{
+ (void)URL;
+ return CURLE_OK;
+}
+#endif /* USE_SSL && USE_SSLS_EXPORT */