diff options
author | zelig <viktor.tron@gmail.com> | 2015-01-19 12:53:48 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-02-06 07:00:35 +0800 |
commit | 489d956283390b701473edd4a597afea2c426d41 (patch) | |
tree | 92ec206e6a1cb0c6eedbacdcdc0acafae60b396d /p2p/crypto_test.go | |
parent | 076c382a7486ebf58f33e1e0df49e92dc877ea19 (diff) | |
download | go-tangerine-489d956283390b701473edd4a597afea2c426d41.tar go-tangerine-489d956283390b701473edd4a597afea2c426d41.tar.gz go-tangerine-489d956283390b701473edd4a597afea2c426d41.tar.bz2 go-tangerine-489d956283390b701473edd4a597afea2c426d41.tar.lz go-tangerine-489d956283390b701473edd4a597afea2c426d41.tar.xz go-tangerine-489d956283390b701473edd4a597afea2c426d41.tar.zst go-tangerine-489d956283390b701473edd4a597afea2c426d41.zip |
completed the test. FAIL now. it crashes at diffie-hellman. ECIES -> secp256k1-go panics
Diffstat (limited to 'p2p/crypto_test.go')
-rw-r--r-- | p2p/crypto_test.go | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/p2p/crypto_test.go b/p2p/crypto_test.go index 1785b5c45..cfb2d19d1 100644 --- a/p2p/crypto_test.go +++ b/p2p/crypto_test.go @@ -1,7 +1,7 @@ package p2p import ( - // "bytes" + "bytes" "fmt" "testing" @@ -24,31 +24,32 @@ func TestCryptoHandshake(t *testing.T) { return } - auth, initNonce, _, _ := initiator.initAuth(responder.pubKeyDER, sessionToken) - - response, remoteRespNonce, remoteInitNonce, remoteRandomPubKey, _ := responder.verifyAuth(auth, sessionToken, pubInit) - - respNonce, randomPubKey, _, _ := initiator.verifyAuthResp(response) - - fmt.Printf("%x\n%x\n%x\n%x\n%x\n%x\n%x\n%x\n", auth, initNonce, response, remoteRespNonce, remoteInitNonce, remoteRandomPubKey, respNonce, randomPubKey) - initSessionToken, initSecretRW, _ := initiator.newSession(initNonce, respNonce, auth, randomPubKey) - // respSessionToken, respSecretRW, _ := responder.newSession(remoteInitNonce, remoteRespNonce, auth, remoteRandomPubKey) - - // if !bytes.Equal(initSessionToken, respSessionToken) { - // t.Errorf("session tokens do not match") - // } - // // aesSecret, macSecret, egressMac, ingressMac - // if !bytes.Equal(initSecretRW.aesSecret, respSecretRW.aesSecret) { - // t.Errorf("AES secrets do not match") - // } - // if !bytes.Equal(initSecretRW.macSecret, respSecretRW.macSecret) { - // t.Errorf("macSecrets do not match") - // } - // if !bytes.Equal(initSecretRW.egressMac, respSecretRW.egressMac) { - // t.Errorf("egressMacs do not match") - // } - // if !bytes.Equal(initSecretRW.ingressMac, respSecretRW.ingressMac) { - // t.Errorf("ingressMacs do not match") - // } + auth, initNonce, randomPrvKey, randomPubKey, _ := initiator.initAuth(responder.pubKeyDER, sessionToken) + + response, remoteRespNonce, remoteInitNonce, remoteRandomPrivKey, _ := responder.verifyAuth(auth, sessionToken, pubInit) + + respNonce, remoteRandomPubKey, _, _ := initiator.verifyAuthResp(response) + + initSessionToken, initSecretRW, _ := initiator.newSession(initNonce, respNonce, auth, randomPrvKey, remoteRandomPubKey) + respSessionToken, respSecretRW, _ := responder.newSession(remoteInitNonce, remoteRespNonce, auth, remoteRandomPrivKey, randomPubKey) + + fmt.Printf("%x\n%x\n%x\n%x\n%x\n%x\n%x\n%x\n%x\n%x\n", auth, initNonce, response, remoteRespNonce, remoteInitNonce, remoteRandomPubKey, respNonce, randomPubKey, initSessionToken, initSecretRW) + + if !bytes.Equal(initSessionToken, respSessionToken) { + t.Errorf("session tokens do not match") + } + // aesSecret, macSecret, egressMac, ingressMac + if !bytes.Equal(initSecretRW.aesSecret, respSecretRW.aesSecret) { + t.Errorf("AES secrets do not match") + } + if !bytes.Equal(initSecretRW.macSecret, respSecretRW.macSecret) { + t.Errorf("macSecrets do not match") + } + if !bytes.Equal(initSecretRW.egressMac, respSecretRW.egressMac) { + t.Errorf("egressMacs do not match") + } + if !bytes.Equal(initSecretRW.ingressMac, respSecretRW.ingressMac) { + t.Errorf("ingressMacs do not match") + } } |