I have the following code:
#include <openssl/bn.h>
#include <openssl/rsa.h>
unsigned char* key;
RSA* rsa = RSA_new();
rsa = RSA_generate_key(1024,65537,NULL,NULL);
//init pubkey
key[BN_num_bytes(rsa->n)] = ;
BN_bn2bin(rsa->n, key);
printf("RSA Pub: %s
", key);
RSA_free( rsa );
rsa = NULL;
The debugger is telling me that I have an issue "Access violation writing location" on the line
key[BN_num_bytes(rsa->n)] = ;
If I comment out that line the issue just moves down to
BN_bn2bin(rsa->n, key);
any suggestions on how to fix this issue would be great.