diff options
author | subtly <subtly@users.noreply.github.com> | 2015-02-13 15:48:33 +0800 |
---|---|---|
committer | subtly <subtly@users.noreply.github.com> | 2015-02-13 15:48:33 +0800 |
commit | 5f5bca7632cee1d810bdc086ca7391fc06c7d892 (patch) | |
tree | f362be5519a56674c0eb7e38f3a6adbb16b0f4d9 | |
parent | 48f6bda44b0a8335ed3cbd072fc8b6f30d2c6c4c (diff) | |
download | dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.tar dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.tar.gz dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.tar.bz2 dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.tar.lz dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.tar.xz dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.tar.zst dexon-solidity-5f5bca7632cee1d810bdc086ca7391fc06c7d892.zip |
initiator handshake crypto-test
-rw-r--r-- | crypto.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -316,6 +316,43 @@ BOOST_AUTO_TEST_CASE(ecdhe) BOOST_REQUIRE_EQUAL(sremote, slocal); } +BOOST_AUTO_TEST_CASE(handshakeNew) +{ + // authInitiator -> E(remote-pubk, S(ecdhe-random, ecdh-shared-secret^nonce) || H(ecdhe-random-pubk) || pubk || nonce || 0x0) + // authRecipient -> E(remote-pubk, ecdhe-random-pubk || nonce || 0x0) + + Secret nodeAsecret(sha3("privacy")); + KeyPair nodeA(nodeAsecret); + + Secret nodeBsecret(sha3("privacy++")); + KeyPair nodeB(nodeBsecret); + + // Initiator is Alice (nodeA) + ECDHE eA; + bytes nAbytes(fromHex("0xAAAA")); + h256 nonceA(sha3(nAbytes)); + + bytes auth(Signature::size + h256::size + Public::size + h256::size + 1); + { + bytesConstRef sig(&auth[0], Signature::size); + bytesConstRef hepubk(&auth[Signature::size], h256::size); + bytesConstRef pubk(&auth[Signature::size + h256::size], Public::size); + bytesConstRef nonce(&auth[Signature::size + h256::size + Public::size], h256::size); + + Secret ss; + s_secp256k1.agree(nodeA.sec(), nodeB.pub(), ss); + sign(eA.seckey(), ss ^ nonceA).ref().copyTo(sig); + sha3(eA.pubkey().ref(), hepubk); + nodeA.pub().ref().copyTo(pubk); + nonceA.ref().copyTo(nonce); + auth[auth.size() - 1] = 0x0; + } + + cnote << "initAuth:" << toHex(auth); + +// bytes ack(h256::size * 2 + 1); +} + BOOST_AUTO_TEST_CASE(ecdhe_aes128_ctr_sha3mac) { // New connections require new ECDH keypairs |