[openssl-users] Help on basic EC programming
matt.loah at gmail.com
Tue Nov 24 18:46:12 UTC 2015
Hello all guys,
I'm a newbie... and going to understand the OpenSSL and the APIs involved
in, and even if I searched in the Net, there are two main question/subject
fields that I'd like to ask for.
1. Firstly, I wrote a little code that I don't know if it's really good
enough. So, comments, suggestions... will be greatly appreciated.
#define ECCTYPE "brainpoolP512t1"
int generate_keys (EC_KEY * ecc, EVP_PKEY * pkey)
if (EC_KEY_generate_key (ecc) <= 0)
if (EVP_PKEY_assign_EC_KEY (pkey, ecc) <= 0)
BIO * bp_public = BIO_new_file ("./key.pub.pem", "w+");
BIO * bp_private = BIO_new_file ("./key.prv.pem", "w+");
if (PEM_write_bio_PUBKEY (bp_public, pkey) <= 0)
if (PEM_write_bio_PrivateKey (bp_private, pkey, nullptr,
nullptr, 0, 0, nullptr) <= 0)
int retVal = 0;
EVP_PKEY * pkey = EVP_PKEY_new();
EC_KEY * ecc = EC_KEY_new_by_curve_name (OBJ_txt2nid (ECCTYPE));
retVal = generate_keys (ecc, pkey);
2. Secondly, I'd like to be able to work with these two generated keys... I
mean, encrypt, decrypt... but don't reach to understand how to use them and
which functions should be invoked ?
And also, I'd like to get the public/private keys... Should use
EC_KEY_get0_private_key() & EC_KEY_get0_public_key() functions ?
Any help will be also highly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the openssl-users