OpenNetCF Cryptography Error

G

gcrasher

I am using the OpenNETCF.Security.Cryptography classes on a Dell Axim
running PocketPC 2003 and I am getting a NTE_NO_KEY error when trying
to use the RSACryptoServiceProvider class. The code runs fine on the
desktop but gives this error on the device and emulator. Code is
nothing special:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(rsaPrivKey);
byte[] rgbPlaintext = rsa.DecryptValue(ciphertext);

I am able to decrypt using RC2CryptoServiceProvider on the emulator
(have to still try the device but I assume it would work). The author
of this code had posted before to check the bNb.Sec.Context.IsEnhanced
flag, and it is returning true on the emulator but the code still does
not work. Has anyone been able to get RSA encryption working with
PocketPC 2003? If so I am wondering why I would be getting this error?
 
C

casey chesnut

RSA is a public / private key cryptography (so is DSA).
both RSA and DSA store the keys in the registry.
since the Context is showing that your environment has the enhanced
CryptoApi,
then my guess is that it is failing at the registry.
you will probably have to create that key in the registry once.
try constructing it as new RSACryptoServiceProvider(KeySpec.Exchange, true);
the true flag will tell it to generate a new key.
then it should work thereafter.

DES, RC2, and TripleDES are secret key cyrpto,
they do not store values in the registry.

i've been using that code extensively on PPC 2003 and SP 2003 devices and
emulators.
RSACryptoServiceProvider is used in the WSE 2.0 code.
i mostly run from the device, because the emulators will get in a bad state
periodically.

Thanks,
casey
http://www.brains-N-brawn.com
 
G

gcrasher

I did not understand that the device required the keys in the
registry, I'm sure this will work now. Thanks alot!


casey chesnut said:
RSA is a public / private key cryptography (so is DSA).
both RSA and DSA store the keys in the registry.
since the Context is showing that your environment has the enhanced
CryptoApi,
then my guess is that it is failing at the registry.
you will probably have to create that key in the registry once.
try constructing it as new RSACryptoServiceProvider(KeySpec.Exchange, true);
the true flag will tell it to generate a new key.
then it should work thereafter.

DES, RC2, and TripleDES are secret key cyrpto,
they do not store values in the registry.

i've been using that code extensively on PPC 2003 and SP 2003 devices and
emulators.
RSACryptoServiceProvider is used in the WSE 2.0 code.
i mostly run from the device, because the emulators will get in a bad state
periodically.

Thanks,
casey
http://www.brains-N-brawn.com


gcrasher said:
I am using the OpenNETCF.Security.Cryptography classes on a Dell Axim
running PocketPC 2003 and I am getting a NTE_NO_KEY error when trying
to use the RSACryptoServiceProvider class. The code runs fine on the
desktop but gives this error on the device and emulator. Code is
nothing special:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(rsaPrivKey);
byte[] rgbPlaintext = rsa.DecryptValue(ciphertext);

I am able to decrypt using RC2CryptoServiceProvider on the emulator
(have to still try the device but I assume it would work). The author
of this code had posted before to check the bNb.Sec.Context.IsEnhanced
flag, and it is returning true on the emulator but the code still does
not work. Has anyone been able to get RSA encryption working with
PocketPC 2003? If so I am wondering why I would be getting this error?
 
C

casey chesnut

storing those keys in the registry is just the nature of the CryptoApi.
the desktop does the same thing, although they handle initialization better.

please let me know if that helps.

Thanks,
casey

gcrasher said:
I did not understand that the device required the keys in the
registry, I'm sure this will work now. Thanks alot!


"casey chesnut" <casey@MORE_spam_PLEASEbrains-N-brawn.com> wrote in
message news: said:
RSA is a public / private key cryptography (so is DSA).
both RSA and DSA store the keys in the registry.
since the Context is showing that your environment has the enhanced
CryptoApi,
then my guess is that it is failing at the registry.
you will probably have to create that key in the registry once.
try constructing it as new RSACryptoServiceProvider(KeySpec.Exchange, true);
the true flag will tell it to generate a new key.
then it should work thereafter.

DES, RC2, and TripleDES are secret key cyrpto,
they do not store values in the registry.

i've been using that code extensively on PPC 2003 and SP 2003 devices and
emulators.
RSACryptoServiceProvider is used in the WSE 2.0 code.
i mostly run from the device, because the emulators will get in a bad state
periodically.

Thanks,
casey
http://www.brains-N-brawn.com


gcrasher said:
I am using the OpenNETCF.Security.Cryptography classes on a Dell Axim
running PocketPC 2003 and I am getting a NTE_NO_KEY error when trying
to use the RSACryptoServiceProvider class. The code runs fine on the
desktop but gives this error on the device and emulator. Code is
nothing special:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(rsaPrivKey);
byte[] rgbPlaintext = rsa.DecryptValue(ciphertext);

I am able to decrypt using RC2CryptoServiceProvider on the emulator
(have to still try the device but I assume it would work). The author
of this code had posted before to check the bNb.Sec.Context.IsEnhanced
flag, and it is returning true on the emulator but the code still does
not work. Has anyone been able to get RSA encryption working with
PocketPC 2003? If so I am wondering why I would be getting this error?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top