Beispiel #1
0
func testCertificates(ch <-chan []byte, wg *sync.WaitGroup) {
	var h detectcoll.Hash

	if *md5 {
		h = detectcoll.NewMD5()
	} else {
		if *thorough {
			h = detectcoll.NewSHA1Thorough()
		} else {
			h = detectcoll.NewSHA1()
		}
	}

	for blob := range ch {
		cert, err := x509.ParseCertificate(blob)
		if err != nil {
			// log.Printf("Error in cert %v: %s", err, base64.StdEncoding.EncodeToString(blob))
			continue
		}
		h.Write(cert.RawTBSCertificate)
		if sum, ok := h.DetectSum(nil); !ok {
			log.Printf("Certificate has possible collision (hash=%x)", sum)
			log.Print(base64.StdEncoding.EncodeToString(blob))
		}
		h.Reset()
	}
	wg.Done()
}