From 56f62709ad14354d15c36984c8443e52d20166b5 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Mon, 22 Nov 2021 09:26:42 -0800 Subject: [PATCH] [nonworking] Groestl hash addition --- go.mod | 3 +++ xs/xs.go | 3 ++- xsd/xsd.go | 3 ++- xsnet/chan.go | 4 ++++ xsnet/consts.go | 1 + xsnet/net.go | 6 ++++++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 3872ef3..d61b63b 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module blitter.com/go/xs go 1.12 +replace groestl => ../groestl + require ( blitter.com/go/cryptmt v1.0.2 blitter.com/go/goutmp v1.0.5 @@ -28,4 +30,5 @@ require ( gopkg.in/hlandau/easymetric.v1 v1.0.0 // indirect gopkg.in/hlandau/measurable.v1 v1.0.1 // indirect gopkg.in/hlandau/passlib.v1 v1.0.10 + groestl v0.0.0-00010101000000-000000000000 ) diff --git a/xs/xs.go b/xs/xs.go index 1c8314d..b0d9bed 100755 --- a/xs/xs.go +++ b/xs/xs.go @@ -719,7 +719,8 @@ func main() { C_CHACHA20_12`) flag.StringVar(&hmacAlg, "m", "H_SHA256", "session `HMAC`"+` H_SHA256 - H_SHA512`) + H_SHA512 + H_GROESTL256`) flag.StringVar(&kexAlg, "k", "KEX_HERRADURA512", "KEx `alg`"+` KEX_HERRADURA256 KEX_HERRADURA512 diff --git a/xsd/xsd.go b/xsd/xsd.go index 98e83eb..dcef6dd 100755 --- a/xsd/xsd.go +++ b/xsd/xsd.go @@ -553,7 +553,8 @@ func main() { flag.Var(&aHMACAlgs, "aH", "Allowed `HMAC`s (eg. '-aH HMACAlgA -aH HMACAlgB ...')" + ` H_all H_SHA256 - H_SHA512`) + H_SHA512 + H_GROESTL256`) flag.Parse() diff --git a/xsnet/chan.go b/xsnet/chan.go index 819083d..9b132cb 100644 --- a/xsnet/chan.go +++ b/xsnet/chan.go @@ -31,6 +31,7 @@ import ( // on this...) _ "crypto/sha256" _ "crypto/sha512" + groestl "groestl/pkg/groestl" ) // 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() { log.Fatal("hash not available!") } + case HmacGroestl256: + log.Printf("[hash HmacGroestl256 (%d)]\n", hopts) + mc = groestl.New256() default: log.Printf("[invalid hmac (%d)]\n", hopts) fmt.Printf("DOOFUS SET A VALID HMAC ALG (%d)\n", hopts) diff --git a/xsnet/consts.go b/xsnet/consts.go index 30833a2..0e45a02 100644 --- a/xsnet/consts.go +++ b/xsnet/consts.go @@ -118,6 +118,7 @@ type CSCipherAlg uint32 const ( HmacSHA256 = iota HmacSHA512 + HmacGroestl256 HmacNoneDisallowed ) diff --git a/xsnet/net.go b/xsnet/net.go index bfb002f..93c6351 100644 --- a/xsnet/net.go +++ b/xsnet/net.go @@ -174,6 +174,8 @@ func (h *CSHmacAlg) String() string { return "H_SHA256" case HmacSHA512: return "H_SHA512" + case HmacGroestl256: + return "H_GROESTL256" default: return "H_ERR_UNK" } @@ -362,6 +364,10 @@ func (hc *Conn) applyConnExtensions(extensions ...string) { log.Println("[extension arg = H_SHA512]") hc.cipheropts &= (0xFFFF00FF) hc.cipheropts |= (HmacSHA512 << 8) + case "H_GROESTL256": + log.Println("[extension arg = H_GROESTL256]") + hc.cipheropts &= (0xFFFF00FF) + hc.cipheropts |= (HmacGroestl256 << 8) //default: // log.Printf("[Dial ext \"%s\" ignored]\n", s) }