diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-02-02 16:40:14 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-02-02 16:40:14 +0100 |
commit | 029410b118f079d77fa448cf56a97b949faee126 (patch) | |
tree | 5c9ecf509601b3abffe36094b3b228b87b7d8b92 /src/noise_helpers.go | |
parent | 1e42b1402261d15b87b1b5871f7bc51342b46e34 (diff) |
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 'src/noise_helpers.go')
-rw-r--r-- | src/noise_helpers.go | 7 |
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) { |