diff options
| author | Gab <24553253+gabrix73@users.noreply.github.com> | 2026-08-14 20:39:22 +0200 |
|---|---|---|
| committer | Gab <24553253+gabrix73@users.noreply.github.com> | 2026-08-14 20:39:22 +0200 |
| commit | 43fbddf016f94f4ba006d82c9a67dca61b5852a1 (patch) | |
| tree | 70054d5fa8a34bb094b8c3ef8ddc9c1fcea3b3d5 /yamn/encoder/encoder.go | |
| parent | 994071243fc80990cf09e820b671006e9bd31c76 (diff) | |
| download | yamnweb-43fbddf016f94f4ba006d82c9a67dca61b5852a1.tar.gz yamnweb-43fbddf016f94f4ba006d82c9a67dca61b5852a1.tar.xz yamnweb-43fbddf016f94f4ba006d82c9a67dca61b5852a1.zip | |
Complete Nym and YAMN transport integration
Diffstat (limited to 'yamn/encoder/encoder.go')
| -rw-r--r-- | yamn/encoder/encoder.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/yamn/encoder/encoder.go b/yamn/encoder/encoder.go index 5eacdf3..3b595b1 100644 --- a/yamn/encoder/encoder.go +++ b/yamn/encoder/encoder.go @@ -304,19 +304,20 @@ func slotData(kind byte, packetID, aesKey, info, tag []byte) []byte { } func encryptedHeader(key remailerKey, data []byte) []byte { - var recipient, sender [32]byte + var recipient [32]byte copy(recipient[:], key.publicKey) - if _, err := io.ReadFull(rand.Reader, sender[:]); err != nil { + senderPublic, senderSecret, err := box.GenerateKey(rand.Reader) + if err != nil { panic(err) } var nonce [24]byte if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil { panic(err) } - sealed := box.Seal(nil, data, &nonce, &recipient, &sender) + sealed := box.Seal(nil, data, &nonce, &recipient, senderSecret) b := make([]byte, headerBytes) copy(b, key.keyID) - copy(b[16:], sender[:]) + copy(b[16:], senderPublic[:]) copy(b[48:], nonce[:]) copy(b[72:], sealed) return b @@ -370,7 +371,7 @@ func deterministic(p []byte, keys, ivs [][]byte, chainLen, hop int) { for slot := top; slot <= bottom; slot++ { fake := make([]byte, headerBytes) use := bottom - for i := bottom - slot + hop; i >= 0; i-- { + for i := bottom - slot + hop; i >= hop; i-- { copy(fake, aesCTR(fake, keys[i], seqIV(ivs[i], use))) use-- } |
