[nonworking] Groestl hash addition

This commit is contained in:
Russ Magee 2021-11-22 09:26:42 -08:00
parent 02e379e50d
commit 56f62709ad
6 changed files with 18 additions and 2 deletions

3
go.mod
View File

@ -2,6 +2,8 @@ module blitter.com/go/xs
go 1.12 go 1.12
replace groestl => ../groestl
require ( require (
blitter.com/go/cryptmt v1.0.2 blitter.com/go/cryptmt v1.0.2
blitter.com/go/goutmp v1.0.5 blitter.com/go/goutmp v1.0.5
@ -28,4 +30,5 @@ require (
gopkg.in/hlandau/easymetric.v1 v1.0.0 // indirect gopkg.in/hlandau/easymetric.v1 v1.0.0 // indirect
gopkg.in/hlandau/measurable.v1 v1.0.1 // indirect gopkg.in/hlandau/measurable.v1 v1.0.1 // indirect
gopkg.in/hlandau/passlib.v1 v1.0.10 gopkg.in/hlandau/passlib.v1 v1.0.10
groestl v0.0.0-00010101000000-000000000000
) )

View File

@ -719,7 +719,8 @@ func main() {
C_CHACHA20_12`) C_CHACHA20_12`)
flag.StringVar(&hmacAlg, "m", "H_SHA256", "session `HMAC`"+` flag.StringVar(&hmacAlg, "m", "H_SHA256", "session `HMAC`"+`
H_SHA256 H_SHA256
H_SHA512`) H_SHA512
H_GROESTL256`)
flag.StringVar(&kexAlg, "k", "KEX_HERRADURA512", "KEx `alg`"+` flag.StringVar(&kexAlg, "k", "KEX_HERRADURA512", "KEx `alg`"+`
KEX_HERRADURA256 KEX_HERRADURA256
KEX_HERRADURA512 KEX_HERRADURA512

View File

@ -553,7 +553,8 @@ func main() {
flag.Var(&aHMACAlgs, "aH", "Allowed `HMAC`s (eg. '-aH HMACAlgA -aH HMACAlgB ...')" + ` flag.Var(&aHMACAlgs, "aH", "Allowed `HMAC`s (eg. '-aH HMACAlgA -aH HMACAlgB ...')" + `
H_all H_all
H_SHA256 H_SHA256
H_SHA512`) H_SHA512
H_GROESTL256`)
flag.Parse() flag.Parse()

View File

@ -31,6 +31,7 @@ import (
// on this...) // on this...)
_ "crypto/sha256" _ "crypto/sha256"
_ "crypto/sha512" _ "crypto/sha512"
groestl "groestl/pkg/groestl"
) )
// Expand keymat, if necessary, to a minimum of 2x(blocksize). // Expand keymat, if necessary, to a minimum of 2x(blocksize).
@ -144,6 +145,9 @@ func (hc *Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err er
if !halg.Available() { if !halg.Available() {
log.Fatal("hash not available!") log.Fatal("hash not available!")
} }
case HmacGroestl256:
log.Printf("[hash HmacGroestl256 (%d)]\n", hopts)
mc = groestl.New256()
default: default:
log.Printf("[invalid hmac (%d)]\n", hopts) log.Printf("[invalid hmac (%d)]\n", hopts)
fmt.Printf("DOOFUS SET A VALID HMAC ALG (%d)\n", hopts) fmt.Printf("DOOFUS SET A VALID HMAC ALG (%d)\n", hopts)

View File

@ -118,6 +118,7 @@ type CSCipherAlg uint32
const ( const (
HmacSHA256 = iota HmacSHA256 = iota
HmacSHA512 HmacSHA512
HmacGroestl256
HmacNoneDisallowed HmacNoneDisallowed
) )

View File

@ -174,6 +174,8 @@ func (h *CSHmacAlg) String() string {
return "H_SHA256" return "H_SHA256"
case HmacSHA512: case HmacSHA512:
return "H_SHA512" return "H_SHA512"
case HmacGroestl256:
return "H_GROESTL256"
default: default:
return "H_ERR_UNK" return "H_ERR_UNK"
} }
@ -362,6 +364,10 @@ func (hc *Conn) applyConnExtensions(extensions ...string) {
log.Println("[extension arg = H_SHA512]") log.Println("[extension arg = H_SHA512]")
hc.cipheropts &= (0xFFFF00FF) hc.cipheropts &= (0xFFFF00FF)
hc.cipheropts |= (HmacSHA512 << 8) hc.cipheropts |= (HmacSHA512 << 8)
case "H_GROESTL256":
log.Println("[extension arg = H_GROESTL256]")
hc.cipheropts &= (0xFFFF00FF)
hc.cipheropts |= (HmacGroestl256 << 8)
//default: //default:
// log.Printf("[Dial ext \"%s\" ignored]\n", s) // log.Printf("[Dial ext \"%s\" ignored]\n", s)
} }