Ok i've got this simple code to encrypt a msg with a private key. When i run the app it crashes. Any help?
#include <stdio.h>
#include <string.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
int main()
{
char keyy[] = "Private key here";
unsigned char *key = (unsigned char* )keyy;
printf("%d\n",sizeof(keyy));
RSA *public_key = d2i_RSAPrivateKey(NULL, (const unsigned char**)&key, 1589);
char message[] = "magic";
unsigned char *encrypted = (unsigned char *) malloc(5000);
unsigned char *decrypted = (unsigned char *) malloc(5000);
printf("%s\n",key);
RSA_private_encrypt(strlen(message), (unsigned char *) message, encrypted, public_key, RSA_PKCS1_PADDING); // crashes here
return 0;
}