mirror of
https://github.com/golang/go
synced 2024-11-26 20:21:25 -07:00
crypto/tls: randomly generate ticket_age_add
As required by RFC 8446, section 4.6.1, ticket_age_add now holds a random 32-bit value. Before this change, this value was always set to 0. This change also documents the reasoning for always setting ticket_nonce to 0. The value ticket_nonce must be unique per connection, but we only ever send one ticket per connection. Fixes #52814 Fixes CVE-2022-30629 Change-Id: I6c2fc6ca0376b7b968abd59d6d3d3854c1ab68bb Reviewed-on: https://go-review.googlesource.com/c/go/+/405994 Reviewed-by: Tatiana Bradley <tatiana@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Run-TryBot: Tatiana Bradley <tatiana@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
1c77137d4f
commit
fe4de36198
@ -10,6 +10,7 @@ import (
|
|||||||
"crypto"
|
"crypto"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
@ -745,6 +746,19 @@ func (hs *serverHandshakeStateTLS13) sendSessionTickets() error {
|
|||||||
}
|
}
|
||||||
m.lifetime = uint32(maxSessionTicketLifetime / time.Second)
|
m.lifetime = uint32(maxSessionTicketLifetime / time.Second)
|
||||||
|
|
||||||
|
// ticket_age_add is a random 32-bit value. See RFC 8446, section 4.6.1
|
||||||
|
// The value is not stored anywhere; we never need to check the ticket age
|
||||||
|
// because 0-RTT is not supported.
|
||||||
|
ageAdd := make([]byte, 4)
|
||||||
|
_, err = hs.c.config.rand().Read(ageAdd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.ageAdd = binary.LittleEndian.Uint32(ageAdd)
|
||||||
|
|
||||||
|
// ticket_nonce, which must be unique per connection, is always left at
|
||||||
|
// zero because we only ever send one ticket per connection.
|
||||||
|
|
||||||
if _, err := c.writeRecord(recordTypeHandshake, m.marshal()); err != nil {
|
if _, err := c.writeRecord(recordTypeHandshake, m.marshal()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user