func (d *Dialer) NextDialRequest(round uint32, buckets uint32) *DialRequest { var ex *DialExchange select { case pk := <-d.userDialRequests: intro := (&Introduction{ Rendezvous: round + 4, LongTermKey: *d.myPublicKey, }).Marshal() ctxt, _ := onionbox.Seal(intro, ForwardNonce(round), BoxKeys{pk}.Keys()) ex = &DialExchange{ Bucket: KeyDialBucket(pk, buckets), } copy(ex.EncryptedIntro[:], ctxt) default: ex = &DialExchange{ Bucket: ^uint32(0), } rand.Read(ex.EncryptedIntro[:]) } onion, _ := onionbox.Seal(ex.Marshal(), ForwardNonce(round), d.pki.ServerKeys().Keys()) return &DialRequest{ Round: round, Onion: onion, } }
func FillWithFakeDoubles(dest [][]byte, nonce *[24]byte, nextKeys []*[32]byte) { ParallelFor(len(dest)/2, func(p *P) { for i, ok := p.Next(); ok; i, ok = p.Next() { var exchange1 [SizeConvoExchange]byte var exchange2 [SizeConvoExchange]byte rand.Read(exchange1[:]) copy(exchange2[0:16], exchange1[0:16]) rand.Read(exchange2[16:]) onion1, _ := onionbox.Seal(exchange1[:], nonce, nextKeys) onion2, _ := onionbox.Seal(exchange2[:], nonce, nextKeys) dest[i*2] = onion1 dest[i*2+1] = onion2 } }) }
func FillWithFakeSingles(dest [][]byte, nonce *[24]byte, nextKeys []*[32]byte) { ParallelFor(len(dest), func(p *P) { for i, ok := p.Next(); ok; i, ok = p.Next() { var exchange [SizeConvoExchange]byte rand.Read(exchange[:]) onion, _ := onionbox.Seal(exchange[:], nonce, nextKeys) dest[i] = onion } }) }
func (c *Conversation) NextConvoRequest(round uint32) *ConvoRequest { c.Lock() c.lastRound = round c.Unlock() go c.gui.Flush() var body interface{} select { case m := <-c.outQueue: body = &TextMessage{Message: m} default: body = &TimestampMessage{ Timestamp: time.Now(), } } msg := &ConvoMessage{ Body: body, } msgdata := msg.Marshal() var encmsg [SizeEncryptedMessage]byte ctxt := c.Seal(msgdata[:], round, c.myRole()) copy(encmsg[:], ctxt) exchange := &ConvoExchange{ DeadDrop: c.deadDrop(round), EncryptedMessage: encmsg, } onion, sharedKeys := onionbox.Seal(exchange.Marshal(), ForwardNonce(round), c.pki.ServerKeys().Keys()) pr := &pendingRound{ onionSharedKeys: sharedKeys, sentMessage: encmsg, } c.Lock() c.pendingRounds[round] = pr c.Unlock() return &ConvoRequest{ Round: round, Onion: onion, } }
func FillWithFakeIntroductions(dest [][]byte, noiseCounts []int, nonce *[24]byte, nextKeys []*[32]byte) { buckets := make([]int, len(dest)) idx := 0 for b, count := range noiseCounts { for i := 0; i < count; i++ { buckets[idx] = b idx++ } } ParallelFor(len(dest), func(p *P) { for i, ok := p.Next(); ok; i, ok = p.Next() { var exchange [SizeDialExchange]byte binary.BigEndian.PutUint32(exchange[0:4], uint32(buckets[i])) rand.Read(exchange[4:]) onion, _ := onionbox.Seal(exchange[:], nonce, nextKeys) dest[i] = onion } }) }