Add reference from hashtools to their labeled hash version
This commit is contained in:
parent
9dffde4dfa
commit
6889bbd62e
3 changed files with 30 additions and 1 deletions
hashtools
|
@ -6,6 +6,8 @@ import (
|
|||
// Register BLAKE2 in Go's internal registry.
|
||||
_ "golang.org/x/crypto/blake2b"
|
||||
_ "golang.org/x/crypto/blake2s"
|
||||
|
||||
"github.com/safing/jess/lhash"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -21,6 +23,7 @@ func init() {
|
|||
BlockSize: crypto.BLAKE2s_256.New().BlockSize(),
|
||||
SecurityLevel: 128,
|
||||
Comment: "RFC 7693, successor of SHA3 finalist, optimized for 8-32 bit software",
|
||||
labeledAlg: lhash.BLAKE2s_256,
|
||||
}))
|
||||
Register(blake2bBase.With(&HashTool{
|
||||
Name: "BLAKE2b-256",
|
||||
|
@ -28,6 +31,7 @@ func init() {
|
|||
DigestSize: crypto.BLAKE2b_256.Size(),
|
||||
BlockSize: crypto.BLAKE2b_256.New().BlockSize(),
|
||||
SecurityLevel: 128,
|
||||
labeledAlg: lhash.BLAKE2b_256,
|
||||
}))
|
||||
Register(blake2bBase.With(&HashTool{
|
||||
Name: "BLAKE2b-384",
|
||||
|
@ -35,6 +39,7 @@ func init() {
|
|||
DigestSize: crypto.BLAKE2b_384.Size(),
|
||||
BlockSize: crypto.BLAKE2b_384.New().BlockSize(),
|
||||
SecurityLevel: 192,
|
||||
labeledAlg: lhash.BLAKE2b_384,
|
||||
}))
|
||||
Register(blake2bBase.With(&HashTool{
|
||||
Name: "BLAKE2b-512",
|
||||
|
@ -42,5 +47,6 @@ func init() {
|
|||
DigestSize: crypto.BLAKE2b_512.Size(),
|
||||
BlockSize: crypto.BLAKE2b_512.New().BlockSize(),
|
||||
SecurityLevel: 256,
|
||||
labeledAlg: lhash.BLAKE2b_512,
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package hashtools
|
|||
import (
|
||||
"crypto"
|
||||
"hash"
|
||||
|
||||
"github.com/safing/jess/lhash"
|
||||
)
|
||||
|
||||
// HashTool holds generic information about a hash tool.
|
||||
|
@ -16,6 +18,8 @@ type HashTool struct {
|
|||
|
||||
Comment string
|
||||
Author string
|
||||
|
||||
labeledAlg lhash.Algorithm
|
||||
}
|
||||
|
||||
// New returns a new hash.Hash instance of the hash tool.
|
||||
|
@ -46,6 +50,14 @@ func (ht *HashTool) With(changes *HashTool) *HashTool {
|
|||
if changes.Author == "" {
|
||||
changes.Author = ht.Author
|
||||
}
|
||||
if changes.labeledAlg == 0 {
|
||||
changes.labeledAlg = ht.labeledAlg
|
||||
}
|
||||
|
||||
return changes
|
||||
}
|
||||
|
||||
// LabeledHasher returns the corresponding labeled hashing algorithm.
|
||||
func (ht *HashTool) LabeledHasher() lhash.Algorithm {
|
||||
return ht.labeledAlg
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@ package hashtools
|
|||
|
||||
import (
|
||||
"crypto"
|
||||
|
||||
// Register SHA2 in Go's internal registry.
|
||||
_ "crypto/sha256"
|
||||
_ "crypto/sha512"
|
||||
|
||||
// Register SHA3 in Go's internal registry.
|
||||
_ "golang.org/x/crypto/sha3"
|
||||
|
||||
"github.com/safing/jess/lhash"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -24,6 +25,7 @@ func init() {
|
|||
BlockSize: crypto.SHA224.New().BlockSize(),
|
||||
SecurityLevel: 112,
|
||||
Author: "NSA, 2004",
|
||||
labeledAlg: lhash.SHA2_224,
|
||||
}))
|
||||
Register(sha2Base.With(&HashTool{
|
||||
Name: "SHA2-256",
|
||||
|
@ -31,6 +33,7 @@ func init() {
|
|||
DigestSize: crypto.SHA256.Size(),
|
||||
BlockSize: crypto.SHA256.New().BlockSize(),
|
||||
SecurityLevel: 128,
|
||||
labeledAlg: lhash.SHA2_256,
|
||||
}))
|
||||
Register(sha2Base.With(&HashTool{
|
||||
Name: "SHA2-384",
|
||||
|
@ -38,6 +41,7 @@ func init() {
|
|||
DigestSize: crypto.SHA384.Size(),
|
||||
BlockSize: crypto.SHA384.New().BlockSize(),
|
||||
SecurityLevel: 192,
|
||||
labeledAlg: lhash.SHA2_384,
|
||||
}))
|
||||
Register(sha2Base.With(&HashTool{
|
||||
Name: "SHA2-512",
|
||||
|
@ -45,6 +49,7 @@ func init() {
|
|||
DigestSize: crypto.SHA512.Size(),
|
||||
BlockSize: crypto.SHA512.New().BlockSize(),
|
||||
SecurityLevel: 256,
|
||||
labeledAlg: lhash.SHA2_512,
|
||||
}))
|
||||
Register(sha2Base.With(&HashTool{
|
||||
Name: "SHA2-512-224",
|
||||
|
@ -52,6 +57,7 @@ func init() {
|
|||
DigestSize: crypto.SHA512_224.Size(),
|
||||
BlockSize: crypto.SHA512_224.New().BlockSize(),
|
||||
SecurityLevel: 112,
|
||||
labeledAlg: lhash.SHA2_512_224,
|
||||
}))
|
||||
Register(sha2Base.With(&HashTool{
|
||||
Name: "SHA2-512-256",
|
||||
|
@ -59,6 +65,7 @@ func init() {
|
|||
DigestSize: crypto.SHA512_256.Size(),
|
||||
BlockSize: crypto.SHA512_256.New().BlockSize(),
|
||||
SecurityLevel: 128,
|
||||
labeledAlg: lhash.SHA2_512_256,
|
||||
}))
|
||||
|
||||
// SHA3
|
||||
|
@ -72,6 +79,7 @@ func init() {
|
|||
DigestSize: crypto.SHA3_224.Size(),
|
||||
BlockSize: crypto.SHA3_224.New().BlockSize(),
|
||||
SecurityLevel: 112,
|
||||
labeledAlg: lhash.SHA3_224,
|
||||
}))
|
||||
Register(sha3Base.With(&HashTool{
|
||||
Name: "SHA3-256",
|
||||
|
@ -79,6 +87,7 @@ func init() {
|
|||
DigestSize: crypto.SHA3_256.Size(),
|
||||
BlockSize: crypto.SHA3_256.New().BlockSize(),
|
||||
SecurityLevel: 128,
|
||||
labeledAlg: lhash.SHA3_256,
|
||||
}))
|
||||
Register(sha3Base.With(&HashTool{
|
||||
Name: "SHA3-384",
|
||||
|
@ -86,6 +95,7 @@ func init() {
|
|||
DigestSize: crypto.SHA3_384.Size(),
|
||||
BlockSize: crypto.SHA3_384.New().BlockSize(),
|
||||
SecurityLevel: 192,
|
||||
labeledAlg: lhash.SHA3_384,
|
||||
}))
|
||||
Register(sha3Base.With(&HashTool{
|
||||
Name: "SHA3-512",
|
||||
|
@ -93,5 +103,6 @@ func init() {
|
|||
DigestSize: crypto.SHA3_512.Size(),
|
||||
BlockSize: crypto.SHA3_512.New().BlockSize(),
|
||||
SecurityLevel: 256,
|
||||
labeledAlg: lhash.SHA3_512,
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue