Re: data size and RSA encryption
From: Tim Wallace (twallace-ThisDoesNotBelong-AT-emailDOTcom)
Date: 09/19/05
- Next message: Dominick Baier [DevelopMentor]: "Re: Windows authentication only"
- Previous message: Valery Pryamikov: "Re: data size and RSA encryption"
- In reply to: Valery Pryamikov: "Re: data size and RSA encryption"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
>>
>
- Next message: Dominick Baier [DevelopMentor]: "Re: Windows authentication only"
- Previous message: Valery Pryamikov: "Re: data size and RSA encryption"
- In reply to: Valery Pryamikov: "Re: data size and RSA encryption"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|