diff --git a/libslunkcrypt/src/slunkcrypt.c b/libslunkcrypt/src/slunkcrypt.c index c6b71dc..1eef425 100644 --- a/libslunkcrypt/src/slunkcrypt.c +++ b/libslunkcrypt/src/slunkcrypt.c @@ -297,7 +297,8 @@ static FORCE_INLINE uint8_t process_encrypt(crypt_state_t* const crypt_state, ui size_t i; for (i = 0U; i < 256U; ++i) { - value = crypt_state->wheel_fwd[i][(value + crypt_state->rotation_fwd[i]) & 0xFF]; + const uint8_t rotation = crypt_state->rotation_fwd[i]; + value = (crypt_state->wheel_fwd[i][(value + rotation) & 0xFF] - rotation) & 0xFF; } ++crypt_state->rotation_fwd[crypt_state->step_fwd[crypt_state->counter]]; odometer_step(crypt_state->rotation_fwd, 0); @@ -310,7 +311,8 @@ static FORCE_INLINE uint8_t process_decrypt(crypt_state_t* const crypt_state, ui size_t i; for (i = 0U; i < 256U; ++i) { - value = (crypt_state->wheel_bwd[i][value] - crypt_state->rotation_bwd[i]) & 0xFF; + const uint8_t rotation = crypt_state->rotation_bwd[i]; + value = (crypt_state->wheel_bwd[i][(value + rotation) & 0xFF] - rotation) & 0xFF; } ++crypt_state->rotation_bwd[crypt_state->step_bwd[crypt_state->counter]]; odometer_step(crypt_state->rotation_bwd, 1);