diff options
| author | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 11:34:07 -0700 |
|---|---|---|
| committer | Joe Richey joerichey@google.com <joerichey@google.com> | 2017-10-20 11:24:14 -0700 |
| commit | 6de6b14a09b3695fe797e5fd59a04b3c3834641a (patch) | |
| tree | 49a6c617f0e470892099e0f38f4dd3ab9f920964 /crypto/crypto.go | |
| parent | 3269bc539e52cdced8c03a628e4fdf22942ece4b (diff) | |
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.
Diffstat (limited to 'crypto/crypto.go')
| -rw-r--r-- | crypto/crypto.go | 9 |
1 files changed, 6 insertions, 3 deletions
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 } |