|
|
@@ -7,6 +7,7 @@ import (
|
|
|
"io"
|
|
|
)
|
|
|
|
|
|
+// Checksum returns a hash of the data in accordance with RFC 4757
|
|
|
func Checksum(key []byte, usage uint32, data []byte) ([]byte, error) {
|
|
|
// Create hashing key
|
|
|
s := append([]byte(`signaturekey`), byte(0x00)) //includes zero octet at end
|
|
|
@@ -15,7 +16,7 @@ func Checksum(key []byte, usage uint32, data []byte) ([]byte, error) {
|
|
|
Ksign := mac.Sum(nil)
|
|
|
|
|
|
// Format data
|
|
|
- tb := MessageTypeBytes(usage)
|
|
|
+ tb := UsageToMSMsgType(usage)
|
|
|
p := append(tb, data...)
|
|
|
h := md5.New()
|
|
|
rb := bytes.NewReader(p)
|
|
|
@@ -31,6 +32,7 @@ func Checksum(key []byte, usage uint32, data []byte) ([]byte, error) {
|
|
|
return mac.Sum(nil), nil
|
|
|
}
|
|
|
|
|
|
+// HMAC returns a keyed MD5 checksum of the data
|
|
|
func HMAC(key []byte, data []byte) []byte {
|
|
|
mac := hmac.New(md5.New, key)
|
|
|
mac.Write(data)
|