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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…