Esempio n. 1
0
        /// <summary>
        ///     Complete the hash, returning its value
        /// </summary>
        public byte[] HashFinal()
        {
            Contract.Ensures(Contract.Result <byte[]>() != null);
            Contract.Assert(m_hashHandle != null);

            return(CapiNative.GetHashParameter(m_hashHandle, CapiNative.HashParameter.HashValue));
        }
Esempio n. 2
0
        /*
         * SafeCritical - we're not exposing out anything that we want to prevent untrusted code from getting at
         */
        public CapiHashAlgorithm(
            string provider,
            CapiNative.ProviderType providerType,
            CapiNative.AlgorithmId algorithm)
        {
            Contract.Requires(!string.IsNullOrEmpty(provider));
            Contract.Requires((CapiNative.AlgorithmClass)((uint)algorithm & (uint)CapiNative.AlgorithmClass.Hash) == CapiNative.AlgorithmClass.Hash);

            m_algorithmId = algorithm;
            m_cspHandle   = CapiNative.AcquireCsp(null,
                                                  provider,
                                                  providerType,
                                                  CapiNative.CryptAcquireContextFlags.VerifyContext,
                                                  true);
            m_hashHandle = Initialize();
        }