NTE_BAD_KEY - RSA Cryptography
From: casey chesnut (casey_at_braSPAMins-N-braSPAMwn.com)
Date: 05/25/04
- Next message: casey chesnut: "Re: NTE_BAD_KEY - RSA Cryptography"
- Previous message: Jon Skeet [C# MVP]: "MissingMethodException with MulticastDelegate"
- Next in thread: casey chesnut: "Re: NTE_BAD_KEY - RSA Cryptography"
- Reply: casey chesnut: "Re: NTE_BAD_KEY - RSA Cryptography"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 May 2004 10:04:46 -0500
i've received a couple questions regarding RSA and this error.
for code like the following:
using OpenNETCF.Security.Cryptography;
RSACryptoServiceProvider rsa = new
RSACryptoServiceProvider(KeySpec.KEYEXCHANGE, true);
string txtPublicKey = rsa.ToXmlString(false);
string txtPrivateKey = rsa.ToXmlString(true);
string str = "this is some text to encrypt";
RSACryptoServiceProvider rsa1 = new RSACryptoServiceProvider();
rsa1.FromXmlString(txtPublicKey);
byte[] encryptedStrAsBytes =
rsa1.EncryptValue(Encoding.Unicode.GetBytes(str));
string encryptedStrAsString =
Encoding.Unicode.GetString(encryptedStrAsBytes, 0,
encryptedStrAsBytes.Length);
RSACryptoServiceProvider rsa2 = new RSACryptoServiceProvider();
rsa2.FromXmlString(txtPrivateKey);
byte [] decVal =
rsa2.DecryptValue(Encoding.Unicode.GetBytes(encryptedStrAsString));
string origVal = Encoding.Unicode.GetString(decVal, 0, decVal.Length);
this works for me on PPC 2003 emulator, and device, SP 2003 emu, and device.
chances are this is failing because you are on a PPC 2002 emulator,
because it does not have the high encryption pack installed.
the bNb.Sec.Context class has a property you can check:
bNb.Sec.Context.IsEnhanced
this will let you know if the Enhanced Crypto is installed on the device,
so that you can do pub/priv key encryption and signing.
Thanks,
casey
http://www.brains-N-brawn.com
- Next message: casey chesnut: "Re: NTE_BAD_KEY - RSA Cryptography"
- Previous message: Jon Skeet [C# MVP]: "MissingMethodException with MulticastDelegate"
- Next in thread: casey chesnut: "Re: NTE_BAD_KEY - RSA Cryptography"
- Reply: casey chesnut: "Re: NTE_BAD_KEY - RSA Cryptography"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|