From 461a58e6a4e0622b852efd209c7e137946b5dd92 Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Wed, 6 Dec 2023 00:37:33 +0000 Subject: [PATCH] go fmt --- cmix/clientGateway_test.go | 2 +- cmix/kmac_test.go | 10 +++++----- cmix/setGroupBits_test.go | 4 ++-- contact/unmarshalVersion_test.go | 1 - cyclic/buffer_test.go | 10 +++++----- cyclic/group_test.go | 12 ++++++------ cyclic/int_test.go | 4 ++-- diffieHellman/dhkx_test.go | 6 +++--- e2e/aes_test.go | 6 +++--- e2e/auth/encryptDecrypt.go | 2 +- e2e/auth/requestFP.go | 4 ++-- e2e/auth/requestFP_test.go | 6 +++--- e2e/derrive_test.go | 6 +++--- e2e/keys_test.go | 6 +++--- e2e/messageID_test.go | 12 ++++++------ e2e/relationshipFingerprint_test.go | 2 +- fastRNG/stream_test.go | 12 ++++++------ hash/keys_test.go | 2 +- partnerships/crust/upload_test.go | 4 ++-- 19 files changed, 55 insertions(+), 56 deletions(-) diff --git a/cmix/clientGateway_test.go b/cmix/clientGateway_test.go index d0126f8c..23b9fd6e 100644 --- a/cmix/clientGateway_test.go +++ b/cmix/clientGateway_test.go @@ -14,7 +14,7 @@ import ( "testing" ) -//Tests that the ClientGateway key generates consistently and expected +// Tests that the ClientGateway key generates consistently and expected func TestGenerateClientGatewayKey(t *testing.T) { grp := grpTest() diff --git a/cmix/kmac_test.go b/cmix/kmac_test.go index d142fb5a..b7f4a88a 100644 --- a/cmix/kmac_test.go +++ b/cmix/kmac_test.go @@ -18,7 +18,7 @@ import ( "testing" ) -//Tests that the kmac function outputs wha +// Tests that the kmac function outputs wha func TestGenerateKMAC_Consistency(t *testing.T) { grp := grpTest() @@ -56,7 +56,7 @@ func TestGenerateKMAC_Consistency(t *testing.T) { } } -//Tests that the kmac function outputs wha +// Tests that the kmac function outputs wha func TestGenerateKMACs_Consistency(t *testing.T) { grp := grpTest() @@ -101,7 +101,7 @@ func TestGenerateKMACs_Consistency(t *testing.T) { } } -//Happy path +// Happy path func TestVerifyKMAC(t *testing.T) { grp := grpTest() @@ -137,7 +137,7 @@ func TestVerifyKMAC(t *testing.T) { } } -//Error path +// Error path func TestVerifyKMAC_WrongExpectedKmac(t *testing.T) { grp := grpTest() @@ -172,7 +172,7 @@ func TestVerifyKMAC_WrongExpectedKmac(t *testing.T) { } -//Error path +// Error path func TestVerifyKACY_Mismatch(t *testing.T) { grp := grpTest() diff --git a/cmix/setGroupBits_test.go b/cmix/setGroupBits_test.go index bccb6369..3f6dd0a6 100644 --- a/cmix/setGroupBits_test.go +++ b/cmix/setGroupBits_test.go @@ -39,7 +39,7 @@ func (s *fakeRNG) SetSeed(seed []byte) error { return nil } -//tests that the byte mask value resulst sin 50% 1s and 50% 0s +// tests that the byte mask value resulst sin 50% 1s and 50% 0s func TestSelectGroupBit_ByteMask(t *testing.T) { //c := csprng.Source(&csprng.SystemRNG{}) c := newFakeRNG() @@ -92,7 +92,7 @@ func (s *all1RNG) SetSeed(seed []byte) error { return nil } -//tests that when the payload is outside the group with a leading 1, it makes the leading value a 0 +// tests that when the payload is outside the group with a leading 1, it makes the leading value a 0 func TestSelectGroupBit_InGroup(t *testing.T) { prime := large.NewIntFromString(pString, base) payload := prime.Add(prime, prime) diff --git a/contact/unmarshalVersion_test.go b/contact/unmarshalVersion_test.go index 43e339d8..85af60b7 100644 --- a/contact/unmarshalVersion_test.go +++ b/contact/unmarshalVersion_test.go @@ -28,7 +28,6 @@ var expectedContact = []string{ "<xxc(2)WnzDHpJX9IYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIAB7Ugdw/BAr6WjQA9fwDEYOKAAAAAAAAAAAAAAAAAAAAAAAAAAAAGwAVWFYZz0sVTJhWE9ZdjZjR0E9PSxVUEJrenFSYlhPRHVaUEdsSm1VV3dzTS9qM0M3Qi9KWT07zmmJXN9xJq5gp21nEEkmqg==xxc>", } - // Consistency test for unmarshal version "2". func TestContact_unmarshalVer2_Consistency(t *testing.T) { prng := rand.New(rand.NewSource(42)) diff --git a/cyclic/buffer_test.go b/cyclic/buffer_test.go index 5b966dfd..c5e5f815 100644 --- a/cyclic/buffer_test.go +++ b/cyclic/buffer_test.go @@ -12,7 +12,7 @@ import ( "testing" ) -//Tests that getting and interacting with the intbuffer is correct +// Tests that getting and interacting with the intbuffer is correct func TestIntBuffer_Get(t *testing.T) { p := large.NewInt(1000000010101111111) g := large.NewInt(5) @@ -43,7 +43,7 @@ func TestIntBuffer_Get(t *testing.T) { } } -//Tests that len works correctly +// Tests that len works correctly func TestIntBuffer_Len(t *testing.T) { p := large.NewInt(1000000010101111111) g := large.NewInt(5) @@ -57,7 +57,7 @@ func TestIntBuffer_Len(t *testing.T) { } } -//Tests that GetFingerprint returns the correct fingerprint +// Tests that GetFingerprint returns the correct fingerprint func TestIntBuffer_GetFingerprint(t *testing.T) { p1 := large.NewInt(1000000010101111111) g := large.NewInt(5) @@ -82,7 +82,7 @@ func TestIntBuffer_GetFingerprint(t *testing.T) { } -//Tests that getting a region in the intbuffer works correctly +// Tests that getting a region in the intbuffer works correctly func TestIntBuffer_GetRegion(t *testing.T) { p := large.NewInt(1000000010101111111) g := large.NewInt(5) @@ -125,7 +125,7 @@ func TestIntBuffer_GetRegion(t *testing.T) { } } -//Tests that deep copy of an int buffer copies correctly +// Tests that deep copy of an int buffer copies correctly func TestIntBuffer_DeepCopy(t *testing.T) { p := large.NewInt(1000000010101111111) g := large.NewInt(5) diff --git a/cyclic/group_test.go b/cyclic/group_test.go index 7b25e8ee..73cb849d 100644 --- a/cyclic/group_test.go +++ b/cyclic/group_test.go @@ -55,7 +55,7 @@ func TestNewInt(t *testing.T) { } } -//Tests creation and properties of an IntBuffer +// Tests creation and properties of an IntBuffer func TestGroup_NewIntBuffer(t *testing.T) { p := large.NewInt(1000000010101111111) @@ -1083,9 +1083,9 @@ func TestGetP(t *testing.T) { } } -//Tests the prime byte getter from the group -//Tests the old manual call against the implementation (p.Bytes() vs grp.GetPBytes()) -//P is never nil, so no edge case there +// Tests the prime byte getter from the group +// Tests the old manual call against the implementation (p.Bytes() vs grp.GetPBytes()) +// P is never nil, so no edge case there func TestGetPBytes(t *testing.T) { // setup test group and generator p := large.NewInt(17) @@ -1461,8 +1461,8 @@ func TestRandomCoprime_PanicReadErr(t *testing.T) { group.RandomCoprime(group.NewInt(1)) } -//Tests whether the z value is prematurely overwritten in the group after RootCoprime is run -//Tests z value after rootcoprime against a value it's known to be given this input +// Tests whether the z value is prematurely overwritten in the group after RootCoprime is run +// Tests z value after rootcoprime against a value it's known to be given this input func TestRootCoprime_ZVal(t *testing.T) { p := large.NewInt(17) g := large.NewInt(29) diff --git a/cyclic/int_test.go b/cyclic/int_test.go index 73d625c6..ade156b7 100644 --- a/cyclic/int_test.go +++ b/cyclic/int_test.go @@ -78,7 +78,7 @@ func TestLeftpadBytes(t *testing.T) { } } -//TestBitLen checks if BitLen works +// TestBitLen checks if BitLen works func TestBitLen(t *testing.T) { testints := []*Int{ grp.NewInt(42), @@ -218,7 +218,7 @@ func TestTextVerbose(t *testing.T) { } } -//TestByteLen checks if the ByteLen placeholder exists +// TestByteLen checks if the ByteLen placeholder exists func TestByteLen(t *testing.T) { testints := []*Int{ grp.NewInt(1), //1 bits --> 1 byte (where +7 works) diff --git a/diffieHellman/dhkx_test.go b/diffieHellman/dhkx_test.go index 05e532ef..9f7cbd1b 100644 --- a/diffieHellman/dhkx_test.go +++ b/diffieHellman/dhkx_test.go @@ -56,7 +56,7 @@ func TestGeneratePrivateKey(t *testing.T) { } } -//tests public keys are generated correctly +// tests public keys are generated correctly func TestGeneratePublicKey(t *testing.T) { const numTests = 50 @@ -97,7 +97,7 @@ func TestGeneratePublicKey(t *testing.T) { } } -//tests Session keys are generated correctly +// tests Session keys are generated correctly func TestGenerateSessionKey(t *testing.T) { const numTests = 50 @@ -196,7 +196,7 @@ func TestCheckPublicKey(t *testing.T) { } -//benchmarks session key creation +// benchmarks session key creation func BenchmarkCreateDHSessionKey(b *testing.B) { primeString := "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" + diff --git a/e2e/aes_test.go b/e2e/aes_test.go index b93bf33a..cca4ad04 100644 --- a/e2e/aes_test.go +++ b/e2e/aes_test.go @@ -175,9 +175,9 @@ func TestDecryptCore_BadArgs(t *testing.T) { println("TestEncryptCore_BadArgs()", pass, "out of", tests, "tests passed.") } -//------------------------------------------------------------------------------------------------// -//--------------------------------- Tests for exported functions ---------------------------------// -//------------------------------------------------------------------------------------------------// +// ------------------------------------------------------------------------------------------------// +// --------------------------------- Tests for exported functions ---------------------------------// +// ------------------------------------------------------------------------------------------------// const ( TEST_MSG = "The quick brown fox jumps over the lazy dog" TEST_KEY_2048 = "4851871933b715040372862bbddc4bfcae7607f9a392172496b585534533e2ce" + diff --git a/e2e/auth/encryptDecrypt.go b/e2e/auth/encryptDecrypt.go index a2a13865..ea9f83cb 100644 --- a/e2e/auth/encryptDecrypt.go +++ b/e2e/auth/encryptDecrypt.go @@ -17,7 +17,7 @@ func Encrypt(myPrivKey, partnerPubKey *cyclic.Int, payload []byte, grp *cyclic.Group) (ecrPayload, mac []byte) { // Generate the base key - authKey, vec := MakeAuthKey(myPrivKey, partnerPubKey,grp) + authKey, vec := MakeAuthKey(myPrivKey, partnerPubKey, grp) // Encrypt the payload ecrPayload = Crypt(authKey, vec, payload) diff --git a/e2e/auth/requestFP.go b/e2e/auth/requestFP.go index a34afe4f..580a871a 100644 --- a/e2e/auth/requestFP.go +++ b/e2e/auth/requestFP.go @@ -18,7 +18,7 @@ import ( const authRequestFingerprintVector = "authRequestFingerprintVector" -//Sets the message as an authenticated channel creation message +// Sets the message as an authenticated channel creation message func SetRequestFingerprint(m format.Message, partnerPublicKey *cyclic.Int) { //get the key hash @@ -28,7 +28,7 @@ func SetRequestFingerprint(m format.Message, partnerPublicKey *cyclic.Int) { m.SetKeyFP(keyHash) } -//creates a valid auth request fingerprint from a public key +// creates a valid auth request fingerprint from a public key func MakeRequestFingerprint(publicKey *cyclic.Int) format.Fingerprint { // Create new hash //suppress because we just panic and a nil hash will panic anyhow diff --git a/e2e/auth/requestFP_test.go b/e2e/auth/requestFP_test.go index 0feab764..72b9c20f 100644 --- a/e2e/auth/requestFP_test.go +++ b/e2e/auth/requestFP_test.go @@ -15,7 +15,7 @@ import ( "testing" ) -//Tests that the generated fingerprints do not change +// Tests that the generated fingerprints do not change func TestMakeRequestFingerprint_Consistency(t *testing.T) { expected := []string{ "MY/pv2UmD7nvcsU6hmcly72humiiqOWIspbiGw4pHr4=", @@ -42,7 +42,7 @@ func TestMakeRequestFingerprint_Consistency(t *testing.T) { } } -//Tests that the first bit of the fingerprint is always zero +// Tests that the first bit of the fingerprint is always zero func TestMakeRequestFingerprint_FirstBitZero(t *testing.T) { const numTests = 100 @@ -62,7 +62,7 @@ func TestMakeRequestFingerprint_FirstBitZero(t *testing.T) { } } -//Tests that the set fingerprints are correct +// Tests that the set fingerprints are correct func TestSetRequestFingerprint_Consistency(t *testing.T) { expected := []string{ "MY/pv2UmD7nvcsU6hmcly72humiiqOWIspbiGw4pHr4=", diff --git a/e2e/derrive_test.go b/e2e/derrive_test.go index 51eb177d..d9d11855 100644 --- a/e2e/derrive_test.go +++ b/e2e/derrive_test.go @@ -17,7 +17,7 @@ import ( "testing" ) -//checks that the derived keys are as is expected +// checks that the derived keys are as is expected func TestDerive_Consistency(t *testing.T) { expectedKeys := []string{ "xnry59JCUEvvkzAr+S/IHUGHyY2NcWQynI5sYtWL0aE=", @@ -60,7 +60,7 @@ func TestDerive_Consistency(t *testing.T) { } } -//checks that the keynum has an impact on the output key +// checks that the keynum has an impact on the output key func TestDerive_KeyNum(t *testing.T) { const numTests = 25 @@ -88,7 +88,7 @@ func TestDerive_KeyNum(t *testing.T) { } } -//checks that the data has an impact on the output key +// checks that the data has an impact on the output key func TestDerive_Data(t *testing.T) { const numTests = 25 diff --git a/e2e/keys_test.go b/e2e/keys_test.go index 32a00338..b7ed90fb 100644 --- a/e2e/keys_test.go +++ b/e2e/keys_test.go @@ -18,7 +18,7 @@ import ( "testing" ) -//test consistency for DeriveKey +// test consistency for DeriveKey func TestDeriveKey_Consistency(t *testing.T) { expectedKeys := []string{ "2gQs27wW7ckb6zGUBibdyYs6/aBqJxK2YFW6hToO2EI=", @@ -76,7 +76,7 @@ func TestDeriveKey_Consistency_doubleSalt(t *testing.T) { deriveConsistencyTester(t, expectedKeys, d, "DeriveKey()") } -//test consistency for DeriveKeyFingerprint +// test consistency for DeriveKeyFingerprint func TestDeriveKeyFingerprint_Consistency(t *testing.T) { expectedKeys := []string{ "biUwFTuy+udrvH9iMCjBfen4seZAC9Q/5yZMwtVVTyk=", @@ -126,7 +126,7 @@ func deriveConsistencyTester(t *testing.T, expectedKeys []string, d func(dhkey * } } -//verifies that all derived fingerprints and keys are different +// verifies that all derived fingerprints and keys are different func TestAllDifferent(t *testing.T) { const numtests = 25 diff --git a/e2e/messageID_test.go b/e2e/messageID_test.go index 66228494..37bdd8c2 100644 --- a/e2e/messageID_test.go +++ b/e2e/messageID_test.go @@ -15,7 +15,7 @@ import ( "testing" ) -//tests io consistency of new message id +// tests io consistency of new message id func TestNewMessageID_Consistency(t *testing.T) { prng := rand.New(rand.NewSource(42)) @@ -70,7 +70,7 @@ func TestNewMessageID_AllInputs(t *testing.T) { } } -//tests that the wrong size error triggers correctly +// tests that the wrong size error triggers correctly func TestUnmarshalMessageID_Error(t *testing.T) { nulMID := MessageID{} @@ -103,7 +103,7 @@ func TestUnmarshalMessageID_Error(t *testing.T) { } } -//tests that unmarshal produces the correct result +// tests that unmarshal produces the correct result func TestUnmarshalMessageID(t *testing.T) { expected := []string{ @@ -131,7 +131,7 @@ func TestUnmarshalMessageID(t *testing.T) { } } -//tests that ths string function produces the correct truncated result +// tests that ths string function produces the correct truncated result func TestMessageID_String_Consistency(t *testing.T) { prng := rand.New(rand.NewSource(42)) @@ -158,7 +158,7 @@ func TestMessageID_String_Consistency(t *testing.T) { } } -//tests that the string verbose produces the correct full result +// tests that the string verbose produces the correct full result func TestMessageID_StringVerbose_Consistency(t *testing.T) { prng := rand.New(rand.NewSource(42)) @@ -185,7 +185,7 @@ func TestMessageID_StringVerbose_Consistency(t *testing.T) { } } -//tests that the string verbose produces the correct full result +// tests that the string verbose produces the correct full result func TestMessageID_Marshal_Consistency(t *testing.T) { prng := rand.New(rand.NewSource(42)) diff --git a/e2e/relationshipFingerprint_test.go b/e2e/relationshipFingerprint_test.go index 1ca37c58..b6f0ba40 100644 --- a/e2e/relationshipFingerprint_test.go +++ b/e2e/relationshipFingerprint_test.go @@ -15,7 +15,7 @@ import ( "testing" ) -//show that every input changes the output hash +// show that every input changes the output hash func TestMakeRelationshipFingerprint(t *testing.T) { grp := getGroup() diff --git a/fastRNG/stream_test.go b/fastRNG/stream_test.go index 85cd410c..1a85a960 100644 --- a/fastRNG/stream_test.go +++ b/fastRNG/stream_test.go @@ -33,7 +33,7 @@ func (m *mockRNG) SetSeed(seed []byte) error { return nil } -//Test the creation of a new stream generator and that it is configured correctly +// Test the creation of a new stream generator and that it is configured correctly func TestNewStreamGenerator(t *testing.T) { sg := NewStreamGenerator(12, 20, csprng.NewSystemRNG) if cap(sg.waitingStreams) != 20 || sg.scalingFactor != 12 { @@ -41,7 +41,7 @@ func TestNewStreamGenerator(t *testing.T) { } } -//Test the creation of new streams and that the counters are in fact working +// Test the creation of new streams and that the counters are in fact working func TestNewStream(t *testing.T) { sg := NewStreamGenerator(12, 3, csprng.NewSystemRNG) s1 := sg.GetStream() @@ -54,7 +54,7 @@ func TestNewStream(t *testing.T) { } } -//Test that a blocked channel will grab a stream that is available +// Test that a blocked channel will grab a stream that is available func TestGetStream_GrabsAlreadyWaitingStream(t *testing.T) { sg := NewStreamGenerator(43, 3, csprng.NewSystemRNG) stream0 := sg.GetStream() @@ -187,7 +187,7 @@ func TestRead_ReadMoreThanSource(t *testing.T) { } } -//Test that different streams under same stream generator output differently upon reading +// Test that different streams under same stream generator output differently upon reading func TestRead_MultipleStreams_DifferentOutputs(t *testing.T) { //A large byte array, of which you will read size from src byte array requestedBytes := make([]byte, 512) @@ -227,7 +227,7 @@ func TestRead_MultipleStreams_DifferentOutputs(t *testing.T) { } } -//Test that b (requestedBytes) is delinked from source by overwriting b and checking that source has not changed +// Test that b (requestedBytes) is delinked from source by overwriting b and checking that source has not changed func TestRead_DelinkedSource(t *testing.T) { //A large byte array, of which you will read size from src byte array requestedBytes := make([]byte, 512) @@ -287,7 +287,7 @@ func TestRead_ReadLessThanSource(t *testing.T) { } } -//Test with a mock read that returns predictably every time +// Test with a mock read that returns predictably every time func TestRead_MockRNG(t *testing.T) { sg := NewStreamGenerator(20, 2, csprng.NewSystemRNG) read := make([]byte, 24) diff --git a/hash/keys_test.go b/hash/keys_test.go index 85144fea..8e4b5a53 100644 --- a/hash/keys_test.go +++ b/hash/keys_test.go @@ -32,7 +32,7 @@ var p = large.NewIntFromString(primeString, 16) var g = large.NewInt(2) var grp = cyclic.NewGroup(p, g) -//TestExpandKey verifies ExpandKey with two different hashes +// TestExpandKey verifies ExpandKey with two different hashes func TestExpandKey(t *testing.T) { test := 4 pass := 0 diff --git a/partnerships/crust/upload_test.go b/partnerships/crust/upload_test.go index 25e3baa4..df7349ea 100644 --- a/partnerships/crust/upload_test.go +++ b/partnerships/crust/upload_test.go @@ -86,8 +86,8 @@ func TestSignVerifyUpload(t *testing.T) { } -//Unit test: Generate signatures using pre-canned data -//and compare it against the expected pre-canned data. +// Unit test: Generate signatures using pre-canned data +// and compare it against the expected pre-canned data. func TestSignUpload_Consistency(t *testing.T) { // use insecure seeded rng to ensure repeatability notRand := &CountingReader{count: uint8(0)} -- GitLab