Beispiel #1
0
static ECDSA_DATA *
ECDSA_DATA_new_method(ENGINE *engine)
{
	ECDSA_DATA *ret;

	ret = malloc(sizeof(ECDSA_DATA));
	if (ret == NULL) {
		ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
		return (NULL);
	}

	ret->init = NULL;

	ret->meth = ECDSA_get_default_method();
	ret->engine = engine;
#ifndef OPENSSL_NO_ENGINE
	if (!ret->engine)
		ret->engine = ENGINE_get_default_ECDSA();
	if (ret->engine) {
		ret->meth = ENGINE_get_ECDSA(ret->engine);
		if (!ret->meth) {
			ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD,
			    ERR_R_ENGINE_LIB);
			ENGINE_finish(ret->engine);
			free(ret);
			return NULL;
		}
	}
#endif

	ret->flags = ret->meth->flags;
	CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data);
	return (ret);
}
Beispiel #2
0
static void suspend_engine(void *ctx,int *mem)
{
	ENGINE *e=(ENGINE *)ctx;

	*mem=0;

	if(ENGINE_get_default_RSA())
	{
		*mem|=0x01;
		ENGINE_unregister_RSA(e);
	}

	if(ENGINE_get_default_DSA())
	{
		*mem|=0x02;
		ENGINE_unregister_DSA(e);
	}

#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
	if(ENGINE_get_default_EC())
	{
		*mem|=0x04;
		ENGINE_unregister_EC(e);
	}
#else
	if(ENGINE_get_default_ECDH())
	{
		*mem|=0x04;
		ENGINE_unregister_ECDH(e);
	}

	if(ENGINE_get_default_ECDSA())
	{
		*mem|=0x08;
		ENGINE_unregister_ECDSA(e);
	}
#endif

	if(ENGINE_get_default_DH())
	{
		*mem|=0x10;
		ENGINE_unregister_DH(e);
	}

	if(ENGINE_get_default_RAND())
	{
		*mem|=0x20;
		ENGINE_unregister_RAND(e);
	}
}
Beispiel #3
0
Engine* Engines::getEngineDefault(Engine::Algorithm algorithm)
		throw (EngineException)
{
	ENGINE *eng = NULL;
	switch (algorithm)
	{
		case Engine::RSA:
			eng = ENGINE_get_default_RSA();
			break;
		case Engine::DSA:
			eng = ENGINE_get_default_DSA();
			break;
//		case Engines::DH:
//			e = ENGINE_get_default_DH();
//			break;
		case Engine::RAND:
			eng = ENGINE_get_default_RAND();
			break;
//		case Engine::ECDH:
//			e = ENGINE_get_default_ECDH();
//			break;
		case Engine::ECDSA:
			eng = ENGINE_get_default_ECDSA();
			break;
//		case Engine::CIPHERS:
//			e = ENGINE_get_default_CIPHERS();
//			break;
//		case Engine::DIGESTS:
//			e = ENGINE_get_default_DIGESTS();
//			break;
//		case Engine::STORE:
		case Engine::ALL:
		case Engine::NONE:
		default:
			break;
	}
	if (!eng)
	{
		throw EngineException(EngineException::ENGINE_NOT_FOUND, "Engines::getEngineDefault");
	}
	return new Engine(eng);
}