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)); } }
public void ConvertToOidString_HashAlgorithmName_WithValidInput_Succeeds(HashAlgorithmName hashAlgorithmName, string expectedOid) { var actualOid = hashAlgorithmName.ConvertToOidString(); Assert.Equal(expectedOid, actualOid); }
/// <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)); }