示例#1
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);
	}
}
示例#2
0
static int openssl_engine_register(lua_State*L)
{
  ENGINE* eng = CHECK_OBJECT(1, ENGINE, "openssl.engine");
  int unregister = 0;
  int first = 2;
  int top = lua_gettop(L);
  if (lua_isboolean(L, 2))
  {
    unregister = lua_toboolean(L, 2);
    first = 3;
  };
  while (first <= top)
  {
    int c = luaL_checkoption(L, first, "RSA", list);
    switch (c)
    {
    case TYPE_RSA:
      if (unregister)
        ENGINE_unregister_RSA(eng);
      else
        ENGINE_register_RSA(eng);
      break;
    case TYPE_DSA:
      if (unregister)
        ENGINE_unregister_DSA(eng);
      else
        ENGINE_register_DSA(eng);
      break;
    case TYPE_ECDH:
      if (unregister)
        ENGINE_unregister_ECDH(eng);
      else
        ENGINE_register_ECDH(eng);
      break;
    case TYPE_ECDSA:
      if (unregister)
        ENGINE_unregister_ECDSA(eng);
      else
        ENGINE_register_ECDSA(eng);
      break;
    case TYPE_DH:
      if (unregister)
        ENGINE_unregister_DH(eng);
      else
        ENGINE_register_DH(eng);
      break;
    case TYPE_RAND:
      if (unregister)
        ENGINE_unregister_RAND(eng);
      else
        ENGINE_register_RAND(eng);
      break;
    case TYPE_STORE:
      if (unregister)
        ENGINE_unregister_STORE(eng);
      else
        ENGINE_register_STORE(eng);
      break;
    case TYPE_CIPHERS:
      if (unregister)
        ENGINE_unregister_ciphers(eng);
      else
        ENGINE_register_ciphers(eng);
      break;
    case TYPE_DIGESTS:
      if (unregister)
        ENGINE_unregister_digests(eng);
      else
        ENGINE_register_digests(eng);
      break;
    case TYPE_COMPLETE:
    {
      int ret = ENGINE_register_complete(eng);
      lua_pushboolean(L, ret);
      return 1;
      break;
    }
    default:
      luaL_error(L, "not support %d for %s", c, list[c]);
      break;
    }
    first++;
  }
  return 0;
};
示例#3
0
文件: engine.c 项目: bjorng/otp
ERL_NIF_TERM engine_unregister_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (Engine, EngineMethod) */
#ifdef HAS_ENGINE_SUPPORT
    struct engine_ctx *ctx;
    unsigned int method;

    // Get Engine
    ASSERT(argc == 2);

    if (!enif_get_resource(env, argv[0], engine_ctx_rtype, (void**)&ctx))
        goto bad_arg;
    if (!enif_get_uint(env, argv[1], &method))
        goto bad_arg;

    switch(method)
    {
#ifdef ENGINE_METHOD_RSA
    case ENGINE_METHOD_RSA:
        ENGINE_unregister_RSA(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_DSA
    case ENGINE_METHOD_DSA:
        ENGINE_unregister_DSA(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_DH
    case ENGINE_METHOD_DH:
        ENGINE_unregister_DH(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_RAND
    case ENGINE_METHOD_RAND:
        ENGINE_unregister_RAND(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_ECDH
    case ENGINE_METHOD_ECDH:
        ENGINE_unregister_ECDH(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_ECDSA
    case ENGINE_METHOD_ECDSA:
        ENGINE_unregister_ECDSA(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_STORE
    case ENGINE_METHOD_STORE:
        ENGINE_unregister_STORE(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_CIPHERS
    case ENGINE_METHOD_CIPHERS:
        ENGINE_unregister_ciphers(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_DIGESTS
    case ENGINE_METHOD_DIGESTS:
        ENGINE_unregister_digests(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_PKEY_METHS
    case ENGINE_METHOD_PKEY_METHS:
        ENGINE_unregister_pkey_meths(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_PKEY_ASN1_METHS
    case ENGINE_METHOD_PKEY_ASN1_METHS:
        ENGINE_unregister_pkey_asn1_meths(ctx->engine);
        break;
#endif
#ifdef ENGINE_METHOD_EC
    case ENGINE_METHOD_EC:
        ENGINE_unregister_EC(ctx->engine);
        break;
#endif
    default:
        break;
    }

    return atom_ok;

 bad_arg:
    return enif_make_badarg(env);

#else
    return atom_notsup;
#endif
}