mirror of https://github.com/openssl/openssl
QUIC Transport Parameters: Add CID encoder/decoder, make ID optional
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19703)
This commit is contained in:
parent
0f7b5cc9f3
commit
a64d82485d
|
@ -456,6 +456,14 @@ int ossl_quic_wire_encode_transport_param_int(WPACKET *pkt,
|
|||
uint64_t id,
|
||||
uint64_t value);
|
||||
|
||||
/*
|
||||
* Encodes a QUIC transport parameter TLV with a given ID into the WPACKET.
|
||||
* The payload is a QUIC connection ID.
|
||||
*/
|
||||
int ossl_quic_wire_encode_transport_param_cid(WPACKET *wpkt,
|
||||
uint64_t id,
|
||||
const QUIC_CONN_ID *cid);
|
||||
|
||||
/*
|
||||
* QUIC Wire Format Decoding
|
||||
* =========================
|
||||
|
@ -715,8 +723,8 @@ int ossl_quic_wire_peek_transport_param(PACKET *pkt, uint64_t *id);
|
|||
* returned on success. This points inside the PACKET's buffer and is therefore
|
||||
* valid as long as the PACKET's buffer is valid.
|
||||
*
|
||||
* The transport parameter ID is written to *id and the length of the payload
|
||||
* in bytes is written to *len.
|
||||
* The transport parameter ID is written to *id (if non-NULL) and the length of
|
||||
* the payload in bytes is written to *len.
|
||||
*
|
||||
* Returns NULL on failure.
|
||||
*/
|
||||
|
@ -727,11 +735,21 @@ const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt,
|
|||
/*
|
||||
* Decodes a QUIC transport parameter TLV containing a variable-length integer.
|
||||
*
|
||||
* The transport parameter ID is written to *id and the value is written to
|
||||
* *value.
|
||||
* The transport parameter ID is written to *id (if non-NULL) and the value is
|
||||
* written to *value.
|
||||
*/
|
||||
int ossl_quic_wire_decode_transport_param_int(PACKET *pkt,
|
||||
uint64_t *id,
|
||||
uint64_t *value);
|
||||
|
||||
/*
|
||||
* Decodes a QUIC transport parameter TLV containing a connection ID.
|
||||
*
|
||||
* The transport parameter ID is written to *id (if non-NULL) and the value is
|
||||
* written to *value.
|
||||
*/
|
||||
int ossl_quic_wire_decode_transport_param_cid(PACKET *pkt,
|
||||
uint64_t *id,
|
||||
QUIC_CONN_ID *cid);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -408,6 +408,21 @@ int ossl_quic_wire_encode_transport_param_int(WPACKET *pkt,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int ossl_quic_wire_encode_transport_param_cid(WPACKET *wpkt,
|
||||
uint64_t id,
|
||||
const QUIC_CONN_ID *cid)
|
||||
{
|
||||
if (cid->id_len > QUIC_MAX_CONN_ID_LEN)
|
||||
return 0;
|
||||
|
||||
if (ossl_quic_wire_encode_transport_param_bytes(wpkt, id,
|
||||
cid->id,
|
||||
cid->id_len) == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* QUIC Wire Format Decoding
|
||||
* =========================
|
||||
|
@ -847,8 +862,9 @@ const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt,
|
|||
{
|
||||
uint64_t len_;
|
||||
const unsigned char *b = NULL;
|
||||
uint64_t id_;
|
||||
|
||||
if (!PACKET_get_quic_vlint(pkt, id)
|
||||
if (!PACKET_get_quic_vlint(pkt, &id_)
|
||||
|| !PACKET_get_quic_vlint(pkt, &len_))
|
||||
return NULL;
|
||||
|
||||
|
@ -857,6 +873,8 @@ const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt,
|
|||
return NULL;
|
||||
|
||||
*len = (size_t)len_;
|
||||
if (id != NULL)
|
||||
*id = id_;
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -876,3 +894,19 @@ int ossl_quic_wire_decode_transport_param_int(PACKET *pkt,
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ossl_quic_wire_decode_transport_param_cid(PACKET *pkt,
|
||||
uint64_t *id,
|
||||
QUIC_CONN_ID *cid)
|
||||
{
|
||||
const unsigned char *body;
|
||||
size_t len = 0;
|
||||
|
||||
body = ossl_quic_wire_decode_transport_param_bytes(pkt, id, &len);
|
||||
if (body == NULL || len > QUIC_MAX_CONN_ID_LEN)
|
||||
return 0;
|
||||
|
||||
cid->id_len = (unsigned char)len;
|
||||
memcpy(cid->id, body, cid->id_len);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue