summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/stun/checks.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-11-29 01:46:27 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-11-29 18:14:16 +0100
commit18f52af5be3a9a0c73811706108f790d65ee9c67 (patch)
treee13cbacb47d56919caa9c44a2b45dec1497a7860 /vendor/github.com/pion/stun/checks.go
parentebcef0d57b6ecb5a40c6579f6be07182dd3033ba (diff)
[pkg] update vendor
Diffstat (limited to 'vendor/github.com/pion/stun/checks.go')
-rw-r--r--vendor/github.com/pion/stun/checks.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/pion/stun/checks.go b/vendor/github.com/pion/stun/checks.go
new file mode 100644
index 0000000..a760997
--- /dev/null
+++ b/vendor/github.com/pion/stun/checks.go
@@ -0,0 +1,45 @@
+// +build !debug
+
+package stun
+
+import "github.com/pion/stun/internal/hmac"
+
+// CheckSize returns ErrAttrSizeInvalid if got is not equal to expected.
+func CheckSize(_ AttrType, got, expected int) error {
+ if got == expected {
+ return nil
+ }
+ return ErrAttributeSizeInvalid
+}
+
+func checkHMAC(got, expected []byte) error {
+ if hmac.Equal(got, expected) {
+ return nil
+ }
+ return ErrIntegrityMismatch
+}
+
+func checkFingerprint(got, expected uint32) error {
+ if got == expected {
+ return nil
+ }
+ return ErrFingerprintMismatch
+}
+
+// IsAttrSizeInvalid returns true if error means that attribute size is invalid.
+func IsAttrSizeInvalid(err error) bool {
+ return err == ErrAttributeSizeInvalid
+}
+
+// CheckOverflow returns ErrAttributeSizeOverflow if got is bigger that max.
+func CheckOverflow(_ AttrType, got, max int) error {
+ if got <= max {
+ return nil
+ }
+ return ErrAttributeSizeOverflow
+}
+
+// IsAttrSizeOverflow returns true if error means that attribute size is too big.
+func IsAttrSizeOverflow(err error) bool {
+ return err == ErrAttributeSizeOverflow
+}