From 0cab9ad96d222f84e584f88f59c5680365228ec9 Mon Sep 17 00:00:00 2001 From: mertakman Date: Mon, 30 Sep 2024 14:46:46 +0100 Subject: [PATCH 1/5] fix:add fix for few format issues --- cmd/mksyscall/main.go | 2 +- internal/cryptotest/aead.go | 8 ++++---- internal/subtle/aliasing_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/mksyscall/main.go b/cmd/mksyscall/main.go index 8f7ecd0..eec3b93 100644 --- a/cmd/mksyscall/main.go +++ b/cmd/mksyscall/main.go @@ -103,6 +103,6 @@ func generateSyscalls() []byte { log.Fatal(err) } zsys := bout.Bytes() - zsys = bytes.Replace(zsys, []byte("\"internal/syscall/windows/sysdll\""), []byte("\"github.com/microsoft/go-crypto-winnative/internal/sysdll\""), -1) + zsys = bytes.ReplaceAll(zsys, []byte("\"internal/syscall/windows/sysdll\""), []byte("\"github.com/microsoft/go-crypto-winnative/internal/sysdll\"")) return zsys } diff --git a/internal/cryptotest/aead.go b/internal/cryptotest/aead.go index a6107e5..65f21d5 100644 --- a/internal/cryptotest/aead.go +++ b/internal/cryptotest/aead.go @@ -273,7 +273,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { // Perturb the nonce and check for an error when Opening alterNonce := make([]byte, aead.NonceSize()) copy(alterNonce, nonce) - alterNonce[len(alterNonce)-1] += 1 + alterNonce[len(alterNonce)-1]++ _, err := aead.Open(nil, alterNonce, ciphertext, addData) if err == nil { @@ -308,7 +308,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { // Perturb the Additional Data and check for an error when Opening alterAD := make([]byte, adLen) copy(alterAD, addData) - alterAD[len(alterAD)-1] += 1 + alterAD[len(alterAD)-1]++ _, err := aead.Open(nil, nonce, ciphertext, alterAD) if err == nil { @@ -340,7 +340,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { // Perturb the ciphertext and check for an error when Opening alterCT := make([]byte, len(ciphertext)) copy(alterCT, ciphertext) - alterCT[len(alterCT)-1] += 1 + alterCT[len(alterCT)-1]++ _, err := aead.Open(nil, nonce, alterCT, addData) if err == nil { @@ -353,7 +353,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { } // Helper function to Seal a plaintext with additional data. Checks that -// ciphertext isn't bigger than the plaintext length plus Overhead() +// ciphertext isn't bigger than the plaintext length plus Overhead(). func sealMsg(t *testing.T, aead cipher.AEAD, ciphertext, nonce, plaintext, addData []byte) []byte { t.Helper() diff --git a/internal/subtle/aliasing_test.go b/internal/subtle/aliasing_test.go index 2a94494..71b5b2c 100644 --- a/internal/subtle/aliasing_test.go +++ b/internal/subtle/aliasing_test.go @@ -32,13 +32,13 @@ var aliasingTests = []struct { } func testAliasing(t *testing.T, i int, x, y []byte, anyOverlap, inexactOverlap bool) { - any := subtle.AnyOverlap(x, y) - if any != anyOverlap { - t.Errorf("%d: wrong AnyOverlap result, expected %v, got %v", i, anyOverlap, any) + isOverlapping := subtle.AnyOverlap(x, y) + if isOverlapping != anyOverlap { + t.Errorf("%d: wrong AnyOverlap result, expected %v, got %v", i, anyOverlap, isOverlapping) } inexact := subtle.InexactOverlap(x, y) if inexact != inexactOverlap { - t.Errorf("%d: wrong InexactOverlap result, expected %v, got %v", i, inexactOverlap, any) + t.Errorf("%d: wrong InexactOverlap result, expected %v, got %v", i, inexactOverlap, isOverlapping) } } From 709efd6e580dcbda58bcb4acd9bebe85d8c43b61 Mon Sep 17 00:00:00 2001 From: mertakman Date: Mon, 30 Sep 2024 14:53:01 +0100 Subject: [PATCH 2/5] Fix:revert changes from copied files from upstream --- internal/cryptotest/aead.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cryptotest/aead.go b/internal/cryptotest/aead.go index 65f21d5..f08bcf7 100644 --- a/internal/cryptotest/aead.go +++ b/internal/cryptotest/aead.go @@ -273,7 +273,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { // Perturb the nonce and check for an error when Opening alterNonce := make([]byte, aead.NonceSize()) copy(alterNonce, nonce) - alterNonce[len(alterNonce)-1]++ + alterNonce[len(alterNonce)-1] += 1 _, err := aead.Open(nil, alterNonce, ciphertext, addData) if err == nil { @@ -308,7 +308,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { // Perturb the Additional Data and check for an error when Opening alterAD := make([]byte, adLen) copy(alterAD, addData) - alterAD[len(alterAD)-1]++ + alterAD[len(alterAD)-1] += 1 _, err := aead.Open(nil, nonce, ciphertext, alterAD) if err == nil { From e13ee5f21aeca6f3d99ba9f2d3ddbc2faac3d948 Mon Sep 17 00:00:00 2001 From: mertakman Date: Mon, 30 Sep 2024 14:54:09 +0100 Subject: [PATCH 3/5] Fix:revert changes from copied files from upstream --- internal/subtle/aliasing_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/subtle/aliasing_test.go b/internal/subtle/aliasing_test.go index 71b5b2c..2a94494 100644 --- a/internal/subtle/aliasing_test.go +++ b/internal/subtle/aliasing_test.go @@ -32,13 +32,13 @@ var aliasingTests = []struct { } func testAliasing(t *testing.T, i int, x, y []byte, anyOverlap, inexactOverlap bool) { - isOverlapping := subtle.AnyOverlap(x, y) - if isOverlapping != anyOverlap { - t.Errorf("%d: wrong AnyOverlap result, expected %v, got %v", i, anyOverlap, isOverlapping) + any := subtle.AnyOverlap(x, y) + if any != anyOverlap { + t.Errorf("%d: wrong AnyOverlap result, expected %v, got %v", i, anyOverlap, any) } inexact := subtle.InexactOverlap(x, y) if inexact != inexactOverlap { - t.Errorf("%d: wrong InexactOverlap result, expected %v, got %v", i, inexactOverlap, isOverlapping) + t.Errorf("%d: wrong InexactOverlap result, expected %v, got %v", i, inexactOverlap, any) } } From b038eea63cb2f14e78ece0610ae910e420500bcb Mon Sep 17 00:00:00 2001 From: mertakman Date: Mon, 30 Sep 2024 14:54:36 +0100 Subject: [PATCH 4/5] Fix:revert changes from copied files from upstream --- internal/cryptotest/aead.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cryptotest/aead.go b/internal/cryptotest/aead.go index f08bcf7..6d0f204 100644 --- a/internal/cryptotest/aead.go +++ b/internal/cryptotest/aead.go @@ -340,7 +340,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { // Perturb the ciphertext and check for an error when Opening alterCT := make([]byte, len(ciphertext)) copy(alterCT, ciphertext) - alterCT[len(alterCT)-1]++ + alterCT[len(alterCT)-1] += 1 _, err := aead.Open(nil, nonce, alterCT, addData) if err == nil { From 45ea87e548d5c938b307dfc2ee2b8e7df25d68b7 Mon Sep 17 00:00:00 2001 From: mertakman Date: Mon, 30 Sep 2024 14:55:04 +0100 Subject: [PATCH 5/5] Fix:revert changes from copied files from upstream --- internal/cryptotest/aead.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cryptotest/aead.go b/internal/cryptotest/aead.go index 6d0f204..a6107e5 100644 --- a/internal/cryptotest/aead.go +++ b/internal/cryptotest/aead.go @@ -353,7 +353,7 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) { } // Helper function to Seal a plaintext with additional data. Checks that -// ciphertext isn't bigger than the plaintext length plus Overhead(). +// ciphertext isn't bigger than the plaintext length plus Overhead() func sealMsg(t *testing.T, aead cipher.AEAD, ciphertext, nonce, plaintext, addData []byte) []byte { t.Helper()