internal uint HashPayload(byte[] payload, int offset, int length, ChecksumHash HashType) { if (HashType == ChecksumHash.None) { return(0); } uint hash = 0; BigInteger BigTemp = new BigInteger(); if (payload != null && length > 0) { if (ChecksumHash.CRC32 == (HashType & ChecksumHash.CRC32)) { using (CRC32 hasher = new CRC32()) { BigTemp += new BigInteger(hasher.ComputeHash(payload, offset, length)); } } if (ChecksumHash.MD5 == (HashType & ChecksumHash.MD5)) { using (MD5 hasher = MD5.Create()) { BigTemp += new BigInteger(hasher.ComputeHash(payload, offset, length)); } } if (ChecksumHash.SHA1 == (HashType & ChecksumHash.SHA1)) { using (SHA1 hasher = SHA1.Create()) { BigTemp += new BigInteger(hasher.ComputeHash(payload, offset, length)); } } if (ChecksumHash.SHA512 == (HashType & ChecksumHash.SHA512)) { using (SHA512 hasher = SHA512.Create()) { BigTemp += new BigInteger(hasher.ComputeHash(payload, offset, length)); } } } //here is the point where the collisions could begin! //Xor, Mod, later to fix it, for now let's leave it like this do { hash += (uint)BigTemp.LongValue(); BigTemp >>= 32; }while (BigTemp > 0); return(hash); }
/// <summary> /// Initialize a new Certificate /// </summary> public CertInfo(CertificateInfo info) { this.CommonName = info.CommonName; this.Country = info.Country; this.State = info.State; this.Locality = info.Locality; this.KeyAlgorithm = info.KeyAlgorithm; this.FingerPrintMd5 = info.FingerPrintMd5; this.FingerPrintSha1 = info.FingerPrintSha1; this.Cipher = info.Cipher; this.Compression = info.Compression; this.ValidTo = info.ValidTo; this.ValidFrom = info.ValidFrom; this.Organization = info.Organization; this.Unit = info.Unit; this.IssuerCommonName = info.IssuerCommonName; this.IssuerOrganization = info.IssuerOrganization; this.IssuerCountry = info.IssuerCountry; this.HandshakeMethod = info.HandshakeMethod; this.Checksum = info.Checksum; }