From e27c13284f119447af815b5608e6cab48b10ece5 Mon Sep 17 00:00:00 2001 From: dagger Date: Sat, 22 Aug 2026 16:07:59 +0700 Subject: [PATCH] fix p256 public key --- src/crypto/Crypto.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/crypto/Crypto.cpp b/src/crypto/Crypto.cpp index 169f94d65..72f92366a 100644 --- a/src/crypto/Crypto.cpp +++ b/src/crypto/Crypto.cpp @@ -811,23 +811,13 @@ namespace crypto { ) != static_cast(privateSize)) { fail("ECDSA private key encoding failed"); } - std::size_t publicSize = 0; - if (EVP_PKEY_get_octet_string_param( - key.get(), OSSL_PKEY_PARAM_PUB_KEY, nullptr, 0, &publicSize - ) != 1) { - fail("ECDSA public key size query failed"); - } - result.publicKey.resize(publicSize); - if (EVP_PKEY_get_octet_string_param( - key.get(), - OSSL_PKEY_PARAM_PUB_KEY, - result.publicKey.data(), - result.publicKey.size(), - &publicSize - ) != 1) { - fail("ECDSA public key export failed"); - } - result.publicKey.resize(publicSize); + result.publicKey = ecPrivateKey( + curve, + std::string_view( + reinterpret_cast(result.privateKey.data()), + result.privateKey.size() + ) + ).publicKey; return result; }