I have encrypted a message using RSA algorithm in C programming language. I want to encrypt multiple files which is kept in a particular folder using same key. Iam working in openSSL environment. The code that i used to encrypt a particular message is,
// Get the message to encrypt
printf("Message to encrypt: ");
fgets(msg, KEY_LENGTH-1, stdin);
msg[strlen(msg)-1] = '\0';
// Encrypt the message
encrypt = malloc(RSA_size(keypair));
int encrypt_len;
err = malloc(130);
if((encrypt_len = RSA_public_encrypt(strlen(msg)+1, (unsigned char*)msg, (unsigned char*)encrypt,
keypair, RSA_PKCS1_OAEP_PADDING)) == -1) {
ERR_load_crypto_strings();
ERR_error_string(ERR_get_error(), err);
fprintf(stderr, "Error encrypting message: %s\n", err);
goto free_stuff;
}
Now i want to use RSA algorithm to encrypt a folder which contains many files using the same public key in C
Thanks in advance!