mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-01 19:17:36 +03:00
24 lines
417 B
Go
24 lines
417 B
Go
package hkdf
|
|
|
|
import (
|
|
"crypto/hkdf"
|
|
"hash"
|
|
)
|
|
|
|
func Extract[H hash.Hash](h func() H, secret, salt []byte) []byte {
|
|
res, err := hkdf.Extract(h, secret, salt)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
func Expand[H hash.Hash](h func() H, pseudorandomKey []byte, info string, keyLength int) []byte {
|
|
res, err := hkdf.Expand(h, pseudorandomKey, info, keyLength)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return res
|
|
}
|