internal/cryptotest: fix typos in AEAD test comments

This commit is contained in:
Sun Yimin 2024-10-01 11:37:10 +08:00 committed by GitHub
parent 68056a6730
commit e1c457c1f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,7 +108,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
// Test all combinations of plaintext and additional data lengths.
for _, ptLen := range lengths {
if ptLen <= 1 { // We need enough room for an overlap to occur.
if ptLen <= 1 { // We need enough room for an inexact overlap to occur.
continue
}
for _, adLen := range lengths {
@ -196,7 +196,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
rng.Read(longBuff)
prefixes := [][]byte{shortBuff, longBuff}
// Check each prefix gets appended to by Seal with altering them.
// Check each prefix gets appended to by Seal without altering them.
for _, prefix := range prefixes {
plaintext, addData := make([]byte, ptLen), make([]byte, adLen)
rng.Read(plaintext)
@ -204,8 +204,8 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
out := sealMsg(t, aead, prefix, nonce, plaintext, addData)
// Check that Seal didn't alter the prefix
if !bytes.Equal(out[0:len(prefix)], prefix) {
t.Errorf("Seal alters dst instead of appending; got %s, want %s", truncateHex(out[0:len(prefix)]), truncateHex(prefix))
if !bytes.Equal(out[:len(prefix)], prefix) {
t.Errorf("Seal alters dst instead of appending; got %s, want %s", truncateHex(out[:len(prefix)]), truncateHex(prefix))
}
ciphertext := out[len(prefix):]
@ -227,7 +227,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
rng.Read(longBuff)
prefixes := [][]byte{shortBuff, longBuff}
// Check each prefix gets appended to by Open with altering them.
// Check each prefix gets appended to by Open without altering them.
for _, prefix := range prefixes {
before, addData := make([]byte, adLen), make([]byte, ptLen)
rng.Read(before)
@ -237,8 +237,8 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
out := openWithoutError(t, aead, prefix, nonce, ciphertext, addData)
// Check that Open didn't alter the prefix
if !bytes.Equal(out[0:len(prefix)], prefix) {
t.Errorf("Open alters dst instead of appending; got %s, want %s", truncateHex(out[0:len(prefix)]), truncateHex(prefix))
if !bytes.Equal(out[:len(prefix)], prefix) {
t.Errorf("Open alters dst instead of appending; got %s, want %s", truncateHex(out[:len(prefix)]), truncateHex(prefix))
}
after := out[len(prefix):]