From 63e79539e97e3b3117fb44a82e2ddfe419f097ec Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 15 Apr 2015 20:51:52 +0200 Subject: [PATCH] crypto: Remove type iv --- crypto/crypto.go | 8 ++++---- crypto/writer.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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