How to load an RSA key from binary data to an RSA structure using the OpenSSL C Library?
Posted
by Andreas Bonini
on Stack Overflow
See other posts from Stack Overflow
or by Andreas Bonini
Published on 2010-03-19T13:22:45Z
Indexed on
2010/03/19
13:41 UTC
Read the original article
Hit count: 253
Currently I have my private key saved in a file, private.key, and I use the following function to load it:
RSA *r = PEM_read_RSAPrivateKey("private.key", NULL, NULL, NULL);
This works perfectly but I'm not happy with the file-based format; I want to save my key in pure binary form (ie, no base64 or similar) in a char*
variable and load/save the key from/to it. This way I have much more freedom: I'll be able to store the key directly into the application const char key[] { 0x01, 0x02, ... };
, send it over a network socket, etc.
Unfortunately though I haven't found a way to do that. The only way to save and load a key I know of reads/saves it to a file directly.
© Stack Overflow or respective owner