HashAlgorithmNameNullOrEmpty() static private method

static private HashAlgorithmNameNullOrEmpty ( ) : Exception
return Exception
コード例 #1
0
 /// <summary>Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and comparing it to the provided signature. </summary>
 /// <param name="data">The signed data. </param>
 /// <param name="offset">The starting index at which to compute the hash. </param>
 /// <param name="count">The number of bytes to hash. </param>
 /// <param name="signature">The signature data to be verified. </param>
 /// <param name="hashAlgorithm">The hash algorithm used to create the hash value of the data. </param>
 /// <returns>
 ///     <see langword="true" /> if the digital signature is valid; otherwise, <see langword="false" />. </returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="data" /> is <see langword="null" />. -or-
 ///         <paramref name="signature" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.ArgumentException">
 ///         <paramref name="hashAlgorithm" />.<see cref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <see langword="null" /> or <see cref="F:System.String.Empty" />. </exception>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 ///         <paramref name="offset" /> is less than zero. -or-
 ///         <paramref name="count" /> is less than zero.-or-
 ///         <paramref name="offset" /> + <paramref name="count" /> – 1 results in an index that is beyond the upper bound of <paramref name="data" />.  </exception>
 // Token: 0x06002176 RID: 8566 RVA: 0x000764BC File Offset: 0x000746BC
 public virtual bool VerifyData(byte[] data, int offset, int count, byte[] signature, HashAlgorithmName hashAlgorithm)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (offset < 0 || offset > data.Length)
     {
         throw new ArgumentOutOfRangeException("offset");
     }
     if (count < 0 || count > data.Length - offset)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (signature == null)
     {
         throw new ArgumentNullException("signature");
     }
     if (string.IsNullOrEmpty(hashAlgorithm.Name))
     {
         throw DSA.HashAlgorithmNameNullOrEmpty();
     }
     byte[] rgbHash = this.HashData(data, offset, count, hashAlgorithm);
     return(this.VerifySignature(rgbHash, signature));
 }
コード例 #2
0
 /// <summary>Computes the hash value of the specified stream using the specified hash algorithm and signs the resulting hash value.</summary>
 /// <param name="data">The input stream for which to compute the hash. </param>
 /// <param name="hashAlgorithm">The hash algorithm to use to create the hash value. </param>
 /// <returns>The DSA signature for the specified data. </returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="data" /> is <see langword="null" />. </exception>
 /// <exception cref="T:System.ArgumentException">
 ///         <paramref name="hashAlgorithm" />.<see cref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <see langword="null" /> or <see cref="F:System.String.Empty" />. </exception>
 // Token: 0x06002174 RID: 8564 RVA: 0x00076460 File Offset: 0x00074660
 public virtual byte[] SignData(Stream data, HashAlgorithmName hashAlgorithm)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (string.IsNullOrEmpty(hashAlgorithm.Name))
     {
         throw DSA.HashAlgorithmNameNullOrEmpty();
     }
     byte[] rgbHash = this.HashData(data, hashAlgorithm);
     return(this.CreateSignature(rgbHash));
 }
コード例 #3
0
 /// <summary>Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and comparing it to the provided signature. </summary>
 /// <param name="data">The signed data. </param>
 /// <param name="signature">The signature data to be verified. </param>
 /// <param name="hashAlgorithm">The hash algorithm used to create the hash value of the data. </param>
 /// <returns>
 ///     <see langword="true" /> if the digital signature is valid; otherwise, <see langword="false" />. </returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="data" /> is <see langword="null" />. -or-
 ///         <paramref name="signature" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.ArgumentException">
 ///         <paramref name="hashAlgorithm" />.<see cref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <see langword="null" /> or <see cref="F:System.String.Empty" />. </exception>
 // Token: 0x06002177 RID: 8567 RVA: 0x0007653C File Offset: 0x0007473C
 public virtual bool VerifyData(Stream data, byte[] signature, HashAlgorithmName hashAlgorithm)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (signature == null)
     {
         throw new ArgumentNullException("signature");
     }
     if (string.IsNullOrEmpty(hashAlgorithm.Name))
     {
         throw DSA.HashAlgorithmNameNullOrEmpty();
     }
     byte[] rgbHash = this.HashData(data, hashAlgorithm);
     return(this.VerifySignature(rgbHash, signature));
 }