Created
February 14, 2019 05:53
-
-
Save devendranaga/58df06084a8763463ebc8f89124fe259 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int load_privkey(std::string privkey) | |
{ | |
FILE *fp; | |
fp = fopen(privkey.c_str(), "r"); | |
if (!fp) { | |
return -1; | |
} | |
privatekey = PEM_read_ECPrivateKey(fp, NULL, NULL, NULL); | |
if (!privatekey) { | |
ERR_print_errors_fp(stderr); | |
return -1; | |
} | |
// validate the key | |
EC_KEY_check_key(privatekey); | |
evp_sign_key = EVP_PKEY_new(); | |
int ret; | |
ret = EVP_PKEY_assign_EC_KEY(evp_sign_key, privatekey); | |
if (ret != 1) { | |
ERR_print_errors_fp(stderr); | |
return -1; | |
} | |
fclose(fp); | |
std::cout << "privkey load ok" << std::endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment