logger.CriticalIf(context.Background(),errors.New("Failed to decode fixed magic HighwayHash256 key. Please report this bug at https://github.com/minio/minio/issues"))
}
newBLAKE2b:=func()hash.Hash{
b2,_:=blake2b.New512(nil)// New512 never returns an error if the key is nil
returnb2
}
newHighwayHash256:=func()hash.Hash{
hh,_:=highwayhash.New(hh256Key)// New will never return error since key is 256 bit
// BitrotAlgorithm specifies a algorithm used for bitrot protection.
typeBitrotAlgorithmcrypto.Hash
typeBitrotAlgorithmuint
const(
// SHA256 represents the SHA-256 hash function
SHA256=BitrotAlgorithm(crypto.SHA256)
SHA256BitrotAlgorithm=1+iota
// HighwayHash256 represents the HighwayHash-256 hash function
HighwayHash256=BitrotAlgorithm(crypto.SHA3_256)// we must define that HighwayHash-256 is SHA3-256 because there is no HighwayHash constant in golang/crypto yet.
magicHighwayHash256Key="4be734fa8e238acd263e83e6bb968552040f935da39f441497e09d1322de36a0"// magic HH-256 key as HH-256 hash of the first 100 decimals of π as utf-8 string with a zero key.
HighwayHash256
// BLAKE2b512 represents the BLAKE2b-256 hash function
BLAKE2b512=BitrotAlgorithm(crypto.BLAKE2b_512)
BLAKE2b512
)
// DefaultBitrotAlgorithm is the default algorithm used for bitrot protection.
varDefaultBitrotAlgorithm=HighwayHash256
varbitrotAlgorithms=map[BitrotAlgorithm]string{
SHA256:"sha256",
BLAKE2b512:"blake2b",
@ -85,16 +64,24 @@ var bitrotAlgorithms = map[BitrotAlgorithm]string{
// New logs error and exits if the algorithm is not supported or not