For those who are banging their heads on how you can use the public key stored in the certificate in the WinRT application, let me ease your pain: you cannot, at least not directly.
The AsymmetricKeyAlgorithmProvider.ImportPublicKey function accepts IBuffer and CryptographicPublicKeyBlobType, KeyBlob (IBuffer) is the public key of the certificate, not the full certificate, only its public key.
But you cannot get the public key of the certificate without parsing it first, here's the problem: there is no way to parse the certificate on WinRT, given that the most used class for this task, X509Certificate, is not available and is not its namespace, but the means for certificates should only be used for web service connections.
The only workaround is to implement a certificate parser or migrate such functions from an open source project, such as Bouncy Castle . So, if you know one, leave it in the comments.
By the way, to export the public key from a certificate (in plain .NET) in a format that can be used in a WinRT application, use this:
X509Certificate2 Certificate; .... byte[] CertificatePublicKey = Certificate.PublicKey.EncodedKeyValue.RawData;
Then in a WinRT application use this:
AsymmetricKeyAlgorithmProvider algorithm = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaSignPkcs1Sha1); IBuffer KeyBuffer = CryptographicBuffer.DecodeFromBase64String(CertificatePublicKeyContent); CryptographicKey key = algorithm.ImportPublicKey(KeyBuffer, CryptographicPublicKeyBlobType.Pkcs1RsaPublicKey);
Note that I first encoded the public key in base 64, but you can use raw binary data instead (there are more methods for this CryptographicBuffer class).