2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/macros.h>
11 #include <openssl/objects.h>
12 #include "quic_local.h"
14 int ossl_quic_new(SSL *s)
16 return s->method->ssl_clear(s);
19 void ossl_quic_free(SSL *s)
24 int ossl_quic_clear(SSL *s)
29 int ossl_quic_accept(SSL *s)
31 s->statem.in_init = 0;
35 int ossl_quic_connect(SSL *s)
37 s->statem.in_init = 0;
41 int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes)
44 BIO *rbio = SSL_get_rbio(s);
49 s->rwstate = SSL_READING;
50 ret = BIO_read_ex(rbio, buf, len, readbytes);
51 if (ret > 0 || !BIO_should_retry(rbio))
52 s->rwstate = SSL_NOTHING;
53 return ret <= 0 ? -1 : ret;
56 int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes)
61 int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written)
63 BIO *wbio = SSL_get_wbio(s);
69 s->rwstate = SSL_WRITING;
70 ret = BIO_write_ex(wbio, buf, len, written);
71 if (ret > 0 || !BIO_should_retry(wbio))
72 s->rwstate = SSL_NOTHING;
76 int ossl_quic_shutdown(SSL *s)
81 long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg)
86 return ssl_cert_set1_chain(s, NULL, (STACK_OF(X509) *)parg);
88 return ssl_cert_set0_chain(s, NULL, (STACK_OF(X509) *)parg);
93 long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
98 return ssl_cert_set1_chain(NULL, ctx, (STACK_OF(X509) *)parg);
100 return ssl_cert_set0_chain(NULL, ctx, (STACK_OF(X509) *)parg);
102 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
103 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
104 /* TODO(QUIC): these will have to be implemented properly */
110 long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void))
115 long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void))
120 size_t ossl_quic_pending(const SSL *s)
125 long ossl_quic_default_timeout(void)
130 int ossl_quic_num_ciphers(void)
135 const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u)
138 * TODO(QUIC): This is needed so the SSL_CTX_set_cipher_list("DEFAULT");
139 * produces at least one valid TLS-1.2 cipher.
140 * Later we should allow that there are none with QUIC protocol as
141 * SSL_CTX_set_cipher_list should still allow setting a SECLEVEL.
143 static const SSL_CIPHER ciph = {
145 TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
146 TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
147 TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
152 TLS1_2_VERSION, TLS1_2_VERSION,
153 DTLS1_2_VERSION, DTLS1_2_VERSION,
155 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
163 int ossl_quic_renegotiate_check(SSL *ssl, int initok)