github.com/pion/dtls/v2@v2.2.12/util.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package dtls 5 6 func findMatchingSRTPProfile(a, b []SRTPProtectionProfile) (SRTPProtectionProfile, bool) { 7 for _, aProfile := range a { 8 for _, bProfile := range b { 9 if aProfile == bProfile { 10 return aProfile, true 11 } 12 } 13 } 14 return 0, false 15 } 16 17 func findMatchingCipherSuite(a, b []CipherSuite) (CipherSuite, bool) { 18 for _, aSuite := range a { 19 for _, bSuite := range b { 20 if aSuite.ID() == bSuite.ID() { 21 return aSuite, true 22 } 23 } 24 } 25 return nil, false 26 } 27 28 func splitBytes(bytes []byte, splitLen int) [][]byte { 29 splitBytes := make([][]byte, 0) 30 numBytes := len(bytes) 31 for i := 0; i < numBytes; i += splitLen { 32 j := i + splitLen 33 if j > numBytes { 34 j = numBytes 35 } 36 37 splitBytes = append(splitBytes, bytes[i:j]) 38 } 39 40 return splitBytes 41 }