diff --git a/cmix/nodes/request.go b/cmix/nodes/request.go index 7c0664f513a550957216deb4c7a7e0c003b573fe..fe2d620c2b6590edf45c807ccca7bc1886b9ef20 100644 --- a/cmix/nodes/request.go +++ b/cmix/nodes/request.go @@ -202,6 +202,10 @@ func processRequestResponse(signedKeyResponse *pb.SignedKeyResponse, jww.TRACE.Printf("DH for reg took %s", time.Since(start)) // Verify the HMAC + jww.TRACE.Printf("[ClientKeyHMAC] Session Key Bytes: %+v", sessionKey.Bytes()) + jww.TRACE.Printf("[ClientKeyHMAC] EncryptedClientKey: %+v", keyResponse.EncryptedClientKey) + jww.TRACE.Printf("[ClientKeyHMAC] EncryptedClientKeyHMAC: %+v", keyResponse.EncryptedClientKeyHMAC) + if !registration.VerifyClientHMAC(sessionKey.Bytes(), keyResponse.EncryptedClientKey, opts.Hash.New, keyResponse.EncryptedClientKeyHMAC) { diff --git a/connect/crypto_test.go b/connect/crypto_test.go index 6e7089529e9903f7ad0c167127f5dc14b8fc78d1..0cec007eb478ab853a180e01213f41ac65256585 100644 --- a/connect/crypto_test.go +++ b/connect/crypto_test.go @@ -9,13 +9,36 @@ package connect import ( "bytes" + "testing" + "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/xx" "gitlab.com/xx_network/primitives/id" - "testing" ) -var expectedSig = []byte{187, 204, 247, 50, 98, 78, 28, 104, 15, 123, 40, 138, 202, 195, 4, 176, 246, 11, 97, 148, 47, 134, 15, 25, 97, 196, 88, 207, 85, 5, 149, 140, 47, 106, 89, 19, 19, 18, 209, 205, 163, 177, 176, 246, 237, 215, 242, 199, 69, 26, 47, 124, 212, 115, 102, 59, 214, 181, 22, 76, 43, 134, 136, 158, 39, 47, 107, 182, 169, 102, 201, 205, 224, 220, 245, 125, 244, 19, 104, 187, 239, 194, 243, 172, 82, 31, 135, 254, 80, 54, 147, 249, 209, 240, 79, 91, 83, 183, 247, 203, 96, 135, 69, 250, 79, 129, 234, 70, 215, 98, 65, 182, 112, 31, 53, 254, 18, 139, 11, 188, 247, 235, 236, 61, 30, 21, 164, 128} +// NOTE: there are 2 signatures to deal with race condition-styled behaviors +// added in recent versions of go. Basically one or the other of the following +// will be generated. +var expectedSig1 = []byte{139, 67, 63, 6, 185, 76, 60, 217, 163, 84, + 251, 231, 197, 6, 33, 179, 53, 66, 88, 75, 105, 191, 16, 71, + 126, 4, 16, 11, 41, 237, 34, 245, 242, 97, 44, 58, 154, 120, + 58, 235, 240, 140, 223, 80, 232, 51, 94, 247, 226, 217, 79, + 194, 215, 46, 187, 157, 55, 167, 180, 179, 12, 228, 205, 98, + 132, 200, 146, 180, 142, 0, 230, 79, 0, 129, 39, 205, 67, 79, + 252, 62, 187, 125, 130, 232, 125, 41, 99, 63, 106, 79, 234, + 131, 109, 103, 189, 149, 45, 169, 227, 85, 164, 121, 103, 254, + 19, 224, 236, 28, 187, 38, 240, 132, 192, 227, 145, 140, 56, + 196, 91, 48, 228, 242, 123, 142, 123, 221, 159, 160} + +var expectedSig2 = []byte{187, 204, 247, 50, 98, 78, 28, 104, 15, 123, + 40, 138, 202, 195, 4, 176, 246, 11, 97, 148, 47, 134, 15, 25, 97, 196, + 88, 207, 85, 5, 149, 140, 47, 106, 89, 19, 19, 18, 209, 205, 163, 177, + 176, 246, 237, 215, 242, 199, 69, 26, 47, 124, 212, 115, 102, 59, 214, + 181, 22, 76, 43, 134, 136, 158, 39, 47, 107, 182, 169, 102, 201, 205, + 224, 220, 245, 125, 244, 19, 104, 187, 239, 194, 243, 172, 82, 31, + 135, 254, 80, 54, 147, 249, 209, 240, 79, 91, 83, 183, 247, 203, 96, + 135, 69, 250, 79, 129, 234, 70, 215, 98, 65, 182, 112, 31, 53, 254, + 18, 139, 11, 188, 247, 235, 236, 61, 30, 21, 164, 128} type CountingReader struct { count uint8 @@ -60,9 +83,10 @@ func TestSignVerify_Consistency(t *testing.T) { t.Fatalf("Verify error: %v", err) } - if !bytes.Equal(signature, expectedSig) { + if !bytes.Equal(signature, expectedSig1) && + !bytes.Equal(signature, expectedSig2) { t.Errorf("Consistency test failed."+ - "\nExpected: %v"+ - "\nReceived: %v", expectedSig, signature) + "\nExpected1: %v\nExpected2: %v"+ + "\nReceived: %v", expectedSig1, expectedSig2, signature) } } diff --git a/fileTransfer/store/received.go b/fileTransfer/store/received.go index c1add4a985d26eedddff7a33676c782ba18be7f3..a62ce9acf7e6dfce7193f381345a0997ad61283a 100644 --- a/fileTransfer/store/received.go +++ b/fileTransfer/store/received.go @@ -9,12 +9,13 @@ package store import ( "encoding/json" + "sync" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/v4/storage/versioned" ftCrypto "gitlab.com/elixxir/crypto/fileTransfer" "gitlab.com/xx_network/primitives/netTime" - "sync" ) // Storage keys and versions.