コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HmacSha2"/> class.
        /// </summary>
        /// <param name="sha2"></param>
        /// <param name="key"></param>
        protected HmacSha2(Sha2 sha2, ReadOnlySpan <byte> key)
        {
            if (sha2 is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sha);
            }

            Sha2         = sha2;
            _keys        = new byte[BlockSize * 2];
            _innerPadKey = new ReadOnlyMemory <byte>(_keys, 0, BlockSize);
            _outerPadKey = new ReadOnlyMemory <byte>(_keys, BlockSize, BlockSize);
            if (key.Length > BlockSize)
            {
                Span <byte> keyPrime = stackalloc byte[sha2.HashSize];
                Sha2.ComputeHash(key, keyPrime, default, default);
コード例 #2
0
ファイル: Sha2Extensions.cs プロジェクト: MortalFlesh/Jwt
 public static void ComputeHash(this Sha2 sha2, ReadOnlySpan <byte> source, Span <byte> destination)
 {
     sha2.ComputeHash(source, destination, default, default);