1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core: fix TOTP moving factor on big-endian systems

This commit is contained in:
LuK1337
2023-09-24 21:36:11 +02:00
committed by Sébastien Helleu
parent 169eecb5cf
commit bcd23ff585
+5
View File
@@ -524,6 +524,10 @@ weecrypto_totp_generate_internal (const char *secret, int length_secret,
int rc, offset, length;
unsigned long bin_code;
#if __BYTE_ORDER == __BIG_ENDIAN
/* Big endian does not need to swap bytes here! */
moving_factor_swapped = moving_factor;
#else
moving_factor_swapped = (moving_factor >> 56)
| ((moving_factor << 40) & 0x00FF000000000000)
| ((moving_factor << 24) & 0x0000FF0000000000)
@@ -532,6 +536,7 @@ weecrypto_totp_generate_internal (const char *secret, int length_secret,
| ((moving_factor >> 24) & 0x0000000000FF0000)
| ((moving_factor >> 40) & 0x000000000000FF00)
| (moving_factor << 56);
#endif
rc = weecrypto_hmac (secret, length_secret,
&moving_factor_swapped, sizeof (moving_factor_swapped),