RE: Error Encrytping Symmetric key with RSA Public Key

2008-09-30 Thread Bill Colvin
The answer is in: data too large for key size

According to Secure Programming Cookbook, when using RSA PKCS #1 v1.5
padding you can only encrypt messages up to 11 bytes smaller than the
modulus size in bytes.  If you are using RSA-1024, then that is
(1024/8)-11=117 bytes.

Bill

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of William Estrada
Sent: September 30, 2008 4:31 PM
To: openssl-users@openssl.org
Subject: Error Encrytping Symmetric key with RSA Public Key

Hi group,

  I have written a simple program to test my understanding of the 
OpenSSL APIs.
And of course I have a problem with one of them. My problem is that when

I use
RSA_public_encrypt to encrypt my Symmetric key is get the following
error:

 Testing RSA encryption of Symmertic key
 145 Encrypt In bytes:  128, 
 149 Encript failed:
 Code: 67555438
 error:0406D06E
 rsa routines:RSA_padding_add_PKCS1_type_2
 data too large for key size

   The program first generates a Symmetric key, then uses it to encrypt
and 
decrypt some simple text that the user inputs. Next it create an RSA Key
and
a public RSA key. then the same with these keys. The last thing tested
is the
encryption of the Symmetric Key using the RSA keys which fails.  The
error
message does not make any sense to me since the Sym key is only 128
bytes.

 I would appreciate any help with my problem. All of the code is here:

http://64.124.13.3/_OpenSSL_/Keys/

  Thanks for your time.

-- 
William Estrada
[EMAIL PROTECTED]
Mt-Umunhum-Wireless.net ( http://Mt-Umunhum-Wireless.net )
Ymessenger: MrUmunhum


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: Error Encrytping Symmetric key with RSA Public Key

2008-09-30 Thread William Estrada

Bill,

 You are 100% right. I increased my buffer from 1024 to 1115 and it 
works fine

now. I guess I should RTFM more?

 Thanks.



Bill Colvin wrote:

The answer is in: data too large for key size

According to Secure Programming Cookbook, when using RSA PKCS #1 v1.5
padding you can only encrypt messages up to 11 bytes smaller than the
modulus size in bytes.  If you are using RSA-1024, then that is
(1024/8)-11=117 bytes.

Bill

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of William Estrada
Sent: September 30, 2008 4:31 PM
To: openssl-users@openssl.org
Subject: Error Encrytping Symmetric key with RSA Public Key

Hi group,

  I have written a simple program to test my understanding of the 
OpenSSL APIs.

And of course I have a problem with one of them. My problem is that when

I use
RSA_public_encrypt to encrypt my Symmetric key is get the following
error:

  

Testing RSA encryption of Symmertic key
145 Encrypt In bytes:  128, 
149 Encript failed:

Code: 67555438
error:0406D06E
rsa routines:RSA_padding_add_PKCS1_type_2
data too large for key size



   The program first generates a Symmetric key, then uses it to encrypt
and 
decrypt some simple text that the user inputs. Next it create an RSA Key

and
a public RSA key. then the same with these keys. The last thing tested
is the
encryption of the Symmetric Key using the RSA keys which fails.  The
error
message does not make any sense to me since the Sym key is only 128
bytes.

 I would appreciate any help with my problem. All of the code is here:

http://64.124.13.3/_OpenSSL_/Keys/

  Thanks for your time.

  



--
William Estrada
[EMAIL PROTECTED]
Mt-Umunhum-Wireless.net ( http://Mt-Umunhum-Wireless.net )
Ymessenger: MrUmunhum


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]