Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pkg/crypto/ciphersuite/ciphersuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ func examinePadding(payload []byte) (toRemove int, good byte) {
good = byte(int32(^t) >> 31) //nolint:gosec //G115

// The maximum possible padding length plus the actual length field
toCheck := 256
// The length of the padded data is public, so we can use an if here
if toCheck > len(payload) {
toCheck = len(payload)
}
toCheck := min(
// The length of the padded data is public, so we can use an if here
256, len(payload))

for i := 0; i < toCheck; i++ {
t := uint(paddingLen) - uint(i) //nolint:gosec //G115
Expand Down
2 changes: 1 addition & 1 deletion pkg/crypto/fingerprint/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Fingerprint(cert *x509.Certificate, algo crypto.Hash) (string, error) {
// https://golang.org/pkg/hash/#Hash
i += n
}
digest := []byte(fmt.Sprintf("%x", h.Sum(nil)))
digest := fmt.Appendf(nil, "%x", h.Sum(nil))

digestlen := len(digest)
if digestlen == 0 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/protocol/extension/alpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package extension

import (
"slices"

"golang.org/x/crypto/cryptobyte"
)

Expand Down Expand Up @@ -72,10 +74,8 @@ func ALPNProtocolSelection(supportedProtocols, peerSupportedProtocols []string)
return "", nil
}
for _, s := range supportedProtocols {
for _, c := range peerSupportedProtocols {
if s == c {
return s, nil
}
if slices.Contains(peerSupportedProtocols, s) {
return s, nil
}
}

Expand Down
13 changes: 5 additions & 8 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package dtls

import "slices"

func findMatchingSRTPProfile(a, b []SRTPProtectionProfile) (SRTPProtectionProfile, bool) {
for _, aProfile := range a {
for _, bProfile := range b {
if aProfile == bProfile {
return aProfile, true
}
if slices.Contains(b, aProfile) {
return aProfile, true
}
}

Expand All @@ -31,10 +31,7 @@ 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
}
j := min(i+splitLen, numBytes)

splitBytes = append(splitBytes, bytes[i:j])
}
Expand Down
Loading