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

// Package util contains small helpers used across the repo
package util import ( ) // BigEndianUint24 returns the value of a big endian uint24. func ( []byte) uint32 { if len() < 3 { return 0 } := make([]byte, 4) copy([1:], ) return binary.BigEndian.Uint32() } // PutBigEndianUint24 encodes a uint24 and places into out. func ( []byte, uint32) { := make([]byte, 4) binary.BigEndian.PutUint32(, ) copy(, [1:]) } // PutBigEndianUint48 encodes a uint64 and places into out. func ( []byte, uint64) { := make([]byte, 8) binary.BigEndian.PutUint64(, ) copy(, [2:]) } // Max returns the larger value. func (, int) int { if > { return } return } // AddUint48 appends a big-endian, 48-bit value to the byte string. // Remove if / when https://github.com/golang/crypto/pull/265 is merged // upstream. func ( *cryptobyte.Builder, uint64) { .AddBytes([]byte{byte( >> 40), byte( >> 32), byte( >> 24), byte( >> 16), byte( >> 8), byte()}) }