예제 #1
0
        private static BcEssCertIdV2 CreateBcEssCertIdV2(HashAlgorithmName hashAlgorithmName, string text)
        {
            var hash = CryptoHashUtility.ComputeHash(hashAlgorithmName, Encoding.UTF8.GetBytes(text));
            var bcAlgorithmIdentifier = new BcAlgorithmIdentifier(
                new DerObjectIdentifier(hashAlgorithmName.ConvertToOidString()));

            return(new BcEssCertIdV2(bcAlgorithmIdentifier, hash));
        }
        private static void AddCertificateFingerprintIntoAllowList(
            VerificationTarget target,
            HashAlgorithmName algorithm,
            IRepositoryCertificateInfo certInfo,
            List <CertificateHashAllowListEntry> allowList)
        {
            var fingerprint = certInfo.Fingerprints[algorithm.ConvertToOidString()];

            if (!string.IsNullOrEmpty(fingerprint))
            {
                allowList.Add(new CertificateHashAllowListEntry(target, fingerprint, algorithm));
            }
        }
예제 #3
0
        public void ConvertToOidString_HashAlgorithmName_WithValidInput_Succeeds(HashAlgorithmName hashAlgorithmName, string expectedOid)
        {
            var actualOid = hashAlgorithmName.ConvertToOidString();

            Assert.Equal(expectedOid, actualOid);
        }
예제 #4
0
        /// <summary>
        /// Extension method to convert NuGet.Common.HashAlgorithmName to an OID
        /// </summary>
        /// <returns>OID equivalent of the NuGet.Common.HashAlgorithmName</returns>
        public static Oid ConvertToOid(this HashAlgorithmName hashAlgorithm)
        {
            var oidString = hashAlgorithm.ConvertToOidString();

            return(new Oid(oidString));
        }