Add blake2s and blake2b to the list of valid hash algos
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
94bdf8275a
commit
046db8bf1c
|
@ -36,9 +36,11 @@ import (
|
||||||
|
|
||||||
"github.com/PuerkitoBio/purell"
|
"github.com/PuerkitoBio/purell"
|
||||||
"github.com/vmihailenco/msgpack/v5"
|
"github.com/vmihailenco/msgpack/v5"
|
||||||
|
"golang.org/x/crypto/blake2b"
|
||||||
|
"golang.org/x/crypto/blake2s"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
"lure.sh/lure/internal/dlcache"
|
"lure.sh/lure/internal/dlcache"
|
||||||
"lure.sh/lure/pkg/loggerctx"
|
"lure.sh/lure/pkg/loggerctx"
|
||||||
"golang.org/x/exp/slices"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const manifestFileName = ".lure_cache_manifest"
|
const manifestFileName = ".lure_cache_manifest"
|
||||||
|
@ -91,11 +93,8 @@ type Options struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opts Options) NewHash() (hash.Hash, error) {
|
func (opts Options) NewHash() (hash.Hash, error) {
|
||||||
if opts.HashAlgorithm == "" {
|
|
||||||
opts.HashAlgorithm = "sha256"
|
|
||||||
}
|
|
||||||
switch opts.HashAlgorithm {
|
switch opts.HashAlgorithm {
|
||||||
case "sha256":
|
case "", "sha256":
|
||||||
return sha256.New(), nil
|
return sha256.New(), nil
|
||||||
case "sha224":
|
case "sha224":
|
||||||
return sha256.New224(), nil
|
return sha256.New224(), nil
|
||||||
|
@ -107,8 +106,17 @@ func (opts Options) NewHash() (hash.Hash, error) {
|
||||||
return sha1.New(), nil
|
return sha1.New(), nil
|
||||||
case "md5":
|
case "md5":
|
||||||
return md5.New(), nil
|
return md5.New(), nil
|
||||||
|
case "blake2s-128":
|
||||||
|
return blake2s.New256(nil)
|
||||||
|
case "blake2s-256":
|
||||||
|
return blake2s.New256(nil)
|
||||||
|
case "blake2b-256":
|
||||||
|
return blake2b.New(32, nil)
|
||||||
|
case "blake2b-512":
|
||||||
|
return blake2b.New(64, nil)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("%w: %s", ErrNoSuchHashAlgo, opts.HashAlgorithm)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("%w: %s", ErrNoSuchHashAlgo, opts.HashAlgorithm)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manifest holds information about the type and name
|
// Manifest holds information about the type and name
|
||||||
|
|
Loading…
Reference in New Issue