Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonweeks/e6ce641298698f91fb4fac1f84505cdd to your computer and use it in GitHub Desktop.
Save brandonweeks/e6ce641298698f91fb4fac1f84505cdd to your computer and use it in GitHub Desktop.
// Find the type (e.g. RSA) of the EVP_PKEY we've been provided.
let pkey_type = EVP_PKEY_type(EVP_PKEY_id(pkey));
// Create a new EVP_PKEY_METHOD.
let pmeth = EVP_PKEY_meth_new(pkey_type, 0);
// Find the default EVP_PKEY_METHOD for the type.
let default_method = EVP_PKEY_meth_find(pkey_type);
// Copy the default method into ours.
EVP_PKEY_meth_copy(pmeth, default_method);
// Overwrite _just_ the {sign_init, sign} methods.
EVP_PKEY_meth_set_sign(pmeth, sign_init, sign);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment