FC Updates from BitShares and myself #21
1 changed files with 30 additions and 8 deletions
|
|
@ -52,15 +52,37 @@ BOOST_AUTO_TEST_CASE(dh_test)
|
|||
alice.p = bob.p;
|
||||
alice.g = 9;
|
||||
BOOST_CHECK( !alice.validate() );
|
||||
}
|
||||
|
||||
// It ain't easy...
|
||||
// alice.g = 2;
|
||||
// BOOST_CHECK( alice.validate() );
|
||||
// BOOST_CHECK( alice.generate_pub_key() );
|
||||
// BOOST_CHECK( alice.compute_shared_key( bob.pub_key ) );
|
||||
// BOOST_CHECK( bob.compute_shared_key( alice.pub_key ) );
|
||||
// BOOST_CHECK_EQUAL( alice.shared_key.size(), bob.shared_key.size() );
|
||||
// BOOST_CHECK( memcmp( alice.shared_key.data(), bob.shared_key.data(), alice.shared_key.size() ) );
|
||||
static const std::string P( "\344\005\357H\277<\305\356\006*\312\326\265\347;\363" );
|
||||
static const std::string ALICE_PUB( "\015\343p\243\344d\3600\015/UL\340\277\243\203" );
|
||||
static const std::string ALICE_PRIV( "oJ'\363\227\243\346\215/V\253\036i\250\370\233" );
|
||||
static const std::string BOB_PUB( "26x`3\017A\365\334\022\031\231\032Y\242\242" );
|
||||
static const std::string BOB_PRIV( "d\300\327v?jG4\340\037k\221\230z\372\203" );
|
||||
static const std::string SHARED_KEY( "\303.\236g\25767!\006\365u\341;o\241" );
|
||||
BOOST_AUTO_TEST_CASE(dh_size_mismatch_test)
|
||||
{
|
||||
fc::diffie_hellman alice;
|
||||
alice.p.insert( alice.p.begin(), P.begin(), P.end() );
|
||||
alice.pub_key.insert( alice.pub_key.begin(), ALICE_PUB.begin(), ALICE_PUB.end() );
|
||||
alice.priv_key.insert( alice.priv_key.begin(), ALICE_PRIV.begin(), ALICE_PRIV.end() );
|
||||
alice.g = 5;
|
||||
BOOST_CHECK( alice.validate() );
|
||||
|
||||
fc::diffie_hellman bob;
|
||||
bob.p = alice.p;
|
||||
bob.pub_key.insert( bob.pub_key.begin(), BOB_PUB.begin(), BOB_PUB.end() );
|
||||
bob.priv_key.insert( bob.priv_key.begin(), BOB_PRIV.begin(), BOB_PRIV.end() );
|
||||
bob.g = alice.g;
|
||||
BOOST_CHECK( bob.validate() );
|
||||
|
||||
BOOST_CHECK( alice.compute_shared_key( bob.pub_key ) );
|
||||
BOOST_CHECK( bob.compute_shared_key( alice.pub_key ) );
|
||||
BOOST_CHECK_EQUAL( 15, alice.shared_key.size() );
|
||||
BOOST_CHECK_EQUAL( 15, bob.shared_key.size() );
|
||||
BOOST_CHECK( !memcmp( alice.shared_key.data(), bob.shared_key.data(), alice.shared_key.size() ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( SHARED_KEY, std::string( alice.shared_key.begin(), alice.shared_key.end() ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
Loading…
Reference in a new issue