3 ms·
Also, the if c1 ~= c2 branch is obviously not constant-time, but in practice it’s close enough that it won’t matter for our case. I’d prefer XORing the two stri
by moonboots 13y ago
Also, the if c1 ~= c2 branch is obviously not constant-time, but in practice it’s close enough that it won’t matter for our case. I’d prefer XORing the two strings together and seeing if the result is 0, but Lua doesn’t seem to include a bitwise XOR operator. If I’m wrong on this, I would appreciate a correction.
LuaJIT provides bitwise operators out of the box [1], and the creator also provides an extension for regular lua [2].
[1] http://luajit.org/extensions.html http://luajit.org/extensions.html
[2] http://bitop.luajit.org/ http://bitop.luajit.org/
- StavrosK 13y agoThanks, our nginx is linked with 5.2, it turns out, it's just my test box that had 5.1/didn't support bitwise. I'll change the code, thanks.