Re: data size and RSA encryption

From: Tim Wallace (twallace-ThisDoesNotBelong-AT-emailDOTcom)
Date: 09/19/05


Date: Mon, 19 Sep 2005 14:29:24 -0400

Valery:

Thank you for your reply. Usage notwithstanding, what would cause this
error? I'm encrypting much less than if I were to be encrypting a symmetric
key. Any thoughts?

Tim

"Valery Pryamikov" <valery@harper.no> wrote in message
news:urStbZUvFHA.3080@tk2msftngp13.phx.gbl...
> Tim,
> you should not use RSA for encrypting data, but rather use it for
> encrypting symmetric encryption key that you use for encrypting your data
> (as it for eg. done here:
> http://msdn.microsoft.com/library/en-us/cpguide/html/cpcongeneratingkeysforencryptiondecryption.asp
> or here:
> http://msdn.microsoft.com/library/en-us/dncapi/html/encryptdecrypt2a.asp).
> I would not comment on the rest of your post - since I've only briefly
> looked over your code.
>
> -Valery.
> http://www.harper.no/valery
>
> "Tim Wallace" <twallace-ThisDoesNotBelong-AT-emailDOTcom> wrote in message
> news:uP2SOgTvFHA.2312@TK2MSFTNGP14.phx.gbl...
>>I am getting an error stating "...data to be encrypted exceeds the maximum
>>for this modulus of 256 bytes". I am at a loss as to how this could be,
>>as I'm only attempting to encrypt less than 30 characters. Does anyone
>>have any ideas as to what could cause this error? I'm creating my keys in
>>a separate application like so:
>>
>> RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048);
>> string rsaXml = rsa.ToXmlString(true);
>> StreamWriter sw = new StreamWriter("c:\\some_file_ name.key");
>> sw.Write( rsaXml );
>> sw.Close();
>>
>> Then, in the application where I encrypt, I do it like so:
>>
>> RSACryptoServiceProvider rsacspServer = new
>> RSACryptoServiceProvider(2048);
>> string rsaXml = string.Empty;
>> StreamReader sr = new StreamReader("c:\\some_file_name.key");
>> rsaXml = sr.ReadToEnd();
>> sr.Close();
>> rsacspServer.FromXmlString(rsaXml);
>>
>> Next, I encrypt like this: rsacspServer.Encrypt( a, false ); // a is a
>> byte[]
>>
>> Over in the app that is decrypting (the bytes are being sent using
>> TCPClient), I do the same as the encrytion, save for calling Decrypt.
>>
>> Any ideas?
>>
>> Tim
>>
>



Relevant Pages

  • Re: data size and RSA encryption
    ... you should not use RSA for encrypting data, but rather use it for encrypting ... > TCPClient), I do the same as the encrytion, save for calling Decrypt. ...
    (microsoft.public.dotnet.security)
  • Re: Diffie-Hellman for data encryption
    ... a key has to be exchanged *before* a secure channel is ... and not for encrypting bulk data. ... encrypting data with AES? ... The resulting DHKeys are identical for both parties, ...
    (sci.crypt)
  • Re: Storing confidential data - suggestions please
    ... What options do I have for encrypting data? ... Windows has an Encrypted File System and Vista Ultimate has BitLocker both of which would appear to require less user intervention. ... Anyone in the UK can no have failed to notice the recent cock-up of government departments in loosing CDs and laptops which have large amounts of confidential data. ...
    (comp.unix.solaris)
  • Re: Decrypting plaintext rather than encrypting it
    ... Since operations are symmetric, instead of encrypting data, ... then decrypting it, one could imagine that data in the clear ... recover the plain text. ...
    (sci.crypt)
  • Re: Local System user to use EFS
    ... I want to add the certificate myself and ... > then point it out with the CertificateHash in the registry to tell the ... > System to use it when encrypting. ... carefully and take all the necessary precautions when encrypting data ...
    (microsoft.public.windowsxp.security_admin)