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.
This commit is contained in:
Mathias Hall-Andersen 2018-02-02 16:40:14 +01:00
parent 1e42b14022
commit 029410b118
10 changed files with 386 additions and 239 deletions

View file

@ -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) {