fix: authcode padding and add String to messagenametag

This commit is contained in:
Richard Ramos 2022-12-15 20:47:54 -04:00 committed by RichΛrd
parent 5740a6d571
commit ad33eabe39
2 changed files with 7 additions and 2 deletions

View File

@ -349,7 +349,7 @@ func (hs *Handshake) Authcode() (string, error) {
bn.SetBytes(output0)
code := new(big.Int)
code.Mod(bn, big.NewInt(100_000_000))
return fmt.Sprintf("'%8s'", code.String()), nil
return fmt.Sprintf("'%08s'", code.String()), nil
}
func (hs *Handshake) messageNametagSecrets() (nms1 []byte, nms2 []byte, err error) {

View File

@ -4,10 +4,11 @@ import (
"bytes"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"errors"
)
type MessageNametag = [MessageNametagLength]byte
type MessageNametag [MessageNametagLength]byte
const MessageNametagLength = 16
const MessageNametagBufferSize = 50
@ -24,6 +25,10 @@ func BytesToMessageNametag(input []byte) MessageNametag {
return result
}
func (t MessageNametag) String() string {
return hex.EncodeToString(t[:])
}
type MessageNametagBuffer struct {
buffer []MessageNametag
counter uint64