Ejemplo n.º 1
0
  void DiffieHellmanTest(Library *lib)
  {
    QScopedPointer<DiffieHellman> dh0(lib->CreateDiffieHellman());
    QScopedPointer<DiffieHellman> dh1(lib->CreateDiffieHellman());
    QScopedPointer<DiffieHellman> dh2(lib->CreateDiffieHellman());

    QByteArray shared_0_1 = dh0->GetSharedSecret(dh1->GetPublicComponent());
    QByteArray shared_1_0 = dh1->GetSharedSecret(dh0->GetPublicComponent());
    QByteArray shared_0_2 = dh0->GetSharedSecret(dh2->GetPublicComponent());
    QByteArray shared_2_0 = dh2->GetSharedSecret(dh0->GetPublicComponent());
    QByteArray shared_1_2 = dh1->GetSharedSecret(dh2->GetPublicComponent());
    QByteArray shared_2_1 = dh2->GetSharedSecret(dh1->GetPublicComponent());
    EXPECT_EQ(shared_0_1, shared_1_0);
    EXPECT_EQ(shared_0_2, shared_2_0);
    EXPECT_EQ(shared_1_2, shared_2_1);
    EXPECT_NE(shared_0_1, shared_0_2);
    EXPECT_NE(shared_0_1, shared_1_2);

    QScopedPointer<DiffieHellman> dh0_0(lib->LoadDiffieHellman(dh0->GetPrivateComponent()));
    EXPECT_EQ(dh0->GetPublicComponent(), dh0_0->GetPublicComponent());
    EXPECT_EQ(dh0->GetPrivateComponent(), dh0_0->GetPrivateComponent());

    Id id;
    QScopedPointer<DiffieHellman> dh3_0(lib->GenerateDiffieHellman(id.GetByteArray()));
    QScopedPointer<DiffieHellman> dh3_1(lib->GenerateDiffieHellman(id.GetByteArray()));
    EXPECT_EQ(dh3_0->GetPublicComponent(), dh3_1->GetPublicComponent());
    EXPECT_EQ(dh3_0->GetPrivateComponent(), dh3_1->GetPrivateComponent());
  }
Ejemplo n.º 2
0
    void test_holder()
    {
        // a new DomainObject with a new DataObject object are created
        OrmXml::Holder dh0;
        CPPUNIT_ASSERT(dh0._get_p() != NULL);
        CPPUNIT_ASSERT(!dh0->is_empty());
        // a new DomainObject with an empty DataObject are created
        OrmXml::Holder dh1(EMPTY_DATAOBJ);
        CPPUNIT_ASSERT(dh1._get_p() != NULL);
        CPPUNIT_ASSERT(dh1->is_empty());

        Engine engine(Engine::READ_ONLY);
        setup_log(engine);
        Session session(Yb::theSchema(), &engine);
        OrmXml dobj(session, ORM_XML_ID4);
        OrmXml::Holder dh2(dobj);
        CPPUNIT_ASSERT(dh2._get_p() != NULL);
        CPPUNIT_ASSERT_EQUAL(shptr_get(dobj.get_data_object()),
                shptr_get(dh2->get_data_object()));
    }
Ejemplo n.º 3
0
void DH_TestInstantiations()
{
	DH dh1;
	DH dh2(NullRNG(), 10);
}