File: kdf.go

package info (click to toggle)
golang-github-cloudsoda-go-smb2 0.0~git20231124.f3ec8ae-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 972 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 383 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ref: NIST SP 800-108 5.1

package smb2

import (
	"crypto/hmac"
	"crypto/sha256"
)

// KDF in Counter Mode with h = 256, r = 32, L = 128
func kdf(ki, label, context []byte) []byte {
	h := hmac.New(sha256.New, ki)

	h.Write([]byte{0x00, 0x00, 0x00, 0x01})
	h.Write(label)
	h.Write([]byte{0x00})
	h.Write(context)
	h.Write([]byte{0x00, 0x00, 0x00, 0x80})

	return h.Sum(nil)[:16]
}