kaniko/vendor/github.com/pjbgf/sha1cd
Michael Plump 3e56c7fd0f
chore: upgrade all the dependencies to their latest versions (#3454)
* chore: go get -u ./...

* chore: go mod tidy

* chore: go mod vendor

* chore: fix compilation for buildkit >= 0.15.0

* chore: upgrade to Go 1.24

* chore: upgrade the Debian container used in an integration test
2025-05-21 09:31:10 -04:00
..
internal chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.7.0 (#2528) 2023-05-29 16:28:53 -07:00
ubc chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
Dockerfile.arm chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
Dockerfile.arm64 chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
LICENSE chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
Makefile chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
README.md chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.7.0 (#2528) 2023-05-29 16:28:53 -07:00
detection.go chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.7.0 (#2528) 2023-05-29 16:28:53 -07:00
sha1cd.go chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
sha1cdblock_amd64.go chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.7.0 (#2528) 2023-05-29 16:28:53 -07:00
sha1cdblock_amd64.s chore: upgrade all the dependencies to their latest versions (#3454) 2025-05-21 09:31:10 -04:00
sha1cdblock_generic.go chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.7.0 (#2528) 2023-05-29 16:28:53 -07:00
sha1cdblock_noasm.go chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.7.0 (#2528) 2023-05-29 16:28:53 -07:00

README.md

sha1cd

A Go implementation of SHA1 with counter-cryptanalysis, which detects collision attacks.

The cgo/lib code is a carbon copy of the original code, based on the award winning white paper by Marc Stevens.

The Go implementation is largely based off Go's generic sha1. At present no SIMD optimisations have been implemented.

Usage

sha1cd can be used as a drop-in replacement for crypto/sha1:

import "github.com/pjbgf/sha1cd"

func test(){
	data := []byte("data to be sha1 hashed")
	h := sha1cd.Sum(data)
	fmt.Printf("hash: %q\n", hex.EncodeToString(h))
}

To obtain information as to whether a collision was found, use the func CollisionResistantSum.

import "github.com/pjbgf/sha1cd"

func test(){
	data := []byte("data to be sha1 hashed")
	h, col  := sha1cd.CollisionResistantSum(data)
	if col {
		fmt.Println("collision found!")
	}
	fmt.Printf("hash: %q", hex.EncodeToString(h))
}

Note that the algorithm will automatically avoid collision, by extending the SHA1 to 240-steps, instead of 80 when a collision attempt is detected. Therefore, inputs that contains the unavoidable bit conditions will yield a different hash from sha1cd, when compared with results using crypto/sha1. Valid inputs will have matching the outputs.

References

Use of the Original Implementation