crypto: Use helpers for size calculations

This commit is contained in:
Michael Eischer committed 2022-03-28 22:09:49 +02:00
1 parent d6db5a1fc2
commit 243698680a
3 files changed
+4 -5

No files matched your search

+1 -1
View File
@@ -262,7 +262,7 @@ func AddKey(ctx context.Context, s *Repository, password, username, hostname str
}
nonce := crypto.NewRandomNonce()
ciphertext := make([]byte, 0, len(buf)+newkey.user.Overhead()+newkey.user.NonceSize())
ciphertext := make([]byte, 0, restic.CiphertextLength(len(buf)))
ciphertext = append(ciphertext, nonce...)
ciphertext = newkey.user.Seal(ciphertext, nonce, buf, nil)
newkey.Data = ciphertext