public BCryptHashAlgorithm(CngAlgorithm algorithm, string implementation)
        {
            Contract.Requires(algorithm != null);
            Contract.Requires(!String.IsNullOrEmpty(implementation));
            Contract.Ensures(m_algorithmHandle != null && !m_algorithmHandle.IsInvalid && !m_algorithmHandle.IsClosed);
            Contract.Ensures(m_hashHandle != null && !m_hashHandle.IsInvalid && !m_hashHandle.IsClosed);

            if (_algorithmCache == null)
            {
                _algorithmCache = new BCryptAlgorithmHandleCache();
            }

            m_algorithmHandle = _algorithmCache.GetCachedAlgorithmHandle(algorithm.Algorithm, implementation);

            Initialize();
        }
        public BCryptHashAlgorithm(CngAlgorithm algorithm, string implementation) {
            Contract.Requires(algorithm != null);
            Contract.Requires(!String.IsNullOrEmpty(implementation));
            Contract.Ensures(m_algorithmHandle != null && !m_algorithmHandle.IsInvalid && !m_algorithmHandle.IsClosed);
            Contract.Ensures(m_hashHandle != null && !m_hashHandle.IsInvalid && !m_hashHandle.IsClosed);

            // Make sure CNG is supported on this platform
            if (!BCryptNative.BCryptSupported) {
                throw new PlatformNotSupportedException(SR.GetString(SR.Cryptography_PlatformNotSupported));
            }

            if (_algorithmCache == null)
            {
                _algorithmCache = new BCryptAlgorithmHandleCache();
            }

            m_algorithmHandle = _algorithmCache.GetCachedAlgorithmHandle(algorithm.Algorithm, implementation);

            Initialize();
        }
Пример #3
0
        public BCryptHashAlgorithm(CngAlgorithm algorithm, string implementation)
        {
            Contract.Requires(algorithm != null);
            Contract.Requires(!String.IsNullOrEmpty(implementation));
            Contract.Ensures(m_algorithmHandle != null && !m_algorithmHandle.IsInvalid && !m_algorithmHandle.IsClosed);
            Contract.Ensures(m_hashHandle != null && !m_hashHandle.IsInvalid && !m_hashHandle.IsClosed);

            // Make sure CNG is supported on this platform
            if (!BCryptNative.BCryptSupported)
            {
                throw new PlatformNotSupportedException("SR.Cryptography_PlatformNotSupported");
            }

            if (_algorithmCache == null)
            {
                _algorithmCache = new BCryptAlgorithmHandleCache();
            }

            m_algorithmHandle = _algorithmCache.GetCachedAlgorithmHandle(algorithm.Algorithm, implementation);

            Initialize();
        }