Exemplo n.º 1
0
func FillWithFakeDoubles(dest [][]byte, nonce *[24]byte, nextKeys []*[32]byte) {
	concurrency.ParallelFor(len(dest)/2, func(p *concurrency.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
		}
	})
}
Exemplo n.º 2
0
func (srv *ConvoService) Get(args *ConvoGetArgs, result *ConvoGetResult) error {
	log.WithFields(log.Fields{"service": "convo", "rpc": "Get", "round": args.Round, "count": args.Count}).Debug()

	round, err := srv.getRound(args.Round, convoRoundClosed)
	if err != nil {
		return err
	}

	nonce := BackwardNonce(args.Round)
	outgoingOnionSize := srv.PKI.OutgoingOnionOverhead(srv.ServerName) + SizeEncryptedMessage

	result.Onions = make([][]byte, args.Count)
	for k := range result.Onions {
		i := args.Offset + k

		if v := round.incomingIndex[i]; v > -1 {
			reply := round.replies[v]
			onion := box.SealAfterPrecomputation(nil, reply, nonce, round.sharedKeys[i])
			result.Onions[k] = onion
		}
		if len(result.Onions[k]) != outgoingOnionSize {
			onion := make([]byte, outgoingOnionSize)
			rand.Read(onion)
			result.Onions[k] = onion
		}
	}

	return nil
}
Exemplo n.º 3
0
func FillWithFakeSingles(dest [][]byte, nonce *[24]byte, nextKeys []*[32]byte) {
	concurrency.ParallelFor(len(dest), func(p *concurrency.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
		}
	})
}
Exemplo n.º 4
0
func FillWithFakeIntroductions(dest [][]byte, noiseCounts []uint32, nonce *[24]byte, nextKeys []*[32]byte) {
	buckets := make([]int, len(dest))
	idx := 0
	for b, count := range noiseCounts {
		for i := uint32(0); i < count; i++ {
			buckets[idx] = b
			idx++
		}
	}

	concurrency.ParallelFor(len(dest), func(p *concurrency.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
		}
	})
}