aboutsummaryrefslogtreecommitdiffstats
path: root/src/noise_helpers.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-02-02 16:40:14 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-02-02 16:40:14 +0100
commit029410b118f079d77fa448cf56a97b949faee126 (patch)
tree5c9ecf509601b3abffe36094b3b228b87b7d8b92 /src/noise_helpers.go
parentMerge branch 'timer-teardown' of git.zx2c4.com:wireguard-go into timer-teardown (diff)
downloadwireguard-go-029410b118f079d77fa448cf56a97b949faee126.tar.xz
wireguard-go-029410b118f079d77fa448cf56a97b949faee126.zip
Rework of entire locking system
Locking on the Device instance is now much more fined-grained, seperating out the fields into "resources" st. most common interactions only require a small number.
Diffstat (limited to '')
-rw-r--r--src/noise_helpers.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/noise_helpers.go b/src/noise_helpers.go
index 24302c0..1e2de5f 100644
--- a/src/noise_helpers.go
+++ b/src/noise_helpers.go
@@ -3,6 +3,7 @@ package main
import (
"crypto/hmac"
"crypto/rand"
+ "crypto/subtle"
"golang.org/x/crypto/blake2s"
"golang.org/x/crypto/curve25519"
"hash"
@@ -58,11 +59,11 @@ func KDF3(t0, t1, t2 *[blake2s.Size]byte, key, input []byte) {
}
func isZero(val []byte) bool {
- var acc byte
+ acc := 1
for _, b := range val {
- acc |= b
+ acc &= subtle.ConstantTimeByteEq(b, 0)
}
- return acc == 0
+ return acc == 1
}
func setZero(arr []byte) {