Skip to content

Commit 01e6daf

Browse files
committed
Send and receive Transport Parameters with BoringSSL API
1 parent da6062a commit 01e6daf

3 files changed

Lines changed: 31 additions & 14 deletions

File tree

iocore/net/quic/QUICTLS.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ QUICTLS::remote_transport_parameters()
9999
return this->_remote_transport_parameters;
100100
}
101101

102-
void
103-
QUICTLS::set_local_transport_parameters(std::shared_ptr<const QUICTransportParameters> tp)
104-
{
105-
this->_local_transport_parameters = tp;
106-
}
107-
108102
void
109103
QUICTLS::set_remote_transport_parameters(std::shared_ptr<const QUICTransportParameters> tp)
110104
{

iocore/net/quic/QUICTLS_boringssl.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ set_encryption_secrets(SSL *ssl, enum ssl_encryption_level_t level, const uint8_
6363
qtls->update_key_materials_for_read(ats_level, read_secret, secret_len);
6464
qtls->update_key_materials_for_write(ats_level, write_secret, secret_len);
6565

66+
if (ats_level == QUICEncryptionLevel::ONE_RTT) {
67+
// FIXME Where should this be placed?
68+
const uint8_t *tp_buf;
69+
size_t tp_buf_len;
70+
SSL_get_peer_quic_transport_params(ssl, &tp_buf, &tp_buf_len);
71+
if (SSL_is_server(ssl)) {
72+
qtls->set_remote_transport_parameters(std::make_shared<QUICTransportParametersInClientHello>(tp_buf, tp_buf_len));
73+
} else {
74+
qtls->set_remote_transport_parameters(std::make_shared<QUICTransportParametersInEncryptedExtensions>(tp_buf, tp_buf_len));
75+
}
76+
}
77+
6678
return 1;
6779
}
6880

@@ -151,9 +163,21 @@ QUICTLS::QUICTLS(QUICPacketProtectionKeyInfo &pp_key_info, SSL_CTX *ssl_ctx, Net
151163
}
152164
}
153165

166+
void
167+
QUICTLS::set_local_transport_parameters(std::shared_ptr<const QUICTransportParameters> tp)
168+
{
169+
this->_local_transport_parameters = tp;
170+
171+
uint8_t buf[UINT16_MAX];
172+
uint16_t len;
173+
this->_local_transport_parameters->store(buf, &len);
174+
SSL_set_quic_transport_params(this->_ssl, buf, len);
175+
}
176+
154177
int
155178
QUICTLS::_process_post_handshake_messages(QUICHandshakeMsgs *out, const QUICHandshakeMsgs *in)
156179
{
180+
this->_pass_quic_data_to_ssl_impl(*in);
157181
return SSL_process_quic_post_handshake(this->_ssl);
158182
}
159183

iocore/net/quic/QUICTLS_openssl.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ QUICTLS::get_encryption_level(int msg_type)
264264
}
265265
}
266266

267+
void
268+
QUICTLS::set_local_transport_parameters(std::shared_ptr<const QUICTransportParameters> tp)
269+
{
270+
this->_local_transport_parameters = tp;
271+
}
272+
267273
int
268274
QUICTLS::_process_post_handshake_messages(QUICHandshakeMsgs *out, const QUICHandshakeMsgs *in)
269275
{
@@ -276,14 +282,7 @@ QUICTLS::_process_post_handshake_messages(QUICHandshakeMsgs *out, const QUICHand
276282
SSL_set_msg_callback(this->_ssl, QUICTLS::_msg_cb);
277283
SSL_set_msg_callback_arg(this->_ssl, out);
278284

279-
// TODO: set BIO_METHOD which read from QUICHandshakeMsgs directly
280-
BIO *rbio = BIO_new(BIO_s_mem());
281-
// TODO: set dummy BIO_METHOD which do nothing
282-
BIO *wbio = BIO_new(BIO_s_mem());
283-
if (in != nullptr && in->offsets[4] != 0) {
284-
BIO_write(rbio, in->buf, in->offsets[4]);
285-
}
286-
SSL_set_bio(this->_ssl, rbio, wbio);
285+
this->_pass_quic_data_to_ssl_impl(*in);
287286

288287
uint8_t data[2048];
289288
size_t l = 0;

0 commit comments

Comments
 (0)