Added HMAC_SHA512

This commit is contained in:
Russ Magee 2018-09-30 00:19:25 -07:00
parent cd9f7914e0
commit 06ee94da03
3 changed files with 15 additions and 0 deletions

View File

@ -52,6 +52,7 @@ type CSCipherAlg uint32
const (
HmacSHA256 = iota
HmacSHA512
HmacNoneDisallowed
)
// Available HMACs for hkex.Conn (TODO: not currently used)

View File

@ -27,6 +27,7 @@ import (
// (Would be nice if the golang pkg docs were more clear
// on this...)
_ "crypto/sha256"
_ "crypto/sha512"
)
/* Support functionality to set up encryption after a channel has
@ -92,6 +93,14 @@ func (hc Conn) getStream(keymat *big.Int) (rc cipher.Stream, mc hash.Hash, err e
log.Fatal("hash not available!")
}
break
case HmacSHA512:
log.Printf("[hash HmacSHA512 (%d)]\n", hopts)
halg := crypto.SHA512
mc = halg.New()
if !halg.Available() {
log.Fatal("hash not available!")
}
break
default:
log.Printf("[invalid hmac (%d)]\n", hopts)
fmt.Printf("DOOFUS SET A VALID HMAC ALG (%d)\n", hopts)

View File

@ -176,6 +176,11 @@ func (hc *Conn) applyConnExtensions(extensions ...string) {
hc.cipheropts &= (0xFFFF00FF)
hc.cipheropts |= (HmacSHA256 << 8)
break
case "H_SHA512":
log.Println("[extension arg = H_SHA512]")
hc.cipheropts &= (0xFFFF00FF)
hc.cipheropts |= (HmacSHA512 << 8)
break
default:
log.Printf("[Dial ext \"%s\" ignored]\n", s)
break