Hi, i am new to OpenSSL..i have to use RSA_generate key function to generate key..below is the program and outcome..is this the way to generate key?
#include<stdio.h> #include<openssl/rsa.h> #include<string.h> int main() { char *plain="Sample text"; //Sample text (plain text) to Encrypt/Decrypt char *ciphertext; printf("%s\n",plain); // Generate RSA key RSA *rsa1= RSA_generate_key(1024,65537,NULL,NULL); // RSA_size() will determine how much memory must be allocated for an if(rsa1==NULL) { printf("NO RSA!\n\n"); ERR_load_crypto_strings(); ERR_print_errors_fp(stdout); } else { printf("RSA OK!\n"); } ciphertext = (char *)malloc(RSA_size(rsa1)); printf("rsa key = %d\n",rsa1); printf("RSA size = %d\n",RSA_size(rsa1)); RSA_free(rsa1); } $ gcc -o rsa1 rsa1.c -lcrypto Output --------- $ ./rsa1 Sample text RSA OK! rsa key = 473608208 RSA size = 128 Please correct me if i am missing anything .. kris