maint: update utils
This commit is contained in:
parent
79eb70c882
commit
cc464cafc4
@ -21,7 +21,7 @@ constexpr const char* get_build_number() {
|
|||||||
|
|
||||||
const char* get_version_string() {
|
const char* get_version_string() {
|
||||||
const auto* result = utils::string::va(
|
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<const char*>(0x6A1574));
|
reinterpret_cast<const char*>(0x6A1574));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -225,7 +225,9 @@ std::string ecc::sign_message(const key& key, const std::string& message) {
|
|||||||
std::uint8_t buffer[512];
|
std::uint8_t buffer[512];
|
||||||
unsigned long length = sizeof(buffer);
|
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());
|
prng_.get_state(), prng_.get_id(), &key.get());
|
||||||
|
|
||||||
return {cs(buffer), length};
|
return {cs(buffer), length};
|
||||||
@ -236,9 +238,11 @@ bool ecc::verify_message(const key& key, const std::string& message,
|
|||||||
if (!key.is_valid())
|
if (!key.is_valid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const auto hash = sha512::compute(message);
|
||||||
|
|
||||||
auto result = 0;
|
auto result = 0;
|
||||||
return (ecc_verify_hash(cs(signature.data()), ul(signature.size()),
|
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 &&
|
&key.get()) == CRYPT_OK &&
|
||||||
result != 0);
|
result != 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user