public AppleHmacProvider(string hashAlgorithmId, ReadOnlySpan <byte> key)
            {
                PAL_HashAlgorithm algorithm = HashAlgorithmNames.HashAlgorithmToPal(hashAlgorithmId);

                _liteHmac = new LiteHmac(algorithm, key, preinitialize: false);
                _key      = key.ToArray();
            }
Esempio n. 2
0
        internal static int HmacStream(
            string hashAlgorithmId,
            int hashSizeInBytes,
            ReadOnlySpan <byte> key,
            Stream source,
            Span <byte> destination)
        {
            LiteHmac hash = CreateHmac(hashAlgorithmId, key);

            return(ProcessStream(hash, source, destination));
        }
Esempio n. 3
0
        internal static byte[] HmacStream(
            string hashAlgorithmId,
            int hashSizeInBytes,
            ReadOnlySpan <byte> key,
            Stream source)
        {
            byte[]   result  = new byte[hashSizeInBytes];
            LiteHmac hash    = CreateHmac(hashAlgorithmId, key);
            int      written = ProcessStream(hash, source, result);

            Debug.Assert(written == hashSizeInBytes);
            return(result);
        }
Esempio n. 4
0
        internal static ValueTask <byte[]> HmacStreamAsync(
            string hashAlgorithmId,
            int hashSizeInBytes,
            ReadOnlySpan <byte> key,
            Stream source,
            CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(ValueTask.FromCanceled <byte[]>(cancellationToken));
            }

            LiteHmac hash = CreateHmac(hashAlgorithmId, key);

            return(ProcessStreamAsync(hash, source, cancellationToken));
        }
Esempio n. 5
0
 public HmacHashProvider(string hashAlgorithmId, ReadOnlySpan <byte> key)
 {
     _liteHmac = LiteHashProvider.CreateHmac(hashAlgorithmId, key);
 }