/* ----------------------------------------------------------------*/ int register_pmeth_gost(int id, EVP_PKEY_METHOD **pmeth, int flags) { *pmeth = EVP_PKEY_meth_new(id, flags); if (!*pmeth) return 0; switch (id) { case NID_id_GostR3410_94: EVP_PKEY_meth_set_ctrl(*pmeth, pkey_gost_ctrl, pkey_gost_ctrl94_str); EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost94cp_keygen); EVP_PKEY_meth_set_sign(*pmeth, NULL, pkey_gost94_cp_sign); EVP_PKEY_meth_set_verify(*pmeth, NULL, pkey_gost94_cp_verify); EVP_PKEY_meth_set_encrypt(*pmeth, pkey_gost_encrypt_init, pkey_GOST94cp_encrypt); EVP_PKEY_meth_set_decrypt(*pmeth, NULL, pkey_GOST94cp_decrypt); EVP_PKEY_meth_set_derive(*pmeth, pkey_gost_derive_init, pkey_gost94_derive); EVP_PKEY_meth_set_paramgen(*pmeth, pkey_gost_paramgen_init, pkey_gost94_paramgen); break; case NID_id_GostR3410_2001: EVP_PKEY_meth_set_ctrl(*pmeth, pkey_gost_ctrl, pkey_gost_ctrl01_str); EVP_PKEY_meth_set_sign(*pmeth, NULL, pkey_gost01_cp_sign); EVP_PKEY_meth_set_verify(*pmeth, NULL, pkey_gost01_cp_verify); EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost01cp_keygen); EVP_PKEY_meth_set_encrypt(*pmeth, pkey_gost_encrypt_init, pkey_GOST01cp_encrypt); EVP_PKEY_meth_set_decrypt(*pmeth, NULL, pkey_GOST01cp_decrypt); EVP_PKEY_meth_set_derive(*pmeth, pkey_gost_derive_init, pkey_gost2001_derive); EVP_PKEY_meth_set_paramgen(*pmeth, pkey_gost_paramgen_init, pkey_gost01_paramgen); break; case NID_id_Gost28147_89_MAC: EVP_PKEY_meth_set_ctrl(*pmeth, pkey_gost_mac_ctrl, pkey_gost_mac_ctrl_str); EVP_PKEY_meth_set_signctx(*pmeth, pkey_gost_mac_signctx_init, pkey_gost_mac_signctx); EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost_mac_keygen); EVP_PKEY_meth_set_init(*pmeth, pkey_gost_mac_init); EVP_PKEY_meth_set_cleanup(*pmeth, pkey_gost_mac_cleanup); EVP_PKEY_meth_set_copy(*pmeth, pkey_gost_mac_copy); return 1; default: /* Unsupported method */ return 0; } EVP_PKEY_meth_set_init(*pmeth, pkey_gost_init); EVP_PKEY_meth_set_cleanup(*pmeth, pkey_gost_cleanup); EVP_PKEY_meth_set_copy(*pmeth, pkey_gost_copy); /* * FIXME derive etc... */ return 1; }
//This function tells openssl what pkey operations are supported by our engine for specific algorithm int register_pmeth_gost(int id, EVP_PKEY_METHOD **pmeth, int flags) { *pmeth = EVP_PKEY_meth_new(id, flags); if (!*pmeth) return 0; if (id == NID_hmac_sha1) { EVP_PKEY_meth_set_ctrl(*pmeth, pkey_gost_mac_ctrl, pkey_gost_mac_ctrl_str); //required if algorithm supports commands EVP_PKEY_meth_set_signctx(*pmeth, pkey_gost_mac_signctx_init, pkey_gost_mac_signctx); //required - sets resulting sign in context EVP_PKEY_meth_set_keygen(*pmeth, NULL, pkey_gost_mac_keygen); //required - sets (or generates) pkey EVP_PKEY_meth_set_init(*pmeth, pkey_gost_mac_init); //required - creates context EVP_PKEY_meth_set_cleanup(*pmeth, pkey_gost_mac_cleanup); EVP_PKEY_meth_set_copy(*pmeth,pkey_gost_mac_copy); return 1; } return 0; }
static int ossl_register_hmac_meth(void) { EVP_PKEY_METHOD *meth; meth = EVP_PKEY_meth_new(EVP_PKEY_HMAC, 0); if (meth == NULL) return 0; EVP_PKEY_meth_set_init(meth, ossl_hmac_init); EVP_PKEY_meth_set_copy(meth, ossl_hmac_copy); EVP_PKEY_meth_set_cleanup(meth, ossl_hmac_cleanup); EVP_PKEY_meth_set_keygen(meth, 0, ossl_hmac_keygen); EVP_PKEY_meth_set_signctx(meth, ossl_hmac_signctx_init, ossl_hmac_signctx); EVP_PKEY_meth_set_ctrl(meth, ossl_hmac_ctrl, ossl_hmac_ctrl_str); ossl_hmac_meth = meth; return 1; }
int Everest_init(ENGINE *e) { // Initialize the global variables needed for BCrypt if (!NT_SUCCESS(BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_ECDH_ALGORITHM, NULL, 0))) { fprintf(stderr, "Cannot open algorithm provider\n"); return 0; } if (!NT_SUCCESS(BCryptSetProperty(hAlg, BCRYPT_ECC_CURVE_NAME, (PUCHAR) BCRYPT_ECC_CURVE_25519, sizeof(BCRYPT_ECC_CURVE_25519), 0))) { fprintf(stderr, "Cannot select the right curve\n"); return 0; } // Initialize our new method bcrypt_x25519_meth = EVP_PKEY_meth_new(NID_X25519, 0); EVP_PKEY_meth_set_derive(bcrypt_x25519_meth, NULL, bcrypt_derive); EVP_PKEY_meth_set_ctrl(bcrypt_x25519_meth, bcrypt_ctrl, NULL); EVP_PKEY_meth_set_keygen(bcrypt_x25519_meth, NULL, bcrypt_keygen); return 1; }