def rc4.next

bend-osdev-legacy-ciphers@0.1.0.0 · rc4.bend:95

import bend-osdev-legacy-ciphers@0.1.0.0/rc4.bend as Rc4
import Base

95#   i = i + 1; j = j + S[i]; swap S[i] and S[j]; the byte S[S[i] + S[j]]
96def rc4.next(st: LcRc4State) -> LcRc4Step:
97  match st:
98    case LcRc4State{+s, i, j}:
99      +i2 = U32.and(255, U32.add(i, 1))
100      +j2 = U32.and(255, U32.add(j, rc4.at(s, i2)))
101      +s2 = rc4.swap(s, i2, j2)
102      LcRc4Step{LcRc4State{s2, i2, j2}, rc4.at(s2, U32.and(255, U32.add(rc4.at(s2, i2), rc4.at(s2, j2))))}

Uses (6)

Used by (9)