MCPcopy Create free account
hub / github.com/chanify/chanify / x963KDF

Function x963KDF

crypto/crypto.go:191–213  ·  view source on GitHub ↗
(sharedKeySeed []byte, ephemeralPublicKey []byte, hfnc func() hash.Hash)

Source from the content-addressed store, hash-verified

189}
190
191func x963KDF(sharedKeySeed []byte, ephemeralPublicKey []byte, hfnc func() hash.Hash) []byte {
192 length := 32
193 output := make([]byte, 0)
194 outlen := 0
195 counter := uint32(1)
196
197 for outlen < length {
198 h := hfnc()
199 h.Write(sharedKeySeed) // nolint: errcheck
200
201 counterBuf := make([]byte, 4)
202 binary.BigEndian.PutUint32(counterBuf, counter)
203 h.Write(counterBuf) // nolint: errcheck
204
205 h.Write(ephemeralPublicKey) // nolint: errcheck
206
207 out := h.Sum(nil)
208 output = append(output, out...)
209 outlen += h.Size()
210 counter++
211 }
212 return output
213}
214
215func calcSharedKey(sec *ecdsa.PrivateKey, pub *ecdsa.PublicKey) ([]byte, error) {
216 if pub == nil {

Callers 2

EncryptMethod · 0.85
DecryptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected