Пример #1
0
        public EcdhKeyWrapper(ECJwk key, EncryptionAlgorithm encryptionAlgorithm, KeyManagementAlgorithm algorithm)
            : base(encryptionAlgorithm, algorithm)
        {
            Debug.Assert(key.SupportKeyManagement(algorithm));
            Debug.Assert(algorithm.Category == AlgorithmCategory.EllipticCurve);
            _key = key;
            if (algorithm.WrappedAlgorithm is null)
            {
                _algorithm      = encryptionAlgorithm.Name;
                _keySizeInBytes = encryptionAlgorithm.RequiredKeySizeInBytes;
            }
            else
            {
                _algorithm              = algorithm.Name;
                _keySizeInBytes         = algorithm.WrappedAlgorithm.RequiredKeySizeInBits >> 3;
                _keyManagementAlgorithm = algorithm.WrappedAlgorithm;
            }

            _algorithmNameLength = _algorithm.EncodedUtf8Bytes.Length;
            _hashAlgorithm       = GetHashAlgorithm(encryptionAlgorithm);
        }