fix more broken cruft

This commit is contained in:
Asim Aslam
2019-12-12 17:10:32 +00:00
parent df728aaddd
commit 7bd50cd251
5 changed files with 29 additions and 17 deletions

View File

@@ -60,6 +60,11 @@ func Decrypt(data []byte, key string) ([]byte, error) {
}
nonceSize := gcm.NonceSize()
if len(data) < nonceSize {
return nil, ErrDecryptingData
}
// NOTE: we need to parse out nonce from the payload
// we prepend the nonce to every encrypted payload
nonce, ciphertext := data[:nonceSize], data[nonceSize:]