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

core: replace manual endianness swap with htobe64() call

This fixes generation of TOTP and tests on FreeBSD.
This commit is contained in:
LuK1337
2024-08-14 12:15:55 +02:00
committed by Sébastien Helleu
parent 17d225ad73
commit 5b58356390
2 changed files with 6 additions and 14 deletions
+1
View File
@@ -52,6 +52,7 @@
- core: fix crash when deleting a bar that has no items ([#2138](https://github.com/weechat/weechat/issues/2138))
- relay/api: fix crash when sending data to a remote buffer when the remote has been deleted ([#2157](https://github.com/weechat/weechat/issues/2157))
- irc, xfer: fix display of input prompt in IRC private buffers and DCC chat buffers ([#2128](https://github.com/weechat/weechat/issues/2128))
- core: fix generation of TOTP on FreeBSD ([#2171](https://github.com/weechat/weechat/issues/2171))
- core: apply buffer properties (options weechat.buffer.*) when a buffer name is changed
- irc: fix property "short_name" of channel buffer when the joined channel has a different case than the `/join` command
- irc: close /list buffer when the server buffer is closed ([#2121](https://github.com/weechat/weechat/issues/2121))
+5 -14
View File
@@ -38,6 +38,10 @@
#include "core-string.h"
#include "../plugins/plugin.h"
#ifdef htonll
#define htobe64 htonll
#endif
char *weecrypto_hash_algo_string[] = {
"crc32",
"md5",
@@ -520,20 +524,7 @@ 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)
| ((moving_factor << 8) & 0x000000FF00000000)
| ((moving_factor >> 8) & 0x00000000FF000000)
| ((moving_factor >> 24) & 0x0000000000FF0000)
| ((moving_factor >> 40) & 0x000000000000FF00)
| (moving_factor << 56);
#endif
moving_factor_swapped = htobe64 (moving_factor);
rc = weecrypto_hmac (secret, length_secret,
&moving_factor_swapped, sizeof (moving_factor_swapped),
GCRY_MD_SHA1,