MCPcopy Create free account
hub / github.com/Mister-leo/fssh / HKDF

Function HKDF

internal/crypt/crypt.go:11–28  ·  view source on GitHub ↗
(master []byte, salt []byte, info []byte, length int)

Source from the content-addressed store, hash-verified

9)
10
11func HKDF(master []byte, salt []byte, info []byte, length int) []byte {
12 prk := hmac.New(sha256.New, salt)
13 prk.Write(master)
14 prkSum := prk.Sum(nil)
15 res := make([]byte, 0, length)
16 var t []byte
17 var ctr byte = 1
18 for len(res) < length {
19 h := hmac.New(sha256.New, prkSum)
20 h.Write(t)
21 h.Write(info)
22 h.Write([]byte{ctr})
23 t = h.Sum(nil)
24 res = append(res, t...)
25 ctr++
26 }
27 return res[:length]
28}
29
30func EncryptAEAD(key []byte, nonce []byte, plaintext []byte, aad []byte) ([]byte, error) {
31 blk, err := aes.NewCipher(key)

Callers 4

UnlockMasterKeyMethod · 0.92
SaveEncryptedRecordFunction · 0.92
LoadDecryptedRecordFunction · 0.92
deriveMasterKeyFromSeedFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected