Hi all,
How can I encrypt a large file (like 100mb) with a public key so that no one other than who has the private key be able to decrypt it?
I can make RSA public and private keys but when it comes to encrypting a large file using this command:
openssl rsautl -encrypt -pubin -inkey public.pem -in myLargeFile.txt -out myLargeFile_encrypted.txt
I get this error:
RSA operation error
3020:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:.\crypto\rsa\rsa_pk1.c:151:
I tried to make keys with sizes from 40 to 4096 bits, no luck, same error
Thankx in advance
Amir
--
Sent from the OpenSSL - User forum at Nabble.com:
http://www.nabble.com/How-to-encrypt-a-large-file-by-a-public-key--t724858.html#a1900225
------=_Part_42_30220025.1134355795442
Content-Type: text/html; charset=UTF8
Content-Transfer-Encoding: 7bit
Hi all,
<br>
<br>How can I encrypt a large file (like 100mb) with a public key so that no one other than who has the private key be able to decrypt it?
<br>
<br>I can make RSA public and private keys but when it comes to encrypting a large file using this command:
<br>
<br>openssl rsautl -encrypt -pubin -inkey public.pem -in myLargeFile.txt -out myLargeFile_encrypted.txt
<br>
<br>I get this error:
<br>
<br>RSA operation error
<br>3020:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:.\crypto\rsa\rsa_pk1.c:151:
<br>
<br>I tried to make keys with sizes from 40 to 4096 bits, no luck, same error
<br>
<br>Thankx in advance
<br>
<br>Amir
<br>
<br>
<br><hr align="left" width="300">
Sent from the <a href="http://www.nabble.com/OpenSSL---User-f981.html">OpenSSL - User</a> forum at Nabble.com:<br>
<a href="http://www.nabble.com/How-to-encrypt-a-large-file-by-a-public-key--t724858.html#a1900225">How to encrypt a large file by a public key?</a>
------=_Part_42_30220025.1134355795442--
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org
Encrypt it using a strong symmetric key (such as AES) and use RSA to
encrypt *that* key.
This is the way "everyone" does it.
/r$
--
SOA Appliance Group
IBM Application Integration Middleware
With RSA, the data to be encrypted is first mapped on to an integer. For
RSA to work, this integer must be smaller than the RSA modulus used. In
order to get things to work the way you want, if you are using a (say)
1,024-bit RSA modulus, you must split your input data in chunks 1,024 bits
long, at most. Actually, if using padding, which you you should, they've go=
t
to be even smaller - e.g. 11 bytes smaller for PKCS #1 v1.5 padding. You
then would have to encrypt each chunk sequentially, using a mode like ECB o=
r
CBC.
Having said all that, you should not proceed that way. RSA
encryption/decryption is tremendously slow and CPU intensive. You'd be far
better off encrypting your big input file with some symmetric algorithm (e.=
g.
AES) and then encrypting with the RSA key (private or public, depending on
your needs) the key used with this algorithm.
On 12/11/05, Amir (sent by Nabble.com) <li...@nabble.com> wrote:
>
> Hi all,
>
> How can I encrypt a large file (like 100mb) with a public key so that no
> one other than who has the private key be able to decrypt it?
>
> I can make RSA public and private keys but when it comes to encrypting a
> large file using this command:
>
> openssl rsautl -encrypt -pubin -inkey public.pem -in myLargeFile.txt -out
> myLargeFile_encrypted.txt
>
> I get this error:
>
> RSA operation error
> 3020:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too
> large for key size:.\crypto\rsa\rsa_pk1.c:151:
>
> I tried to make keys with sizes from 40 to 4096 bits, no luck, same error
>
> Thankx in advance
>
> Amir
>
>
> ------------------------------
> Sent from the OpenSSL - User<http://www.nabble.com/OpenSSL---User-f981.ht=
ml>forum at
> Nabble.com:
> How to encrypt a large file by a public key?<http://www.nabble.com/How-to=
-encrypt-a-large-file-by-a-public-key--t724858.html#a1900225>
------=_Part_13753_23904184.1134400356393
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
With RSA, the data to be encrypted is first mapped on to
an integer. For RSA to work, this integer must be smaller than the RSA
modulus used. In order to get things to work the way you want, if you
are using a (say) 1,024-bit RSA modulus, you must split your input data
in chunks 1,024 bits long, at most. Actually, if using padding, which
you you should, they've got to be even smaller - e.g. 11 bytes smaller
for PKCS #1 v1.5 padding. You then would have to encrypt each chunk
sequentially, using a mode like ECB or CBC.<br>
<br>
Having said all that, you should not proceed that way. RSA
encryption/decryption is tremendously slow and CPU intensive. You'd be
far better off encrypting your big input file with some symmetric
algorithm (e.g. AES) and then encrypting with the RSA key (private or
public, depending on your needs) the key used with this algorithm.<br>
<br><br><div><span class=3D"gmail_quote">On 12/11/05, <b class=3D"gmail_sen=
dername">Amir (sent by <a href=3D"http://Nabble.com">Nabble.com</a>)</b> &l=
t;<a href=3D"mailto:li...@nabble.com">li...@nabble.com</a>> wrote:</span=
><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204,=
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,
<br>
<br>How can I encrypt a large file (like 100mb) with a public key so
that no one other than who has the private key be able to decrypt it?
<br>
<br>I can make RSA public and private keys but when it comes to encrypting =
a large file using this command:
<br>
<br>openssl rsautl -encrypt -pubin -inkey public.pem -in myLargeFile.txt -o=
ut myLargeFile_encrypted.txt
<br>
<br>I get this error:
<br>
<br>RSA operation error
<br>3020:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too =
large for key size:.\crypto\rsa\rsa_pk1.c:151:
<br>
<br>I tried to make keys with sizes from 40 to 4096 bits, no luck, same err=
or
<br>
<br>Thankx in advance
<br>
<br>Amir
<br>
<br>
<br><hr align=3D"left" width=3D"300">
Sent from the <a href=3D"http://www.nabble.com/OpenSSL---User-f981.html" ta=
rget=3D"_blank" onclick=3D"return top.js.OpenExtLink(window,event,this)">Op=
enSSL - User</a> forum at <a href=3D"http://Nabble.com" target=3D"_blank" o=
nclick=3D"return top.js.OpenExtLink(window,event,this)">
Nabble.com</a>:<br>
<a href=3D"http://www.nabble.com/How-to-encrypt-a-large-file-by-a-public-ke=
y--t724858.html#a1900225" target=3D"_blank" onclick=3D"return top.js.OpenEx=
tLink(window,event,this)">How to encrypt a large file by a public key?</a>
</blockquote></div><br>
------=_Part_13753_23904184.1134400356393--