From a37d3434104306a99801bba831a14ecb98994220 Mon Sep 17 00:00:00 2001 From: jeka Date: Sun, 1 Mar 2026 17:55:33 +0300 Subject: [PATCH] 1 --- src/secure_channel.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/secure_channel.c b/src/secure_channel.c index b6336fa..d7cd2b8 100644 --- a/src/secure_channel.c +++ b/src/secure_channel.c @@ -823,27 +823,22 @@ sc_status_t sc_sha_transcode(const uint8_t *key, size_t key_len, uint8_t *data, } sc_status_t sc_obfuscate_pubkey(const uint8_t *salt, const uint8_t *peer_pubkey, const uint8_t *pubkey, uint8_t *output) { - if (!salt || !peer_pubkey || !pubkey || !output) { - return SC_ERR_INVALID_ARG; - } + if (!salt || !peer_pubkey || !pubkey || !output) return SC_ERR_INVALID_ARG; - uint8_t sha1[SC_HASH_SIZE]; - uint8_t sha2[SC_HASH_SIZE]; + uint8_t sha[SC_HASH_SIZE*2]; SC_SHA256_CTX ctx; sc_sha256_init(&ctx); sc_sha256_update(&ctx, salt, SC_PUBKEY_ENC_SALT_SIZE); sc_sha256_update(&ctx, peer_pubkey, SC_PUBKEY_SIZE); - sc_sha256_final(&ctx, sha1); + sc_sha256_final(&ctx, sha); sc_sha256_init(&ctx); sc_sha256_update(&ctx, peer_pubkey, SC_PUBKEY_SIZE); sc_sha256_update(&ctx, salt, SC_PUBKEY_ENC_SALT_SIZE); - sc_sha256_final(&ctx, sha2); + sc_sha256_final(&ctx, sha+SC_HASH_SIZE); - for (size_t i = 0; i < SC_PUBKEY_SIZE; i++) { - output[i] = pubkey[i] ^ sha1[i] ^ sha2[i]; - } + for (size_t i = 0; i < SC_PUBKEY_SIZE; i++) output[i] = pubkey[i] ^ sha[i]; return SC_OK; }