(master []byte, salt []byte, info []byte, length int)
| 9 | ) |
| 10 | |
| 11 | func 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 | |
| 30 | func EncryptAEAD(key []byte, nonce []byte, plaintext []byte, aad []byte) ([]byte, error) { |
| 31 | blk, err := aes.NewCipher(key) |
no outgoing calls
no test coverage detected