As mentioned in #24485, it would be useful to be able to jump forward in the cipher stream, for example for QUIC. We should add a SetCounter method to the new x/crypto/chacha20 package.
(In the CL above the SetCounter method is renamed to Advance.)
I think if I saw s.Advance(1) in code I don't think it would be immediately obvious to me whether the method call is trying to skip 1 byte of the keystream, increment the counter by 1, or set the value of the counter to 1.
I therefore wonder if we should call this something less ambiguous. AdvanceCounterTo perhaps?
Yeah, fair, naming things is hard. Let's just go back to SetCounter. The docs can explain the rollback behavior.
Change https://golang.org/cl/206638 mentions this issue: chacha20: add SetCounter method
Most helpful comment
(In the CL above the
SetCountermethod is renamed toAdvance.)I think if I saw
s.Advance(1)in code I don't think it would be immediately obvious to me whether the method call is trying to skip 1 byte of the keystream, increment the counter by 1, or set the value of the counter to 1.I therefore wonder if we should call this something less ambiguous.
AdvanceCounterToperhaps?