internal/cryptutil: fixed panic on nil pubkey

This commit is contained in:
Bobby DeSimone 2019-07-15 19:36:02 -07:00
parent 22fb3a0f7e
commit c5bcc9bbef
No known key found for this signature in database
GPG key ID: AEE4CF12FE86D07E
5 changed files with 81 additions and 13 deletions

View file

@ -70,11 +70,7 @@ func NewCipher(secret []byte) (*XChaCha20Cipher, error) {
// GenerateNonce generates a random nonce.
// Panics if source of randomness fails.
func (c *XChaCha20Cipher) GenerateNonce() []byte {
nonce := make([]byte, c.aead.NonceSize())
if _, err := rand.Read(nonce); err != nil {
panic(err)
}
return nonce
return randomBytes(c.aead.NonceSize())
}
// Encrypt a value using XChaCha20-Poly1305