I am currently working with PCLCrypto and have been looking for a way to mimic the System.Security.Cryptography.RSACryptoServiceProvider SignData function. Currently I am using this code to create :
var mac = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithm.RsaSignPkcs1Sha512);
var cryptoKey = mac.CreateKeyPair(2048);
var hash = WinRTCrypto.CryptographicEngine.Sign(cryptoKey, input);
return WinRTCrypto.CryptographicBuffer.EncodeToBase64String(hash);
This is the code I am using to verify the signature:
var mac = WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithm.RsaSignPkcs1Sha512);
var keyMaterial = WinRTCrypto.CryptographicBuffer.ConvertStringToBinary(key, Encoding.UTF8);
var cryptoKey = mac.ImportPublicKey(keyMaterial, CryptographicPublicKeyBlobType.X509SubjectPublicKeyInfo);
return WinRTCrypto.CryptographicEngine.VerifySignature(cryptoKey, data, signature);
To be clear, I am 100% confident that I am using the correct keypair. My key is in the following format:
<RSAKeyValue><Modulus>nMhF8TRjT5O7tTtqr1//9ahokRuNGRxdGwc7fwk+i21Zscr/7L0PlfiE/sTQC/VQrj/BHhkX8CXVMTw1ukSN7zZDD7UCbdvhmV7jhPs/TDJP70Y4pgcG624WnQXjWDgR5f7Mbfg18zsevidtGukK+U5huaBfxhxg2Za3X3JzUYc=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
Could someone point me to an example which produces the same output as the RSACryptoServiceProvider?
I actually figured it out by myself, apparently it had some problems importing a key which was specified in the xml format. My current solution which produces the desired result: