Skip to content

Commit 36aa143

Browse files
committed
fix tests
1 parent f6b5b9f commit 36aa143

5 files changed

Lines changed: 12 additions & 4 deletions

File tree

conn.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,11 @@ func (c *Conn) fragmentHandshake(dtlsHandshake *handshake.Handshake) ([][]byte,
775775
}
776776

777777
contentFragments := splitBytes(content, c.maximumTransmissionUnit)
778+
if len(contentFragments) == 0 {
779+
contentFragments = [][]byte{
780+
{},
781+
}
782+
}
778783

779784
offset := 0
780785
fragmentedHandshakes := make([][]byte, 0, len(contentFragments))

pkg/protocol/handshake/message_certificate_13.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,19 @@ func (m *MessageCertificate13) Size() int {
8585

8686
func (m *MessageCertificate13) cacheMarshalExtensions() error {
8787
if m.marchalledExtensions == nil && m.marchalledExtensionsErr == nil {
88-
for _, entry := range m.CertificateList {
88+
m.marchalledExtensions = make([][]byte, len(m.CertificateList))
89+
for i, entry := range m.CertificateList {
8990
for _, ext := range entry.Extensions {
9091
var c []byte
9192
c, m.marchalledExtensionsErr = ext.Marshal()
9293
if m.marchalledExtensionsErr != nil {
9394
return m.marchalledExtensionsErr
9495
}
95-
m.marchalledExtensions = append(m.marchalledExtensions, c)
96+
m.marchalledExtensions[i] = append(m.marchalledExtensions[i], c...)
9697
}
9798
}
9899
}
100+
99101
return m.marchalledExtensionsErr
100102
}
101103

pkg/protocol/handshake/message_client_hello.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (m *MessageClientHello) cacheMarshalExtensions() error {
4242
if m.marchalledExtensions == nil && m.marchalledExtensionsErr == nil {
4343
m.marchalledExtensions, m.marchalledExtensionsErr = extension.Marshal(m.Extensions)
4444
}
45+
4546
return m.marchalledExtensionsErr
4647
}
4748

pkg/protocol/handshake/message_client_key_exchange.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func (m *MessageClientKeyExchange) Size() int {
5252
total := 0
5353
if m.IdentityHint != nil {
5454
total += 2
55+
total += len(m.IdentityHint)
5556
}
5657

5758
if m.PublicKey != nil {

pkg/protocol/handshake/message_server_hello.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ func (m *MessageServerHello) cacheMarshalExtensions() error {
4040
if m.marchalledExtensions == nil && m.marchalledExtensionsErr == nil {
4141
m.marchalledExtensions, m.marchalledExtensionsErr = extension.Marshal(m.Extensions)
4242
}
43+
4344
return m.marchalledExtensionsErr
4445
}
4546

4647
// Size returns the size required by MarshalInto.
4748
func (m *MessageServerHello) Size() int {
48-
4949
err := m.cacheMarshalExtensions()
5050
if err != nil {
5151
return 0
@@ -60,7 +60,6 @@ func (m *MessageServerHello) Size() int {
6060

6161
// MarshalInto encodes the Handshake into a pre-allocated buffer.
6262
func (m *MessageServerHello) MarshalInto(out []byte) error {
63-
6463
err := m.cacheMarshalExtensions()
6564
if err != nil {
6665
return err

0 commit comments

Comments
 (0)