Esempio n. 1
0
// Create the OpenSSL representation of the key
void OSSLDSAPublicKey::createOSSLKey()
{
	if (dsa != NULL) return;

	dsa = DSA_new();
	if (dsa == NULL)
	{
		ERROR_MSG("Could not create DSA object");
		return;
	}

	// Use the OpenSSL implementation and not any engine
#if OPENSSL_VERSION_NUMBER < 0x10100000L

#ifdef WITH_FIPS
	if (FIPS_mode())
		DSA_set_method(dsa, FIPS_dsa_openssl());
	else
		DSA_set_method(dsa, DSA_OpenSSL());
#else
	DSA_set_method(dsa, DSA_OpenSSL());
#endif

#else
	DSA_set_method(dsa, DSA_OpenSSL());
#endif

	BIGNUM* bn_p = OSSL::byteString2bn(p);
	BIGNUM* bn_q = OSSL::byteString2bn(q);
	BIGNUM* bn_g = OSSL::byteString2bn(g);
	BIGNUM* bn_pub_key = OSSL::byteString2bn(y);

	DSA_set0_pqg(dsa, bn_p, bn_q, bn_g);
	DSA_set0_key(dsa, bn_pub_key, NULL);
}
Esempio n. 2
0
const DSA_METHOD *DSA_get_default_method (void)
{
    if (!default_DSA_method)
    {
#ifdef OPENSSL_FIPS
        if (FIPS_mode ())
            return FIPS_dsa_openssl ();
        else
            return DSA_OpenSSL ();
#else
        default_DSA_method = DSA_OpenSSL ();
#endif
    }
    return default_DSA_method;
}