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([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))));
        }
Exemple #3
0
        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 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)))));
        }