コード例 #1
0
  void AuthPass(const Id &authe_id, NullAuthenticate *authe, NullAuthenticator *autho)
  {
    QVariant m1 = authe->PrepareForChallenge();
    QPair<bool, QVariant> m2 = autho->RequestChallenge(authe_id, m1);
    EXPECT_TRUE(m2.first);

    QPair<bool, QVariant> r1 = authe->ProcessChallenge(m2.second);
    EXPECT_TRUE(r1.first);

    QPair<bool, PublicIdentity> r2 = autho->VerifyResponse(authe_id, r1.second);
    EXPECT_TRUE(r2.first);
    EXPECT_EQ(r2.second, GetPublicIdentity(authe->GetPrivateIdentity()));
  }
コード例 #2
0
  QVariant LRSAuthenticate::PrepareForChallenge()
  {
    Library *lib = CryptoFactory::GetInstance().GetLibrary();
    QSharedPointer<AsymmetricKey> skey(lib->CreatePrivateKey());
    QSharedPointer<AsymmetricKey> dkey(lib->CreatePrivateKey());
    QSharedPointer<DiffieHellman> dh(lib->CreateDiffieHellman());
    _ident = PrivateIdentity(_ori_ident.GetLocalId(), skey, dkey, dh,
        _ori_ident.GetSuperPeer());
    _pub_ident = GetPublicIdentity(_ident);

    QByteArray bident;
    QDataStream stream(&bident, QIODevice::WriteOnly);
    stream << _pub_ident;

    QVariantList list;
    list.append(bident);
    list.append(_lrs->Sign(bident));
    return list;
  }