]>
Commit | Line | Data |
---|---|---|
99e1cc7b TM |
1 | /* |
2 | * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. | |
3 | * | |
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 | |
8 | */ | |
9 | ||
10 | #include <openssl/macros.h> | |
11 | #include <openssl/objects.h> | |
12 | #include "quic_local.h" | |
13 | ||
e44795bd | 14 | int ossl_quic_new(SSL *s) |
99e1cc7b TM |
15 | { |
16 | return s->method->ssl_clear(s); | |
17 | } | |
18 | ||
19 | void ossl_quic_free(SSL *s) | |
20 | { | |
21 | return; | |
22 | } | |
23 | ||
24 | int ossl_quic_clear(SSL *s) | |
25 | { | |
26 | return 1; | |
27 | } | |
28 | ||
e44795bd | 29 | int ossl_quic_accept(SSL *s) |
99e1cc7b | 30 | { |
08e49012 | 31 | s->statem.in_init = 0; |
99e1cc7b TM |
32 | return 1; |
33 | } | |
34 | ||
e44795bd | 35 | int ossl_quic_connect(SSL *s) |
99e1cc7b | 36 | { |
08e49012 | 37 | s->statem.in_init = 0; |
99e1cc7b TM |
38 | return 1; |
39 | } | |
40 | ||
e44795bd | 41 | int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes) |
99e1cc7b | 42 | { |
08e49012 | 43 | int ret; |
e44795bd TM |
44 | BIO *rbio = SSL_get_rbio(s); |
45 | ||
46 | if (rbio == NULL) | |
47 | return 0; | |
48 | ||
08e49012 TM |
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; | |
99e1cc7b TM |
54 | } |
55 | ||
e44795bd | 56 | int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes) |
99e1cc7b | 57 | { |
08e49012 | 58 | return -1; |
99e1cc7b TM |
59 | } |
60 | ||
e44795bd | 61 | int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written) |
99e1cc7b | 62 | { |
e44795bd | 63 | BIO *wbio = SSL_get_wbio(s); |
08e49012 | 64 | int ret; |
e44795bd TM |
65 | |
66 | if (wbio == NULL) | |
67 | return 0; | |
68 | ||
08e49012 TM |
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; | |
73 | return ret; | |
99e1cc7b TM |
74 | } |
75 | ||
e44795bd | 76 | int ossl_quic_shutdown(SSL *s) |
99e1cc7b TM |
77 | { |
78 | return 1; | |
79 | } | |
80 | ||
e44795bd | 81 | long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg) |
99e1cc7b | 82 | { |
08e49012 TM |
83 | switch(cmd) { |
84 | case SSL_CTRL_CHAIN: | |
85 | if (larg) | |
86 | return ssl_cert_set1_chain(s, NULL, (STACK_OF(X509) *)parg); | |
87 | else | |
88 | return ssl_cert_set0_chain(s, NULL, (STACK_OF(X509) *)parg); | |
89 | } | |
99e1cc7b TM |
90 | return 0; |
91 | } | |
92 | ||
08e49012 | 93 | long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) |
99e1cc7b | 94 | { |
08e49012 TM |
95 | switch(cmd) { |
96 | case SSL_CTRL_CHAIN: | |
97 | if (larg) | |
98 | return ssl_cert_set1_chain(NULL, ctx, (STACK_OF(X509) *)parg); | |
99 | else | |
100 | return ssl_cert_set0_chain(NULL, ctx, (STACK_OF(X509) *)parg); | |
101 | ||
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 */ | |
105 | return 1; | |
106 | } | |
99e1cc7b TM |
107 | return 0; |
108 | } | |
109 | ||
e44795bd | 110 | long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void)) |
99e1cc7b TM |
111 | { |
112 | return 0; | |
113 | } | |
114 | ||
08e49012 | 115 | long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void)) |
99e1cc7b TM |
116 | { |
117 | return 0; | |
118 | } | |
119 | ||
e44795bd | 120 | size_t ossl_quic_pending(const SSL *s) |
99e1cc7b TM |
121 | { |
122 | return 0; | |
123 | } | |
e44795bd TM |
124 | |
125 | long ossl_quic_default_timeout(void) | |
126 | { | |
127 | return 0; | |
128 | } | |
129 | ||
130 | int ossl_quic_num_ciphers(void) | |
131 | { | |
132 | return 1; | |
133 | } | |
134 | ||
135 | const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u) | |
136 | { | |
08e49012 TM |
137 | /* |
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. | |
142 | */ | |
143 | static const SSL_CIPHER ciph = { | |
144 | 1, | |
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, | |
148 | SSL_kECDHE, | |
149 | SSL_aRSA, | |
150 | SSL_AES256GCM, | |
151 | SSL_AEAD, | |
152 | TLS1_2_VERSION, TLS1_2_VERSION, | |
153 | DTLS1_2_VERSION, DTLS1_2_VERSION, | |
154 | SSL_HIGH | SSL_FIPS, | |
155 | SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384, | |
156 | 256, | |
157 | 256 | |
158 | }; | |
e44795bd TM |
159 | |
160 | return &ciph; | |
161 | } | |
162 | ||
163 | int ossl_quic_renegotiate_check(SSL *ssl, int initok) | |
164 | { | |
165 | return 1; | |
166 | } |