Hi,
I'm trying to encrypt some data with rsa. The RSA_SIZE of my key is 128. The data can be more than 128 bit. So my idea was to encrypt the data using a loop which encrypts 128 bytes at once. I've read that there could be problems if the length is bigger than RSA_SIZE-1. So I set blockLength to RSA_SIZE-11. The length of data in this example is less than 256 so the encrypted data has a size of 256 (with padding). This is the encryption-code: int blockLength = RSA_size(rsa)-11; // (see below) int padding = RSA_PKCS1_PADDING; int clen=blockLength; // encrypt blockwise, size: RSA_SIZE-11 (( see documentation) for (unsigned int left=0; left< flen ; left+=blockLength) { if(left+clen>flen) { clen = flen - left; } l=RSA_private_encrypt(blockLength, /// <-- how big should this be ?????????? (unsigned char*) value.mid(left,clen).data(), to+left , rsa, padding); if(l<=0) { printf("RSA Encrpytion Error.\n"); } else { *len+=l; } } And this is the decryption code: int blockLength = RSA_size(rsa); // -11 int padding = RSA_PKCS1_PADDING; unsigned char to[KEYLEN+1]=""; // KEYLEN = 256 int flen = KEYLEN;//RSA_size(rsa); for (unsigned int left=0; left< flen ; left+=blockLength) { l = RSA_public_decrypt(blockLength-11, binkey+left, to+left, rsa, padding); if(l<=0) { printf("RSA Decryption Error."); } else { len+=l; } printf("Decrypted %d bytes",len); } ERR_print_errors_fp(stdout); Encryption is working fine, but I get -1 in as result of RSA_public_decrypt. This is the message from ERR_print_errors(): 6364:error:0407006A:lib(4):func(112):reason(106):rsa_pk1.c:100: 6364:error:04067072:lib(4):func(103):reason(114):rsa_eay.c:430: 6364:error:0407006A:lib(4):func(112):reason(106):rsa_pk1.c:100: 6364:error:04067072:lib(4):func(103):reason(114):rsa_eay.c:430: What am I doing wrong? Is there a problem with padding? Thanks in advance M.Schmid -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]