//go:build thirdparty

// meta4ra -- Metalink 4.0 utilities
// Copyright (C) 2021-2026 Sergey Matveev <stargrave@stargrave.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

package internal

import (
	"hash"

	"github.com/dchest/skein"
	"go.stargrave.org/gogost/v7/gost34112012256"
	"go.stargrave.org/gogost/v7/gost34112012512"
	"golang.org/x/crypto/blake2b"
	"lukechampine.com/blake3"
)

func init() {
	name := "skein-512"
	BuiltinHashers[name] = func() hash.Hash {
		return skein.NewHash(64)
	}
	HashersDefault = name + " builtin\n" + HashersDefault

	name = "blake2b-256"
	BuiltinHashers[name] = func() hash.Hash {
		h, err := blake2b.New(32, nil)
		if err != nil {
			panic(err)
		}
		return h
	}
	HashersDefault = name + " builtin\n" + HashersDefault

	name = "blake2b-512"
	BuiltinHashers[name] = func() hash.Hash {
		h, err := blake2b.New(64, nil)
		if err != nil {
			panic(err)
		}
		return h
	}
	HashersDefault = name + " builtin\n" + HashersDefault

	name = "blake3-256"
	BuiltinHashers[name] = func() hash.Hash {
		return blake3.New(32, nil)
	}
	HashersDefault = name + " builtin\n" + HashersDefault

	// Those are slower than SHA2, append them
	name = "streebog-512"
	BuiltinHashers[name] = func() hash.Hash {
		return gost34112012512.New()
	}
	HashersDefault = HashersDefault + "\n" + name + " builtin"

	name = "streebog-256"
	BuiltinHashers[name] = func() hash.Hash {
		return gost34112012256.New()
	}
	HashersDefault = HashersDefault + "\n" + name + " builtin"

	name = "xxh3-128"
	BuiltinHashers[name] = func() hash.Hash {
		return NewXXH3128()
	}
	HashersDefault = HashersDefault + "\n" + name + " builtin"
}
