void ENGINE_register_all_ciphers() { ENGINE *e; for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) ENGINE_register_ciphers(e); }
static void rebuild_known_cipher_nids(ENGINE *e) { size_t i; for (i = 0, known_cipher_nids_amount = 0; i < OSSL_NELEM(cipher_data); i++) { if (devcrypto_test_cipher(i)) known_cipher_nids[known_cipher_nids_amount++] = cipher_data[i].nid; } ENGINE_unregister_ciphers(e); ENGINE_register_ciphers(e); }
int ENGINE_register_complete(ENGINE *e) { ENGINE_register_ciphers(e); ENGINE_register_digests(e); #ifndef OPENSSL_NO_RSA ENGINE_register_RSA(e); #endif #ifndef OPENSSL_NO_DSA ENGINE_register_DSA(e); #endif #ifndef OPENSSL_NO_DH ENGINE_register_DH(e); #endif #ifndef OPENSSL_NO_EC ENGINE_register_ECDH(e); ENGINE_register_ECDSA(e); #endif ENGINE_register_RAND(e); ENGINE_register_pkey_meths(e); return 1; }
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; };
static int bind_gost (ENGINE * e, const char *id) { int ret = 0; if (id && strcmp (id, engine_gost_id)) return 0; if (ameth_GostR3410_94) { printf ("GOST engine already loaded\n"); goto end; } if (!ENGINE_set_id (e, engine_gost_id)) { printf ("ENGINE_set_id failed\n"); goto end; } if (!ENGINE_set_name (e, engine_gost_name)) { printf ("ENGINE_set_name failed\n"); goto end; } if (!ENGINE_set_digests (e, gost_digests)) { printf ("ENGINE_set_digests failed\n"); goto end; } if (!ENGINE_set_ciphers (e, gost_ciphers)) { printf ("ENGINE_set_ciphers failed\n"); goto end; } if (!ENGINE_set_pkey_meths (e, gost_pkey_meths)) { printf ("ENGINE_set_pkey_meths failed\n"); goto end; } if (!ENGINE_set_pkey_asn1_meths (e, gost_pkey_asn1_meths)) { printf ("ENGINE_set_pkey_asn1_meths failed\n"); goto end; } /* Control function and commands */ if (!ENGINE_set_cmd_defns (e, gost_cmds)) { fprintf (stderr, "ENGINE_set_cmd_defns failed\n"); goto end; } if (!ENGINE_set_ctrl_function (e, gost_control_func)) { fprintf (stderr, "ENGINE_set_ctrl_func failed\n"); goto end; } if (!ENGINE_set_destroy_function (e, gost_engine_destroy) || !ENGINE_set_init_function (e, gost_engine_init) || !ENGINE_set_finish_function (e, gost_engine_finish)) { goto end; } if (!register_ameth_gost (NID_id_GostR3410_94, &ameth_GostR3410_94, "GOST94", "GOST R 34.10-94")) goto end; if (!register_ameth_gost (NID_id_GostR3410_2001, &ameth_GostR3410_2001, "GOST2001", "GOST R 34.10-2001")) goto end; if (!register_ameth_gost (NID_id_Gost28147_89_MAC, &ameth_Gost28147_MAC, "GOST-MAC", "GOST 28147-89 MAC")) goto end; if (!register_pmeth_gost (NID_id_GostR3410_94, &pmeth_GostR3410_94, 0)) goto end; if (!register_pmeth_gost (NID_id_GostR3410_2001, &pmeth_GostR3410_2001, 0)) goto end; if (!register_pmeth_gost (NID_id_Gost28147_89_MAC, &pmeth_Gost28147_MAC, 0)) goto end; if (!ENGINE_register_ciphers (e) || !ENGINE_register_digests (e) || !ENGINE_register_pkey_meths (e) /* These two actually should go in LIST_ADD command */ || !EVP_add_cipher (&cipher_gost) || !EVP_add_cipher (&cipher_gost_cpacnt) || !EVP_add_digest (&digest_gost) || !EVP_add_digest (&imit_gost_cpa)) { goto end; } ERR_load_GOST_strings (); ret = 1; end: return ret; }
ERL_NIF_TERM engine_register_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: if (!ENGINE_register_RSA(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_DSA case ENGINE_METHOD_DSA: if (!ENGINE_register_DSA(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_DH case ENGINE_METHOD_DH: if (!ENGINE_register_DH(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_RAND case ENGINE_METHOD_RAND: if (!ENGINE_register_RAND(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_ECDH case ENGINE_METHOD_ECDH: if (!ENGINE_register_ECDH(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_ECDSA case ENGINE_METHOD_ECDSA: if (!ENGINE_register_ECDSA(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_STORE case ENGINE_METHOD_STORE: if (!ENGINE_register_STORE(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_CIPHERS case ENGINE_METHOD_CIPHERS: if (!ENGINE_register_ciphers(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_DIGESTS case ENGINE_METHOD_DIGESTS: if (!ENGINE_register_digests(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_PKEY_METHS case ENGINE_METHOD_PKEY_METHS: if (!ENGINE_register_pkey_meths(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_PKEY_ASN1_METHS case ENGINE_METHOD_PKEY_ASN1_METHS: if (!ENGINE_register_pkey_asn1_meths(ctx->engine)) goto failed; break; #endif #ifdef ENGINE_METHOD_EC case ENGINE_METHOD_EC: if (!ENGINE_register_EC(ctx->engine)) goto failed; break; #endif default: return ERROR_Atom(env, "engine_method_not_supported"); } return atom_ok; bad_arg: return enif_make_badarg(env); failed: return ERROR_Atom(env, "register_engine_failed"); #else return atom_notsup; #endif }