Windows Store App in C# using PEM key

1

I have a Bluetooth device I'm connecting to that has a public key installed on it which it uses to encrypt the data it sends back to to my C# Win 8.1 Store App. On the app side I have a PEM private key supplied by the vendor of the bluetooth device.

Can C#, in the confines of a Windows Store App, use a PEM file? Or does it need to be converted to something and installed into Cert Manaer?

Update:

var pemKey = "-----BEGIN RSA PRIVATE KEY----- ..... -----END RSA PRIVATE KEY-----";
try
{
    var pemKeyBuffer = CryptographicBuffer.ConvertStringToBinary(pemKey, BinaryStringEncoding.Utf8);
    objAlgProv.ImportKeyPair(pemKeyBuffer);
}
catch (Exception importKeyEx)
{
    ShowException("Error Importing Key: +" + importKeyEx, "Error Importing Key");
    return;
}

This throws the exception:

An error occurred during encode or decode operation. (Exception from HRESULT: 0x80092002)
c#
cryptography
windows-store-apps
asked on Stack Overflow Sep 18, 2014 by Greg Gorman • edited Sep 18, 2014 by Greg Gorman

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0