diff --git a/go.mod b/go.mod index a47bc1d..8437ff3 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( require ( blitter.com/go/chacha20 v0.0.0-20200130200441-214e4085f54c // indirect blitter.com/go/mtwist v1.0.1 // indirect + github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/klauspost/reedsolomon v1.12.1 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/go.sum b/go.sum index 30048ce..5d44f1f 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/jameskeane/bcrypt v0.0.0-20120420032655-c3cd44c1e20f h1:UWGE8Vi+1Agt0lrvnd7UsmvwqWKRzb9byK9iQmsbY0Y= github.com/jameskeane/bcrypt v0.0.0-20120420032655-c3cd44c1e20f/go.mod h1:u+9Snq0w+ZdYKi8BBoaxnEwWu0fY4Kvu9ByFpM51t1s= +github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 h1:G+9t9cEtnC9jFiTxyptEKuNIAbiN5ZCQzX2a74lj3xg= +github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004/go.mod h1:KmHnJWQrgEvbuy0vcvj00gtMqbvNn1L+3YUZLK/B92c= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/reedsolomon v1.12.1 h1:NhWgum1efX1x58daOBGCFWcxtEhOhXKKl1HAPQUp03Q= diff --git a/xs/xs.go b/xs/xs.go index 4fa9b13..018c542 100755 --- a/xs/xs.go +++ b/xs/xs.go @@ -733,7 +733,8 @@ func main() { //nolint: funlen, gocyclo C_CHACHA20_12`) flag.StringVar(&hmacAlg, "m", "H_SHA256", "session `HMAC`"+` H_SHA256 - H_SHA512`) + H_SHA512 + H_WHIRLPOOL`) flag.StringVar(&kexAlg, "k", "KEX_HERRADURA512", "KEx `alg`"+` KEX_HERRADURA256 KEX_HERRADURA512 diff --git a/xsd/xsd.go b/xsd/xsd.go index 346274b..62f9a39 100755 --- a/xsd/xsd.go +++ b/xsd/xsd.go @@ -572,7 +572,8 @@ func main() { //nolint:funlen,gocyclo flag.Var(&aHMACAlgs, "aH", "Allowed `HMAC`s (eg. '-aH HMACAlgA -aH HMACAlgB ...')"+` H_all H_SHA256 - H_SHA512`) + H_SHA512 + H_WHIRLPOOL`) flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to <`file`>") flag.StringVar(&memprofile, "memprofile", "", "write memory profile to <`file`>") diff --git a/xsnet/chan.go b/xsnet/chan.go index 4b4e82d..5847372 100644 --- a/xsnet/chan.go +++ b/xsnet/chan.go @@ -26,7 +26,7 @@ import ( "github.com/aead/chacha20/chacha" "golang.org/x/crypto/blowfish" "golang.org/x/crypto/twofish" - + whirlpool "github.com/jzelinskie/whirlpool" // hash algos must be manually imported thusly: // (Would be nice if the golang pkg docs were more clear // on this...) @@ -157,6 +157,9 @@ func (hc *Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err er if !halg.Available() { log.Fatal("hash not available!") } + case HmacWHIRLPOOL: + log.Printf("[hash HmacWHIRLPOOL (%d)]\n", hopts) + mc = whirlpool.New() 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 1d7e9c8..9c58d6e 100644 --- a/xsnet/consts.go +++ b/xsnet/consts.go @@ -119,6 +119,7 @@ type CSCipherAlg uint32 const ( HmacSHA256 = iota HmacSHA512 + HmacWHIRLPOOL HmacNoneDisallowed ) diff --git a/xsnet/net.go b/xsnet/net.go index 0a576ab..5bd423f 100644 --- a/xsnet/net.go +++ b/xsnet/net.go @@ -177,6 +177,8 @@ func (h *CSHmacAlg) String() string { return "H_SHA256" case HmacSHA512: return "H_SHA512" + case HmacWHIRLPOOL: + return "H_WHIRLPOOL" default: return "H_ERR_UNK" } @@ -363,6 +365,10 @@ func (hc *Conn) applyConnExtensions(extensions ...string) { log.Println("[extension arg = H_SHA512]") hc.cipheropts &= (0xFFFF00FF) hc.cipheropts |= (HmacSHA512 << 8) + case "H_WHIRLPOOL": + log.Println("[extension arg = H_WHIRLPOOL]") + hc.cipheropts &= (0xFFFF00FF) + hc.cipheropts |= (HmacWHIRLPOOL << 8) case "OPT_REMOD": log.Println("[extension arg = OPT_REMOD]") hc.opts |= CORemodulateShields