Page 1 of 1

Ror() & Rol() bugged on Linux

Posted: Tue Apr 27, 2021 10:18 am
by Allanon
Hello Andreas,
I took me 2 days to identify why my encryption routines worked on Windows but not on Linux (Linux Mint 9, x64).
Finally I've found a small script that demonstrate the bug:

Code: Select all

Local a = 72
Local b = 111
Local c = Ror(a, b, #BYTE)
DebugPrint(a .. " ror " .. b .. " = " .. c)
DebugPrompt("?")
Run on Windows and you get:

Code: Select all

72 ror 111 = 144
?
Compile and run on Linux and you get:

Code: Select all

72 ror 111 = 0
?
btw setting 'b' with a smaller value (for example 5) it works the same way on both Windows & Linux

Re: Ror() & Rol() bugged on Linux

Posted: Sat May 01, 2021 10:08 pm
by airsoftsoftwair
Thanks for the report, fixed now!

Code: Select all

- Fix: Ror() and Rol() didn't return correct results when the rotation count was greater than the rotation bit length 
As a workaround, just make sure the rotation cycle count is not bigger than rotation bit length by applying a modulo division first, e.g.

Code: Select all

Local a = 72
Local b = 111
Local c = Ror(a, b%8, #BYTE)
DebugPrint(a .. " ror " .. b .. " = " .. c)
DebugPrompt("?")

Re: Ror() & Rol() bugged on Linux

Posted: Sun May 02, 2021 8:27 am
by Allanon
Thank you!
:)