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 9621c4381b
commit 64403cefc1
2 changed files with 12 additions and 0 deletions
+7
View File
@@ -10,6 +10,13 @@ This document lists all the changes for each version. +
For a list of important changes that require manual actions, please look at release notes.
[[v4.0.6]]
== Version 4.0.6 (under dev)
Bug fixes::
* core: fix generation of TOTP on Big Endian systems (issue #2021)
[[v4.0.5]]
== Version 4.0.5 (2023-09-24)
+5
View File
@@ -421,6 +421,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)
@@ -429,6 +433,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),