예제 #1
0
        public SymmetricSigner(ReadOnlySpan <byte> key, SignatureAlgorithm algorithm)
            : base(algorithm)
        {
            Debug.Assert(algorithm.Category == AlgorithmCategory.Hmac);
            if (key.Length << 3 < MinimumKeySizeInBits)
            {
                ThrowHelper.ThrowArgumentOutOfRangeException_AlgorithmRequireMinimumKeySize(key.Length << 3, algorithm.Name.ToString(), MinimumKeySizeInBits);
            }

            _hashSizeInBytes       = Algorithm.RequiredKeySizeInBits >> 2;
            _base64HashSizeInBytes = Base64Url.GetArraySizeRequiredToEncode(_hashSizeInBytes);
            _hashAlgorithm         = new HmacSha2(algorithm.Sha, key);
        }