Basically when we encrypt something using an RSA key (whether public or private), the encrypted value must be smaller than the key (due to the maths used to do the actual encryption). So if you have a 1024-bit key, in theory we could encrypt any 1023-bit value (or a 1024-bit value smaller than the key) with that key.
below is the code snippet i am trying to do AES Encryption. it works fine. if i see some example in openssl they are using KEY value EVP_MAX_KEY_LENGTH(32 bytes). can i use RSA public key(1024 bit) to encrypt the same value and use private to decrypt the value. int main(int argc, char* argv[]) { unsigned char outbuf2[1024]; unsigned char outbuf[1024]; int outlen, outlen2, tmplen; unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; unsigned char iv[] = {1,2,3,4,5,6,7,8}; char intext[] = "string to make the random number generator think it has entropy"; // Straight encrypt EVP_CIPHER_CTX x; EVP_CIPHER_CTX_init(&x); if(!EVP_EncryptInit_ex(&x, EVP_aes_256_cbc(), NULL, key, iv)) printf("\n ERROR!! \n"); if(!EVP_EncryptUpdate(&x, outbuf, &outlen,(const unsigned char*) intext, strlen(intext))) printf("\n ERROR!! \n"); if(!EVP_EncryptFinal_ex(&x,outbuf+outlen,&tmplen)) printf("\n ERROR!! \n"); outlen+=tmplen; } EVP_CIPHER_CTX_cleanup(&x); Thanks, Krishnamurthy