public byte[] Sign([ReadOnlyArray] byte[] securedInput, object key) { var sharedKey = Ensure.Type <byte[]>(key, "HmacUsingSha expects key to be byte[] array."); CryptographicKey hmacKey = AlgProvider.CreateKey(CryptographicBuffer.CreateFromByteArray(sharedKey)); return(Buffer.ToBytes(CryptographicEngine.Sign(hmacKey, CryptographicBuffer.CreateFromByteArray(securedInput)))); }
public bool Verify([ReadOnlyArray] byte[] signature, [ReadOnlyArray] byte[] securedInput, object key) { var sharedKey = Ensure.Type <byte[]>(key, "HmacUsingSha expects key to be byte[] array."); var hmacKey = AlgProvider.CreateKey(sharedKey); return(WinRTCrypto.CryptographicEngine.VerifySignature(hmacKey, securedInput, signature)); }
public byte[] Sign(byte[] securedInput, object key) #endif { var sharedKey = Ensure.Type <byte[]>(key, "HmacUsingSha expects key to be byte[] array."); var hmacKey = AlgProvider.CreateKey(sharedKey); return(WinRTCrypto.CryptographicEngine.Sign(hmacKey, securedInput)); }
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 byte[] Sign([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.Export(CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey); ICryptographicKey cKey = AlgProvider.ImportKeyPair(keyBlob, CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey); return(WinRTCrypto.CryptographicEngine.Sign(cKey, securedInput)); }
public bool Verify([ReadOnlyArray] byte[] signature, [ReadOnlyArray] byte[] securedInput, object key) { var sharedKey = Ensure.Type <byte[]>(key, "HmacUsingSha expects key to be byte[] array."); IBuffer msg = CryptographicBuffer.CreateFromByteArray(securedInput); IBuffer hmac = CryptographicBuffer.CreateFromByteArray(signature); CryptographicKey hmacKey = AlgProvider.CreateKey(CryptographicBuffer.CreateFromByteArray(sharedKey)); return(CryptographicEngine.VerifySignature(hmacKey, msg, hmac)); }
private byte[] ComputeAuthTag(byte[] aad, byte[] iv, byte[] cipherText, byte[] key) { byte[] al = Arrays.LongToBytes(aad.Length * 8); byte[] hmacInput = Arrays.Concat(aad, iv, cipherText, al); CryptographicKey hmacKey = AlgProvider.CreateKey(CryptographicBuffer.CreateFromByteArray(key)); return(Arrays.FirstHalf( Buffer.ToBytes(CryptographicEngine.Sign(hmacKey, CryptographicBuffer.CreateFromByteArray(hmacInput))))); }
public byte[] Sign([ReadOnlyArray] byte[] securedInput, object key) { var publicKey = Ensure.Type <CryptographicKey>(key, "RsaPssUsingSha expects key to be of type 'CryptographicKey'"); IBuffer msg = CryptographicBuffer.CreateFromByteArray(securedInput); //reattach key to alg provider IBuffer keyBlob = publicKey.Export(CryptographicPrivateKeyBlobType.BCryptPrivateKey); CryptographicKey cKey = AlgProvider.ImportKeyPair(keyBlob, CryptographicPrivateKeyBlobType.BCryptPrivateKey); return(Buffer.ToBytes(CryptographicEngine.Sign(cKey, msg))); }
public byte[] Unwrap([ReadOnlyArray] byte[] encryptedCek, object key, uint cekSizeBits, JsonObject header) { var privateKey = Ensure.Type <CryptographicKey>(key, "RsaUsingSha expects key to be of type 'CryptographicKey'"); IBuffer msg = CryptographicBuffer.CreateFromByteArray(encryptedCek); //reattach key to alg provider IBuffer keyBlob = privateKey.Export(CryptographicPrivateKeyBlobType.BCryptPrivateKey); CryptographicKey cKey = AlgProvider.ImportKeyPair(keyBlob, CryptographicPrivateKeyBlobType.BCryptPrivateKey); return(Buffer.ToBytes(CryptographicEngine.Decrypt(cKey, msg, null))); }
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)) }); }