RSA_size(RSA *) told you the max length of every RSA encryption needed. RSA encryption is not designed to encrypt the large files because of its high cost.It is common to use a symmetric algorithm to encrypt the large data and the RSA algorithm is used to encrypt the key that the symmetric algorithm needed.
If you want to use RSA to encrypt large files, you may seperate the file into ceil(FILE_SIZE%RSA_size(key)) pieces and each piece has a length of RSA_size(key)(which is the length of you buffer).Then, you need to encrypt each pieces. Note, In my experience, the length of the RSA encryptin's output is not always the same.It may be impossible for you to decrpt your files.So I think you should use a fixed block size for each of your encryption text. At 2011-10-18 22:13:15,"Jonas Schnelli" <jonas.schne...@include7.ch> wrote: >Hi > >I search the mailarchives as well as stackoverflow for a answer. No success. > >I just want to know how large my out-buffer must be when doing a >RSA_public_encrypt. >In the docs i read the size must be RSA_size(RSA *). >In my case i'd like to encrypt files. So i read the whole file into a >mem-buffer. > >So how large should i malloc my out-buffer? > >Or do you use any other function to encrypt files with a RSA public key? > >Thanks >-- >Jonas > >______________________________________________________________________ >OpenSSL Project http://www.openssl.org >User Support Mailing List openssl-users@openssl.org >Automated List Manager majord...@openssl.org