diff --git a/src/crypto/crypto.go b/src/crypto/crypto.go index e85493f0..75736ba7 100644 --- a/src/crypto/crypto.go +++ b/src/crypto/crypto.go @@ -172,7 +172,6 @@ func BoxOpen(shared *BoxSharedKey, boxed []byte, nonce *BoxNonce) ([]byte, bool) { out := util.GetBytes() - //return append(out, boxed...), true //FIXME disabled crypto for benchmarking s := (*[BoxSharedKeyLen]byte)(shared) n := (*[BoxNonceLen]byte)(nonce) unboxed, success := box.OpenAfterPrecomputation(out, boxed, n, s) @@ -185,7 +184,6 @@ func BoxSeal(shared *BoxSharedKey, unboxed []byte, nonce *BoxNonce) ([]byte, *Bo } nonce.Increment() out := util.GetBytes() - //return append(out, unboxed...), nonce // FIXME disabled crypto for benchmarking s := (*[BoxSharedKeyLen]byte)(shared) n := (*[BoxNonceLen]byte)(nonce) boxed := box.SealAfterPrecomputation(out, unboxed, n, s) diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index c17fb045..c39f60de 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -463,8 +463,8 @@ func (sinfo *sessionInfo) recvWorker() { ch := make(chan func(), 1) poolFunc := func() { bs, isOK = crypto.BoxOpen(&k, p.Payload, &p.Nonce) - util.PutBytes(p.Payload) callback := func() { + util.PutBytes(p.Payload) if !isOK { util.PutBytes(bs) return @@ -539,11 +539,14 @@ func (sinfo *sessionInfo) sendWorker() { // Encrypt the packet p.Payload, _ = crypto.BoxSeal(&k, bs, &p.Nonce) packet := p.encode() - // Cleanup - util.PutBytes(bs) - util.PutBytes(p.Payload) // The callback will send the packet - callback := func() { sinfo.core.router.out(packet) } + callback := func() { + // Cleanup + util.PutBytes(bs) + util.PutBytes(p.Payload) + // Send the packet + sinfo.core.router.out(packet) + } ch <- callback } // Send to the worker and wait for it to finish