package tls
import (
)
func ( *cipherSuiteTLS13) ( []byte) []byte {
return tls13.ExpandLabel(.hash.New, , "traffic upd", nil, .hash.Size())
}
func ( *cipherSuiteTLS13) ( []byte) (, []byte) {
= tls13.ExpandLabel(.hash.New, , "key", nil, .keyLen)
= tls13.ExpandLabel(.hash.New, , "iv", nil, aeadNonceLength)
return
}
func ( *cipherSuiteTLS13) ( []byte, hash.Hash) []byte {
:= tls13.ExpandLabel(.hash.New, , "finished", nil, .hash.Size())
:= hmac.New(.hash.New, )
.Write(.Sum(nil))
return .Sum(nil)
}
func ( *cipherSuiteTLS13) ( *tls13.MasterSecret, hash.Hash) func(string, []byte, int) ([]byte, error) {
:= .ExporterMasterSecret()
return func( string, []byte, int) ([]byte, error) {
return .Exporter(, , ), nil
}
}
type keySharePrivateKeys struct {
curveID CurveID
ecdhe *ecdh.PrivateKey
mlkem *mlkem.DecapsulationKey768
}
const x25519PublicKeySize = 32
func ( io.Reader, CurveID) (*ecdh.PrivateKey, error) {
, := curveForCurveID()
if ! {
return nil, errors.New("tls: internal error: unsupported curve")
}
return .GenerateKey()
}
func ( CurveID) (ecdh.Curve, bool) {
switch {
case X25519:
return ecdh.X25519(), true
case CurveP256:
return ecdh.P256(), true
case CurveP384:
return ecdh.P384(), true
case CurveP521:
return ecdh.P521(), true
default:
return nil, false
}
}
func ( ecdh.Curve) (CurveID, bool) {
switch {
case ecdh.X25519():
return X25519, true
case ecdh.P256():
return CurveP256, true
case ecdh.P384():
return CurveP384, true
case ecdh.P521():
return CurveP521, true
default:
return 0, false
}
}