/*!
 * @brief Testa se o certificado mantém a formatação após ser emitido.
 */
TEST_F(CertificateBuilderTest, EncodingTest_ExportedCertificateStringValues) {
    initializeCertRequestAndBuilder(FULL_PRINTABLE);
    certBuilder->alterSubject(rdn);
    RSAKeyPair key = RSAKeyPair(4096);
    Certificate* cert = certBuilder->sign(*key.getPrivateKey(), MessageDigest::SHA512);
    testStringValues(cert->getSubject());
}
/*!
 * @brief Testa se o certificado mantém a formatação após ser emitido.
 */
TEST_F(CertificateBuilderTest, EncodingTest_ExportedCertificateUTF8Codification) {
    initializeCertRequestAndBuilder(FULL_UTF8);
    certBuilder->alterSubject(rdn);
    RSAKeyPair key = RSAKeyPair(4096);
    Certificate* cert = certBuilder->sign(*key.getPrivateKey(), MessageDigest::SHA512);
    testStringCodificaton(V_ASN1_UTF8STRING, cert);
}
Example #3
0
    CryptoPP::RSA::PublicKey CardClient::initKeys(CryptoPP::RSA::PublicKey server_key)
    {
        CryptoPP::RSA::PublicKey pub;
        this->sec_server_key = server_key;

        if (file_exists("data/client-pub.key")) {
            pub = RSAKeyPair::loadPubKey("data/client-pub.key");
        } else {
            pub = card->initialize(this->sec_server_key);
            RSAKeyPair::saveKey("data/client-pub.key", pub);
        }

        this->key_pair = RSAKeyPair();
        this->key_pair.setPublic(pub);

        return pub;
    }
    /**
     * Construct a security server and generate a security server RSA key pair
     * @param string identity
     * @param string port_number
     */
    SecurityServer::SecurityServer(bytestring identity, std::string port_number)
    {
        this->id = identity;
        this->port = port_number;

        if (file_exists("data/server-priv.key") && file_exists("data/server-pub.key")) {
            CryptoPP::RSA::PublicKey pub = RSAKeyPair::loadPubKey("data/server-pub.key");
            CryptoPP::RSA::PrivateKey priv = RSAKeyPair::loadPrivKey("data/server-priv.key");
            this->key_pair = RSAKeyPair(pub, priv);
        } else {
            this->key_pair = this->generateKeyPair(RSAKeyPair::KeyLength);
            RSAKeyPair::saveKey("data/server-priv.key", this->key_pair.getPrivate());
            RSAKeyPair::saveKey("data/server-pub.key", this->key_pair.getPublic());
        }

        // terminal log color
        this->color = RED;
    }