Source File
random.go
Belonging Package
github.com/pion/dtls/v3/pkg/protocol/handshake
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage handshakeimport ()// Consts for Random in Handshake.const (RandomBytesLength = 28RandomLength = RandomBytesLength + 4)// Random value that is used in ClientHello and ServerHello//// https://tools.ietf.org/html/rfc4346#section-7.4.1.2type Random struct {GMTUnixTime time.TimeRandomBytes [RandomBytesLength]byte}// MarshalFixed encodes the Handshake.func ( *Random) () [RandomLength]byte {var [RandomLength]bytebinary.BigEndian.PutUint32([0:], uint32(.GMTUnixTime.Unix())) //nolint:gosec // G115copy([4:], .RandomBytes[:])return}// UnmarshalFixed populates the message from encoded data.func ( *Random) ( [RandomLength]byte) {.GMTUnixTime = time.Unix(int64(binary.BigEndian.Uint32([0:])), 0)copy(.RandomBytes[:], [4:])}// Populate fills the handshakeRandom with random values// may be called multiple times.func ( *Random) () error {.GMTUnixTime = time.Now():= make([]byte, RandomBytesLength), := rand.Read()copy(.RandomBytes[:], )return}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |