forked from quic-go/quic-go
add a handshake test for post-quantum-size ClientHellos (#3759)
Post-quantum ClientHellos typically are larger than 1 MTU and will therefore need to be split across multiple packets.
This commit is contained in:
@@ -125,6 +125,22 @@ var _ = Describe("Transport Parameters", func() {
|
||||
Expect(p.MaxDatagramFrameSize).To(Equal(params.MaxDatagramFrameSize))
|
||||
})
|
||||
|
||||
It("marshals additional transport parameters (used for testing large ClientHellos)", func() {
|
||||
origAdditionalTransportParametersClient := AdditionalTransportParametersClient
|
||||
defer func() {
|
||||
AdditionalTransportParametersClient = origAdditionalTransportParametersClient
|
||||
}()
|
||||
AdditionalTransportParametersClient = map[uint64][]byte{1337: []byte("foobar")}
|
||||
|
||||
result := quicvarint.Append([]byte{}, 1337)
|
||||
result = quicvarint.Append(result, 6)
|
||||
result = append(result, []byte("foobar")...)
|
||||
|
||||
params := &TransportParameters{}
|
||||
Expect(bytes.Contains(params.Marshal(protocol.PerspectiveClient), result)).To(BeTrue())
|
||||
Expect(bytes.Contains(params.Marshal(protocol.PerspectiveServer), result)).To(BeFalse())
|
||||
})
|
||||
|
||||
It("doesn't marshal a retry_source_connection_id, if no Retry was performed", func() {
|
||||
data := (&TransportParameters{
|
||||
StatelessResetToken: &protocol.StatelessResetToken{},
|
||||
|
||||
@@ -17,6 +17,12 @@ import (
|
||||
"github.com/quic-go/quic-go/quicvarint"
|
||||
)
|
||||
|
||||
// AdditionalTransportParametersClient are additional transport parameters that will be added
|
||||
// to the client's transport parameters.
|
||||
// This is not intended for production use, but _only_ to increase the size of the ClientHello beyond
|
||||
// the usual size of less than 1 MTU.
|
||||
var AdditionalTransportParametersClient map[uint64][]byte
|
||||
|
||||
const transportParameterMarshalingVersion = 1
|
||||
|
||||
func init() {
|
||||
@@ -402,6 +408,15 @@ func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte {
|
||||
if p.MaxDatagramFrameSize != protocol.InvalidByteCount {
|
||||
b = p.marshalVarintParam(b, maxDatagramFrameSizeParameterID, uint64(p.MaxDatagramFrameSize))
|
||||
}
|
||||
|
||||
if pers == protocol.PerspectiveClient && len(AdditionalTransportParametersClient) > 0 {
|
||||
for k, v := range AdditionalTransportParametersClient {
|
||||
b = quicvarint.Append(b, k)
|
||||
b = quicvarint.Append(b, uint64(len(v)))
|
||||
b = append(b, v...)
|
||||
}
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user