diff --git a/crypto/crypto.go b/crypto/crypto.go index 035d304a8..258348e96 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -48,7 +48,6 @@ type SigningKey struct { K [16]byte `json:"k"` // for AES128 R [16]byte `json:"r"` // for Poly1305 } -type iv [ivSize]byte // mask for key, (cf. http://cr.yp.to/mac/poly1305-20050329.pdf) var poly1305KeyMask = [16]byte{ @@ -160,12 +159,13 @@ func NewKey() (k *Key) { return k } -func newIV() (iv iv) { - n, err := rand.Read(iv[:]) +func newIV() []byte { + iv := make([]byte, ivSize) + n, err := rand.Read(iv) if n != ivSize || err != nil { panic("unable to read enough random bytes for iv") } - return + return iv } type jsonMACKey struct { diff --git a/crypto/writer.go b/crypto/writer.go index 5ac51ee8d..e56e542aa 100644 --- a/crypto/writer.go +++ b/crypto/writer.go @@ -10,7 +10,7 @@ import ( ) type encryptWriter struct { - iv iv + iv []byte wroteIV bool data *bytes.Buffer key *Key