示例#1
0
        /// <summary>
        /// Converts hashing algorithm OID to appropriate OID from signature group. For example, translates
        /// <strong>sha1</strong> hashing algorithm to <strong>sha1NoSign</strong> with the same OID value.
        /// </summary>
        /// <param name="hashAlgorithm">Hashing algorithm</param>
        /// <exception cref="ArgumentNullException">
        /// <strong>hashAlgorithm</strong> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Input OID doesn't belong to hash algorithm group or it cannot be translated to a respective
        /// </exception>
        /// <returns>OID in signature group.</returns>
        public static Oid2 MapHashToSignatureOid(Oid2 hashAlgorithm)
        {
            if (hashAlgorithm == null)
            {
                throw new ArgumentNullException(nameof(hashAlgorithm));
            }
            if (hashAlgorithm.OidGroup != OidGroupEnum.HashAlgorithm)
            {
                throw new ArgumentException("Input OID must belong to hashing group.");
            }
            Oid2 newOid = new Oid2(hashAlgorithm.Value, OidGroupEnum.SignatureAlgorithm, false);

            if (String.IsNullOrEmpty(newOid.Value))
            {
                throw new ArgumentException("Cannot translate hashing algorithm to signature algorithm.");
            }
            return(newOid);
        }
示例#2
0
 Boolean Equals(Oid2 other)
 {
     return(String.Equals(Value, other.Value) && OidGroup == other.OidGroup && String.Equals(FriendlyName, other.FriendlyName));
 }