From cc464cafc4d80a14c5e65c9632140c7502308567 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Tue, 30 May 2023 15:56:55 +0200 Subject: [PATCH] maint: update utils --- src/client/component/branding.cpp | 2 +- src/common/utils/cryptography.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index bd87001..bb5d44c 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -21,7 +21,7 @@ constexpr const char* get_build_number() { const char* get_version_string() { const auto* result = utils::string::va( - "{} {} build {} {}", BUILD_TYPE, "(Alpha)", get_build_number(), + "{0} {1} build {2} {3}", BUILD_TYPE, "(Alpha)", get_build_number(), reinterpret_cast(0x6A1574)); return result; diff --git a/src/common/utils/cryptography.cpp b/src/common/utils/cryptography.cpp index c81a9b0..8483ec8 100644 --- a/src/common/utils/cryptography.cpp +++ b/src/common/utils/cryptography.cpp @@ -225,7 +225,9 @@ std::string ecc::sign_message(const key& key, const std::string& message) { std::uint8_t buffer[512]; unsigned long length = sizeof(buffer); - ecc_sign_hash(cs(message.data()), ul(message.size()), buffer, &length, + const auto hash = sha512::compute(message); + + ecc_sign_hash(cs(hash.data()), ul(hash.size()), buffer, &length, prng_.get_state(), prng_.get_id(), &key.get()); return {cs(buffer), length}; @@ -236,9 +238,11 @@ bool ecc::verify_message(const key& key, const std::string& message, if (!key.is_valid()) return false; + const auto hash = sha512::compute(message); + auto result = 0; return (ecc_verify_hash(cs(signature.data()), ul(signature.size()), - cs(message.data()), ul(message.size()), &result, + cs(hash.data()), ul(hash.size()), &result, &key.get()) == CRYPT_OK && result != 0); }