From 6de6b14a09b3695fe797e5fd59a04b3c3834641a Mon Sep 17 00:00:00 2001 From: Joseph Richey Date: Thu, 19 Oct 2017 11:34:07 -0700 Subject: crypto: Remove crypto.randReader As #19274 is now fixed in Go 1.9, there is no longer any reason to have a duplicate implementation to the standard library. We can now move safely to crypto/rand. --- crypto/crypto.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crypto/crypto.go') diff --git a/crypto/crypto.go b/crypto/crypto.go index a85d345..dbd13ff 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -42,6 +42,7 @@ import ( "crypto/aes" "crypto/cipher" "crypto/hmac" + "crypto/rand" "crypto/sha256" "crypto/sha512" "encoding/hex" @@ -135,11 +136,13 @@ func Wrap(wrappingKey, secretKey *Key) (*metadata.WrappedKeyData, error) { return nil, err } - data := &metadata.WrappedKeyData{EncryptedKey: make([]byte, secretKey.Len())} + data := &metadata.WrappedKeyData{ + EncryptedKey: make([]byte, secretKey.Len()), + IV: make([]byte, metadata.IVLen), + } // Get random IV - var err error - if data.IV, err = NewRandomBuffer(metadata.IVLen); err != nil { + if _, err := rand.Read(data.IV); err != nil { return nil, err } -- cgit v1.2.3