3 // meta4ra -- Metalink 4.0 utilities
4 // Copyright (C) 2021-2024 Sergey Matveev <stargrave@stargrave.org>
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, version 3 of the License.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 "github.com/dchest/skein"
24 "go.cypherpunks.ru/gogost/v5/gost34112012256"
25 "go.cypherpunks.ru/gogost/v5/gost34112012512"
26 "golang.org/x/crypto/blake2b"
27 "golang.org/x/crypto/sha3"
28 "lukechampine.com/blake3"
32 // Those are better than SHA2, prepend them
34 BuiltinHashes[name] = func() hash.Hash {
35 return sha3.NewShake256()
37 HashesDefault = name + ":builtin," + HashesDefault
40 BuiltinHashes[name] = func() hash.Hash {
41 return sha3.NewShake128()
43 HashesDefault = name + ":builtin," + HashesDefault
46 BuiltinHashes[name] = func() hash.Hash {
47 return skein.NewHash(64)
49 HashesDefault = name + ":builtin," + HashesDefault
52 BuiltinHashes[name] = func() hash.Hash {
53 h, err := blake2b.New(32, nil)
59 HashesDefault = name + ":builtin," + HashesDefault
62 BuiltinHashes[name] = func() hash.Hash {
63 h, err := blake2b.New(64, nil)
69 HashesDefault = name + ":builtin," + HashesDefault
72 BuiltinHashes[name] = func() hash.Hash {
73 return blake3.New(32, nil)
75 HashesDefault = name + ":builtin," + HashesDefault
77 // Those are slower than SHA2, append them
79 BuiltinHashes[name] = func() hash.Hash {
80 return gost34112012512.New()
82 HashesDefault = HashesDefault + "," + name + ":builtin"
85 BuiltinHashes[name] = func() hash.Hash {
86 return gost34112012256.New()
88 HashesDefault = HashesDefault + "," + name + ":builtin"
91 BuiltinHashes[name] = func() hash.Hash {
94 HashesDefault = HashesDefault + "," + name + ":builtin"