Exemple #1
0
        protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
        {
            // we're sealed and the base should have checked this before calling us
            Debug.Assert(data != null);
            Debug.Assert(!String.IsNullOrEmpty(hashAlgorithm.Name));

            using (BCryptHashAlgorithm hasher = new BCryptHashAlgorithm(new CngAlgorithm(hashAlgorithm.Name), BCryptNative.ProviderName.MicrosoftPrimitiveProvider)) {
                hasher.HashStream(data);
                return(hasher.HashFinal());
            }
        }
Exemple #2
0
 public byte[] SignData(Stream data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     using (BCryptHashAlgorithm algorithm = new BCryptHashAlgorithm(this.HashAlgorithm, "Microsoft Primitive Provider"))
     {
         algorithm.HashStream(data);
         byte[] hash = algorithm.HashFinal();
         return(this.SignHash(hash));
     }
 }
Exemple #3
0
        public byte[] SignData(Stream data)
        {
            Contract.Ensures(Contract.Result <byte[]>() != null);

            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            using (BCryptHashAlgorithm hashAlgorithm = new BCryptHashAlgorithm(HashAlgorithm, BCryptNative.ProviderName.MicrosoftPrimitiveProvider)) {
                hashAlgorithm.HashStream(data);
                byte[] hashValue = hashAlgorithm.HashFinal();

                return(SignHash(hashValue));
            }
        }
Exemple #4
0
 public bool VerifyData(Stream data, byte[] signature)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (signature == null)
     {
         throw new ArgumentNullException("signature");
     }
     using (BCryptHashAlgorithm algorithm = new BCryptHashAlgorithm(this.HashAlgorithm, "Microsoft Primitive Provider"))
     {
         algorithm.HashStream(data);
         byte[] hash = algorithm.HashFinal();
         return(this.VerifyHash(hash, signature));
     }
 }
Exemple #5
0
        public bool VerifyData(Stream data, byte[] signature)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (signature == null)
            {
                throw new ArgumentNullException("signature");
            }

            using (BCryptHashAlgorithm hashAlgorithm = new BCryptHashAlgorithm(HashAlgorithm, BCryptNative.ProviderName.MicrosoftPrimitiveProvider)) {
                hashAlgorithm.HashStream(data);
                byte[] hashValue = hashAlgorithm.HashFinal();

                return(VerifyHash(hashValue, signature));
            }
        }
        public bool VerifyData(Stream data, byte[] signature) {
            if (data == null) {
                throw new ArgumentNullException("data");
            }
            if (signature == null) {
                throw new ArgumentNullException("signature");
            }

            using (BCryptHashAlgorithm hashAlgorithm = new BCryptHashAlgorithm(HashAlgorithm, BCryptNative.ProviderName.MicrosoftPrimitiveProvider)) {
                hashAlgorithm.HashStream(data);
                byte[] hashValue = hashAlgorithm.HashFinal();

                return VerifyHash(hashValue, signature);
            }
        }
        public byte[] SignData(Stream data) {
            Contract.Ensures(Contract.Result<byte[]>() != null);

            if (data == null) {
                throw new ArgumentNullException("data");
            }

            using (BCryptHashAlgorithm hashAlgorithm = new BCryptHashAlgorithm(HashAlgorithm, BCryptNative.ProviderName.MicrosoftPrimitiveProvider)) {
                hashAlgorithm.HashStream(data);
                byte[] hashValue = hashAlgorithm.HashFinal();

                return SignHash(hashValue);
            }
        }
Exemple #8
0
        protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
        {
            // We're sealed and the base should have checked these alread.
            Debug.Assert(data != null);
            Debug.Assert(!String.IsNullOrEmpty(hashAlgorithm.Name));

            using (BCryptHashAlgorithm hasher = new BCryptHashAlgorithm(new CngAlgorithm(hashAlgorithm.Name), BCryptNative.ProviderName.MicrosoftPrimitiveProvider))
            {
                hasher.HashStream(data);
                return hasher.HashFinal();
            }
        }
 public byte[] SignData(Stream data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     using (BCryptHashAlgorithm algorithm = new BCryptHashAlgorithm(this.HashAlgorithm, "Microsoft Primitive Provider"))
     {
         algorithm.HashStream(data);
         byte[] hash = algorithm.HashFinal();
         return this.SignHash(hash);
     }
 }
 public bool VerifyData(Stream data, byte[] signature)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (signature == null)
     {
         throw new ArgumentNullException("signature");
     }
     using (BCryptHashAlgorithm algorithm = new BCryptHashAlgorithm(this.HashAlgorithm, "Microsoft Primitive Provider"))
     {
         algorithm.HashStream(data);
         byte[] hash = algorithm.HashFinal();
         return this.VerifyHash(hash, signature);
     }
 }