status-go/vendor/github.com/pion/dtls/v2/util.go

42 lines
863 B
Go
Raw Normal View History

2024-05-15 23:15:00 +00:00
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
2022-03-10 09:44:48 +00:00
package dtls
func findMatchingSRTPProfile(a, b []SRTPProtectionProfile) (SRTPProtectionProfile, bool) {
for _, aProfile := range a {
for _, bProfile := range b {
if aProfile == bProfile {
return aProfile, true
}
}
}
return 0, false
}
2024-05-15 23:15:00 +00:00
func findMatchingCipherSuite(a, b []CipherSuite) (CipherSuite, bool) {
2022-03-10 09:44:48 +00:00
for _, aSuite := range a {
for _, bSuite := range b {
if aSuite.ID() == bSuite.ID() {
return aSuite, true
}
}
}
return nil, false
}
func splitBytes(bytes []byte, splitLen int) [][]byte {
splitBytes := make([][]byte, 0)
numBytes := len(bytes)
for i := 0; i < numBytes; i += splitLen {
j := i + splitLen
if j > numBytes {
j = numBytes
}
splitBytes = append(splitBytes, bytes[i:j])
}
return splitBytes
}