Merge branch 'whirlpool-hash' of RLabs/xs into master

This commit is contained in:
Russtopia 2024-05-01 23:49:36 -07:00 committed by Gogs
commit ec9b4fe2f4
7 changed files with 18 additions and 3 deletions

View file

@ -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)

View file

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

View file

@ -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