/// <summary>
 /// Verifies the signature of a hash value.
 /// </summary>
 public bool VerifyData(byte[] buffer, object halg, byte[] signature)
 {
     int calgHash = CapiHelper.ObjToHashAlgId(halg);
     HashAlgorithm hash = CapiHelper.ObjToHashAlgorithm(halg);
     byte[] hashVal = hash.ComputeHash(buffer);
     return VerifyHash(hashVal, calgHash, signature);
 }
 /// <summary>
 /// Computes the hash value of a subset of the specified byte array using the
 /// specified hash algorithm, and signs the resulting hash value.
 /// </summary>
 /// <param name="inputStream">The input data for which to compute the hash</param>
 /// <param name="halg">The hash algorithm to use to create the hash value. </param>
 /// <returns>The RSA signature for the specified data.</returns>
 public byte[] SignData(Stream inputStream, object halg)
 {
     int calgHash = CapiHelper.ObjToHashAlgId(halg);
     HashAlgorithm hash = CapiHelper.ObjToHashAlgorithm(halg);
     byte[] hashVal = hash.ComputeHash(inputStream);
     return SignHash(hashVal, calgHash);
 }
 /// <summary>
 /// Computes the hash value of a subset of the specified byte array using the
 /// specified hash algorithm, and signs the resulting hash value.
 /// </summary>
 /// <param name="buffer">The input data for which to compute the hash</param>
 /// <param name="halg">The hash algorithm to use to create the hash value. </param>
 /// <returns>The RSA signature for the specified data.</returns>
 public byte[] SignData(byte[] buffer, object halg)
 {
     int calgHash = CapiHelper.ObjToHashAlgId(halg);
     HashAlgorithm hash = CapiHelper.ObjToHashAlgorithm(halg);
     byte[] hashVal = hash.ComputeHash(buffer);
     return SignHash(hashVal, calgHash);
 }
        /// <summary>
        /// Verifies the signature of a hash value.
        /// </summary>
        public bool VerifyData(byte[] buffer, object halg, byte[] signature)
        {
            int calgHash = CapiHelper.ObjToHashAlgId(halg);
            HashAlgorithmName hashAlgorithmName = CapiHelper.AlgIdToHashAlgorithmName(calgHash);

            byte[] hashVal = HashOneShotHelpers.HashData(hashAlgorithmName, buffer);
            return(VerifyHash(hashVal, calgHash, signature));
        }
        /// <summary>
        /// Computes the hash value of a subset of the specified byte array using the
        /// specified hash algorithm, and signs the resulting hash value.
        /// </summary>
        /// <param name="inputStream">The input data for which to compute the hash</param>
        /// <param name="halg">The hash algorithm to use to create the hash value. </param>
        /// <returns>The RSA signature for the specified data.</returns>
        public byte[] SignData(Stream inputStream, object halg)
        {
            int calgHash = CapiHelper.ObjToHashAlgId(halg);
            HashAlgorithmName hashAlgorithmName = CapiHelper.AlgIdToHashAlgorithmName(calgHash);

            byte[] hashVal = HashOneShotHelpers.HashData(hashAlgorithmName, inputStream);
            return(SignHash(hashVal, calgHash));
        }
        /// <summary>
        /// Computes the hash value of a subset of the specified byte array using the
        /// specified hash algorithm, and signs the resulting hash value.
        /// </summary>
        /// <param name="buffer">The input data for which to compute the hash</param>
        /// <param name="offset">The offset into the array from which to begin using data</param>
        /// <param name="count">The number of bytes in the array to use as data. </param>
        /// <param name="halg">The hash algorithm to use to create the hash value. </param>
        /// <returns>The RSA signature for the specified data.</returns>
        public byte[] SignData(byte[] buffer, int offset, int count, object halg)
        {
            int calgHash = CapiHelper.ObjToHashAlgId(halg);
            HashAlgorithmName hashAlgorithmName = CapiHelper.AlgIdToHashAlgorithmName(calgHash);

            byte[] hashVal = HashOneShotHelpers.HashData(hashAlgorithmName, new ReadOnlySpan <byte>(buffer, offset, count));
            return(SignHash(hashVal, calgHash));
        }
        /// <summary>
        /// Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
        /// </summary>
        /// <param name="buffer">The input data for which to compute the hash</param>
        /// <param name="offset">The offset into the array from which to begin using data</param>
        /// <param name="count">The number of bytes in the array to use as data. </param>
        /// <param name="halg">The hash algorithm to use to create the hash value. </param>
        /// <returns>The RSA signature for the specified data.</returns>
        public byte[] SignData(byte[] buffer, int offset, int count, Object halg)
        {
            int           calgHash = CapiHelper.ObjToHashAlgId(halg);
            HashAlgorithm hash     = CapiHelper.ObjToHashAlgorithm(halg);

            byte[] hashVal = hash.ComputeHash(buffer, offset, count);
            return(SignHash(hashVal, calgHash));
        }