mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 12:46:18 +08:00
internal/cryptotest: fix typos in AEAD test comments
This commit is contained in:
parent
68056a6730
commit
e1c457c1f0
@ -108,7 +108,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
|
|||||||
|
|
||||||
// Test all combinations of plaintext and additional data lengths.
|
// Test all combinations of plaintext and additional data lengths.
|
||||||
for _, ptLen := range 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
|
continue
|
||||||
}
|
}
|
||||||
for _, adLen := range lengths {
|
for _, adLen := range lengths {
|
||||||
@ -196,7 +196,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
|
|||||||
rng.Read(longBuff)
|
rng.Read(longBuff)
|
||||||
prefixes := [][]byte{shortBuff, 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 {
|
for _, prefix := range prefixes {
|
||||||
plaintext, addData := make([]byte, ptLen), make([]byte, adLen)
|
plaintext, addData := make([]byte, ptLen), make([]byte, adLen)
|
||||||
rng.Read(plaintext)
|
rng.Read(plaintext)
|
||||||
@ -204,8 +204,8 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
|
|||||||
out := sealMsg(t, aead, prefix, nonce, plaintext, addData)
|
out := sealMsg(t, aead, prefix, nonce, plaintext, addData)
|
||||||
|
|
||||||
// Check that Seal didn't alter the prefix
|
// Check that Seal didn't alter the prefix
|
||||||
if !bytes.Equal(out[0:len(prefix)], prefix) {
|
if !bytes.Equal(out[:len(prefix)], prefix) {
|
||||||
t.Errorf("Seal alters dst instead of appending; got %s, want %s", truncateHex(out[0:len(prefix)]), truncateHex(prefix))
|
t.Errorf("Seal alters dst instead of appending; got %s, want %s", truncateHex(out[:len(prefix)]), truncateHex(prefix))
|
||||||
}
|
}
|
||||||
|
|
||||||
ciphertext := out[len(prefix):]
|
ciphertext := out[len(prefix):]
|
||||||
@ -227,7 +227,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
|
|||||||
rng.Read(longBuff)
|
rng.Read(longBuff)
|
||||||
prefixes := [][]byte{shortBuff, 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 {
|
for _, prefix := range prefixes {
|
||||||
before, addData := make([]byte, adLen), make([]byte, ptLen)
|
before, addData := make([]byte, adLen), make([]byte, ptLen)
|
||||||
rng.Read(before)
|
rng.Read(before)
|
||||||
@ -237,8 +237,8 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
|
|||||||
out := openWithoutError(t, aead, prefix, nonce, ciphertext, addData)
|
out := openWithoutError(t, aead, prefix, nonce, ciphertext, addData)
|
||||||
|
|
||||||
// Check that Open didn't alter the prefix
|
// Check that Open didn't alter the prefix
|
||||||
if !bytes.Equal(out[0:len(prefix)], prefix) {
|
if !bytes.Equal(out[:len(prefix)], prefix) {
|
||||||
t.Errorf("Open alters dst instead of appending; got %s, want %s", truncateHex(out[0:len(prefix)]), truncateHex(prefix))
|
t.Errorf("Open alters dst instead of appending; got %s, want %s", truncateHex(out[:len(prefix)]), truncateHex(prefix))
|
||||||
}
|
}
|
||||||
|
|
||||||
after := out[len(prefix):]
|
after := out[len(prefix):]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user