You need to think about a padding scheme for RSA encryption, for example
PKCS#1 block type 2 which is supported in openssl. You choose to not have
any extra padding if you understand the risks. You'll still want to have the
high order byte going into the RSA encryption forced to zero, to guarantee
unique decryption. Then, if your modulus is n bytes and your padding scheme
uses up k of these bytes, you have n-k bytes left for your RSA payload. Read
in your plaintext in chunks of n-k bytes and RSA encrypt them. This gives
you n bytes of cipher which you write out. Continue until EOF.
To decrypt, read in n bytes at a time. Decrypt the n bytes block and extract
the n-k bytes of plaintext.
Most folks use a hybrid technique that's faster.
Greg Stark, [EMAIL PROTECTED]
Chief Security Architect
Ethentica, Inc.
www.ethentica.com
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 11, 2001 10:24 AM
Subject: encrypt/decrypt large files
>
>
> Hi,
>
> I posted this question earlier but I wasnt a member of mailinglist so some
> things went wrong :(
>
>
> I want to encrypt a plaintext file (about 700Kb) en decrypt it later with
> RSA, ofcourse with the openssl lib
> Now i am able to encrypt chunks of 200 chars at a time but i cant figure
> out how the decrypt them.
> I write every encrypted chararray to disk after another.
>
> This is what i do :
>
> while (PTF != EOF)
> Read 200 chars from plaintext file (PTF)
> encrypt the 200 chars
> write the encrypted data to disk
> close PTF
> while (EDF != EOF)
> Read ??? chars from encrypted data file(EDF)
> decrypt the ??? chars
> write the plaintext to disk
> close EDF
>
> (org C++ code was not understandable for outsider, because of other
classes
> and stuff. That´s why i´ve written it in english instead of C code)
>
> Now my question : how do I know how much characters I have to read in to
> have a successfull decryption ??
> Or am I doing the complete encrypt/decrypt from and to file wrong ??
>
>
> With kind regards,
>
> Thijs Volders
>
>
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> User Support Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]