public bool Verify([ReadOnlyArray] byte[] signature, [ReadOnlyArray] byte[] securedInput, object key) { var publicKey = Ensure.Type <ICryptographicKey>(key, "RsaUsingSha expects key to be of type 'ICryptographicKey'"); //reattach key to alg provider byte[] keyBlob = publicKey.ExportPublicKey(CryptographicPublicKeyBlobType.Pkcs1RsaPublicKey); ICryptographicKey cKey = AlgProvider.ImportPublicKey(keyBlob, CryptographicPublicKeyBlobType.Pkcs1RsaPublicKey); return(WinRTCrypto.CryptographicEngine.VerifySignature(cKey, securedInput, signature)); }
public bool Verify([ReadOnlyArray] byte[] signature, [ReadOnlyArray] byte[] securedInput, object key) { var publicKey = Ensure.Type <CryptographicKey>(key, "EcdsaUsingSha expects key to be of type 'CryptographicKey'"); IBuffer msg = CryptographicBuffer.CreateFromByteArray(securedInput); IBuffer sig = CryptographicBuffer.CreateFromByteArray(signature); //reattach key to alg provider IBuffer keyBlob = publicKey.ExportPublicKey(CryptographicPublicKeyBlobType.BCryptPublicKey); CryptographicKey cKey = AlgProvider.ImportPublicKey(keyBlob, CryptographicPublicKeyBlobType.BCryptPublicKey); return(CryptographicEngine.VerifySignature(cKey, msg, sig)); }
public Part[] WrapNewKey(uint cekSizeBits, object key, JsonObject header) { var publicKey = Ensure.Type <CryptographicKey>(key, "RsaUsingSha expects key to be of type 'CryptographicKey'"); IBuffer cek = CryptographicBuffer.GenerateRandom(cekSizeBits >> 3); //reattach key to alg provider IBuffer keyBlob = publicKey.ExportPublicKey(CryptographicPublicKeyBlobType.BCryptPublicKey); CryptographicKey cKey = AlgProvider.ImportPublicKey(keyBlob, CryptographicPublicKeyBlobType.BCryptPublicKey); IBuffer encryptedCek = CryptographicEngine.Encrypt(cKey, cek, null); return(new [] { new Part(Buffer.ToBytes(cek)), new Part(Buffer.ToBytes(encryptedCek)) }); }