From e1c457c1f0cc5a22095406cbbe2d2f5a7a847817 Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Tue, 1 Oct 2024 11:37:10 +0800 Subject: [PATCH] internal/cryptotest: fix typos in AEAD test comments --- internal/cryptotest/aead.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/cryptotest/aead.go b/internal/cryptotest/aead.go index e17cdf8..85a9c92 100644 --- a/internal/cryptotest/aead.go +++ b/internal/cryptotest/aead.go @@ -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):]