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

package sctp

import (
	
	
)

type paramStateCookie struct {
	paramHeader
	cookie []byte
}

func newRandomStateCookie() (*paramStateCookie, error) {
	 := make([]byte, 32)
	,  := rand.Read()
	// crypto/rand.Read returns n == len(b) if and only if err == nil.
	if  != nil {
		return nil, 
	}

	 := &paramStateCookie{
		cookie: ,
	}

	return , nil
}

func ( *paramStateCookie) () ([]byte, error) {
	.typ = stateCookie
	.raw = .cookie

	return .paramHeader.marshal()
}

func ( *paramStateCookie) ( []byte) (param, error) {
	 := .paramHeader.unmarshal()
	if  != nil {
		return nil, 
	}
	.cookie = .raw

	return , nil
}

// String makes paramStateCookie printable.
func ( *paramStateCookie) () string {
	return fmt.Sprintf("%s: %s", .paramHeader, .cookie)
}