public HMACNativeHashProvider(string hashAlgorithmId, ReadOnlySpan <byte> key)
        {
            Debug.Assert(Interop.BrowserCrypto.CanUseSubtleCrypto);

            (_hashAlgorithm, _hashSizeInBytes) = SHANativeHashProvider.HashAlgorithmToPal(hashAlgorithmId);
            _key = key.ToArray();
        }
        public static int MacDataOneShot(string hashAlgorithmId, ReadOnlySpan <byte> key, ReadOnlySpan <byte> data, Span <byte> destination)
        {
            (SimpleDigest hashName, int hashSizeInBytes) = SHANativeHashProvider.HashAlgorithmToPal(hashAlgorithmId);
            Debug.Assert(destination.Length >= hashSizeInBytes);

            Sign(hashName, key, data, destination);

            return(hashSizeInBytes);
        }
Exemplo n.º 3
0
        public static unsafe int MacDataOneShot(string hashAlgorithmId, ReadOnlySpan <byte> key, ReadOnlySpan <byte> data, Span <byte> destination)
        {
            (SimpleDigest hashName, int hashSizeInBytes) = SHANativeHashProvider.HashAlgorithmToPal(hashAlgorithmId);
            Debug.Assert(destination.Length >= hashSizeInBytes);

            fixed(byte *k = key)
            fixed(byte *src  = data)
            fixed(byte *dest = destination)
            {
                int res = Interop.BrowserCrypto.Sign(hashName, k, key.Length, src, data.Length, dest, destination.Length);

                Debug.Assert(res != 0);
            }

            return(hashSizeInBytes);
        }