Last active
February 26, 2018 18:02
-
-
Save klali/129af62d360f6d5c59c184bf22dd9aeb to your computer and use it in GitHub Desktop.
add a namned group of secp521r1 to an ec key
This file contains 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
#include <stdio.h> | |
#include <openssl/ec.h> | |
#include <openssl/pem.h> | |
int main(int argc, char **argv) { | |
if(argc != 2) { | |
printf("give key as arg\n"); | |
exit(1); | |
} | |
FILE *key = fopen(argv[1], "r"); | |
EVP_PKEY *pkey = PEM_read_PrivateKey(key, NULL, NULL, NULL); | |
EC_KEY *eckey = EVP_PKEY_get1_EC_KEY(pkey); | |
EC_GROUP *ngroup = EC_GROUP_new_by_curve_name(NID_secp521r1); | |
EC_GROUP_set_asn1_flag(ngroup, 1); | |
EC_KEY_set_group(eckey, ngroup); | |
PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
compile with something like:
$ gcc eccconv.c -lcrypto