|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
data size and RSA encryptionfor 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 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 Show quoteHide quote "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 > 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 Show quoteHide quote "Valery Pryamikov" <val***@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 >> >
Importance of salt
Anonymous access + Windows Authentication Strong Names Secure??? Windows authentication only xml based AzMan and ActiveDirectory Is WindowsPrincipal is Remotable ? Unable to run c++ .net executable from a network drive hooked to server Windows Security pops up when executing javascript in an asp.net p Delegation across trusted domains .NET 2.0: code access security / authentication |
|||||||||||||||||||||||