crypto: Use helpers for size calculations

This commit is contained in:
Michael Eischer
2022-02-13 16:48:48 +01:00
parent d6db5a1fc2
commit 243698680a
3 changed files with 4 additions and 5 deletions

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