// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package handshake

import (
	
	
	
)

// Consts for Random in Handshake.
const (
	RandomBytesLength = 28
	RandomLength      = RandomBytesLength + 4
)

// Random value that is used in ClientHello and ServerHello
//
// https://tools.ietf.org/html/rfc4346#section-7.4.1.2
type Random struct {
	GMTUnixTime time.Time
	RandomBytes [RandomBytesLength]byte
}

// MarshalFixed encodes the Handshake.
func ( *Random) () [RandomLength]byte {
	var  [RandomLength]byte

	binary.BigEndian.PutUint32([0:], uint32(.GMTUnixTime.Unix())) //nolint:gosec // G115
	copy([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 
}