diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-07 17:29:35 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-07 17:29:35 +0200 |
commit | fd5f42dc062aa689a1fa244dcd45d2cffa0d499a (patch) | |
tree | e4af491363d041ad437af0541a89ea4c08972313 /src | |
parent | ec8c4cc0423651bb010634724868836a498391c2 (diff) | |
download | weechat-fd5f42dc062aa689a1fa244dcd45d2cffa0d499a.zip |
relay/api: fix authentication with remote using hash algorithm "sha256" or "sha512"
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/relay/api/remote/relay-remote-network.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/relay/api/remote/relay-remote-network.c b/src/plugins/relay/api/remote/relay-remote-network.c index c374873fd..79c6561c7 100644 --- a/src/plugins/relay/api/remote/relay-remote-network.c +++ b/src/plugins/relay/api/remote/relay-remote-network.c @@ -612,6 +612,7 @@ relay_remote_network_connect_ws_auth (struct t_relay_remote *remote) char hash[512 / 8], hash_hexa[((512 / 8) * 2) + 1]; char ws_key[16], ws_key_base64[64]; int length, hash_size; + time_t time_now; relay_remote_set_status (remote, RELAY_STATUS_AUTHENTICATING); @@ -631,6 +632,8 @@ relay_remote_network_connect_ws_auth (struct t_relay_remote *remote) if (!totp_secret) goto end; + time_now = time (NULL); + switch (remote->password_hash_algo) { case RELAY_AUTH_PASSWORD_HASH_PLAIN: @@ -642,10 +645,7 @@ relay_remote_network_connect_ws_auth (struct t_relay_remote *remote) salt_password = malloc (length); if (salt_password) { - snprintf (salt_password, length, - "%ld%s", - time (NULL), - password); + snprintf (salt_password, length, "%ld%s", time_now, password); if (weechat_crypto_hash ( salt_password, strlen (salt_password), relay_auth_password_hash_algo_name[remote->password_hash_algo], @@ -653,14 +653,17 @@ relay_remote_network_connect_ws_auth (struct t_relay_remote *remote) { weechat_string_base_encode ("16", hash, hash_size, hash_hexa); snprintf (str_auth, sizeof (str_auth), - "hash:%s", hash_hexa); + "hash:%s:%ld:%s", + relay_auth_password_hash_algo_name[remote->password_hash_algo], + time_now, + hash_hexa); } free (salt_password); } break; case RELAY_AUTH_PASSWORD_HASH_PBKDF2_SHA256: case RELAY_AUTH_PASSWORD_HASH_PBKDF2_SHA512: - snprintf (salt, sizeof (salt), "%ld", time (NULL)); + snprintf (salt, sizeof (salt), "%ld", time_now); if (weechat_crypto_hash_pbkdf2 ( password, strlen (password), |