diff --git a/src/lib/src/public/easyssl/ecdsassl.cpp b/src/lib/src/public/easyssl/ecdsassl.cpp index 8a59bfe..4173e8e 100644 --- a/src/lib/src/public/easyssl/ecdsassl.cpp +++ b/src/lib/src/public/easyssl/ecdsassl.cpp @@ -103,15 +103,7 @@ QByteArray ECDSASSL::signMessage(const QByteArray &inputData, return {}; } - size_t signatureLength = 0; - // Determine the length of the signature - if (EVP_DigestSignFinal(mdctx, nullptr, &signatureLength) != 1) { - EasySSLUtils::printlastOpenSSlError(); - - EVP_MD_CTX_free(mdctx); - return {}; - } - + size_t signatureLength = EVP_PKEY_size(ecPrivateKey); signature.resize(signatureLength); // Perform the final signing operation and obtain the signature @@ -122,6 +114,8 @@ QByteArray ECDSASSL::signMessage(const QByteArray &inputData, return {}; } + signature.resize(signatureLength); + EVP_MD_CTX_free(mdctx); return signature; } diff --git a/src/lib/src/public/easyssl/rsassl.cpp b/src/lib/src/public/easyssl/rsassl.cpp index 83e497f..38c0174 100644 --- a/src/lib/src/public/easyssl/rsassl.cpp +++ b/src/lib/src/public/easyssl/rsassl.cpp @@ -80,14 +80,7 @@ QByteArray RSASSL::signMessage(const QByteArray &inputData, const QByteArray &ke return {}; } - size_t signatureLength = 0; - // Determine the length of the signature - if (EVP_DigestSignFinal(mdctx, nullptr, &signatureLength) != 1) { - EasySSLUtils::printlastOpenSSlError(); - EVP_MD_CTX_free(mdctx); - return {}; - } - + size_t signatureLength = EVP_PKEY_size(rsaPrivateKey); signature.resize(signatureLength); // Perform the final signing operation and obtain the signature @@ -97,6 +90,8 @@ QByteArray RSASSL::signMessage(const QByteArray &inputData, const QByteArray &ke return {}; } + signature.resize(signatureLength); + EVP_MD_CTX_free(mdctx); return signature; }