Re: data size and RSA encryption
From: Valery Pryamikov (valery_at_harper.no)
Date: 09/19/05
- Next message: Tim Wallace: "Re: data size and RSA encryption"
- Previous message: Stephen Noronha: "Re: Windows authentication only"
- In reply to: Tim Wallace: "data size and RSA encryption"
- Next in thread: Tim Wallace: "Re: data size and RSA encryption"
- Reply: Tim Wallace: "Re: data size and RSA encryption"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 19 Sep 2005 20:16:36 +0200
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: Tim Wallace: "Re: data size and RSA encryption"
- Previous message: Stephen Noronha: "Re: Windows authentication only"
- In reply to: Tim Wallace: "data size and RSA encryption"
- Next in thread: Tim Wallace: "Re: data size and RSA encryption"
- Reply: Tim Wallace: "Re: data size and RSA encryption"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|