From 0a64615f1e17a8c36cca5302da24dfc804ffbe2b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 28 Jul 2020 11:47:05 +0200 Subject: [PATCH] signer/storage: fix a badly ordered error check (#21379) --- cmd/clef/docs/setup.md | 2 +- signer/storage/aes_gcm_storage.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/clef/docs/setup.md b/cmd/clef/docs/setup.md index a25f87ce64e4..cbdd8808d304 100644 --- a/cmd/clef/docs/setup.md +++ b/cmd/clef/docs/setup.md @@ -94,7 +94,7 @@ with minimal requirements. On the `client` qube, we need to create a listener which will receive the request from the Dapp, and proxy it. -[qubes-client.py](qubes/client/qubes-client.py): +[qubes-client.py](qubes/qubes-client.py): ```python diff --git a/signer/storage/aes_gcm_storage.go b/signer/storage/aes_gcm_storage.go index 8c5e147ac6d2..1dad34a3ebc8 100644 --- a/signer/storage/aes_gcm_storage.go +++ b/signer/storage/aes_gcm_storage.go @@ -151,11 +151,11 @@ func encrypt(key []byte, plaintext []byte, additionalData []byte) ([]byte, []byt return nil, nil, err } aesgcm, err := cipher.NewGCM(block) - nonce := make([]byte, aesgcm.NonceSize()) - if _, err := io.ReadFull(rand.Reader, nonce); err != nil { + if err != nil { return nil, nil, err } - if err != nil { + nonce := make([]byte, aesgcm.NonceSize()) + if _, err := io.ReadFull(rand.Reader, nonce); err != nil { return nil, nil, err } ciphertext := aesgcm.Seal(nil, nonce, plaintext, additionalData)