From 0d561148692baec894d5ed70a0fd56b11dfc5f27 Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Thu, 5 Dec 2024 18:13:23 +0800 Subject: [PATCH] zuc: eea XORKeyStreamAt avoid useless calculation --- zuc/eea.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zuc/eea.go b/zuc/eea.go index 6044d8c..0d32110 100644 --- a/zuc/eea.go +++ b/zuc/eea.go @@ -134,9 +134,11 @@ func (c *eea) XORKeyStreamAt(dst, src []byte, offset uint64) { } // consumed all remaining key bytes first - c.used += uint64(c.xLen) - offsetDiff -= uint64(c.xLen) - c.xLen = 0 + if c.xLen > 0 { + c.used += uint64(c.xLen) + offsetDiff -= uint64(c.xLen) + c.xLen = 0 + } // forward the state to the offset stepLen := uint64(RoundBytes)