Change three lines of code. Fix one thing. Break another.

This commit is contained in:
Zach Fox 2017-12-20 15:40:10 -08:00
parent b6d8434b55
commit a2f2c23337

View file

@ -2513,7 +2513,8 @@ bool EntityItemProperties::verifySignature(const QString& publicKey, const QByte
return false; return false;
} }
const unsigned char* key = reinterpret_cast<const unsigned char*>(publicKey.toUtf8().constData()); auto keyByteArray = publicKey.toUtf8();
auto key = keyByteArray.constData();
int keyLength = publicKey.length(); int keyLength = publicKey.length();
BIO *bio = BIO_new_mem_buf((void*)key, keyLength); BIO *bio = BIO_new_mem_buf((void*)key, keyLength);
@ -2531,14 +2532,14 @@ bool EntityItemProperties::verifySignature(const QString& publicKey, const QByte
// ECSDA verification prototype: note that type is currently ignored // ECSDA verification prototype: note that type is currently ignored
// int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, // int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
// const unsigned char *sig, int siglen, EC_KEY *eckey); // const unsigned char *sig, int siglen, EC_KEY *eckey);
bool answer = ECDSA_verify(0, int answer = ECDSA_verify(0,
digest, digest,
digestLength, digestLength,
signature, signature,
signatureLength, signatureLength,
ec); ec);
long error = ERR_get_error(); long error = ERR_get_error();
if (error != 0) { if (error != 0 || answer == -1) {
const char* error_str = ERR_error_string(error, NULL); const char* error_str = ERR_error_string(error, NULL);
qCWarning(entities) << "ERROR while verifying signature! EC error:" << error_str qCWarning(entities) << "ERROR while verifying signature! EC error:" << error_str
<< "\nKey:" << publicKey << "\nutf8 Key Length:" << keyLength << "\nKey:" << publicKey << "\nutf8 Key Length:" << keyLength
@ -2552,7 +2553,7 @@ bool EntityItemProperties::verifySignature(const QString& publicKey, const QByte
if (evp_key) { if (evp_key) {
EVP_PKEY_free(evp_key); EVP_PKEY_free(evp_key);
} }
return answer; return (answer == 1);
} else { } else {
if (bio) { if (bio) {
BIO_free(bio); BIO_free(bio);