mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 19:23:58 +02:00
Use unique_ptr for temp signature array
This commit is contained in:
parent
376a27cd51
commit
ecc3312114
1 changed files with 3 additions and 3 deletions
|
@ -654,7 +654,7 @@ QString Wallet::signWithKey(const QByteArray& text, const QString& key) {
|
|||
EC_KEY* ecPrivateKey = NULL;
|
||||
|
||||
if ((ecPrivateKey = readPrivateKey(keyFilePath()))) {
|
||||
unsigned char* sig = new unsigned char[ECDSA_size(ecPrivateKey)];
|
||||
const auto sig = std::make_unique<unsigned char[]>(ECDSA_size(ecPrivateKey));
|
||||
|
||||
unsigned int signatureBytes = 0;
|
||||
|
||||
|
@ -663,10 +663,10 @@ QString Wallet::signWithKey(const QByteArray& text, const QString& key) {
|
|||
QByteArray hashedPlaintext = QCryptographicHash::hash(text, QCryptographicHash::Sha256);
|
||||
|
||||
int retrn = ECDSA_sign(0, reinterpret_cast<const unsigned char*>(hashedPlaintext.constData()), hashedPlaintext.size(),
|
||||
sig, &signatureBytes, ecPrivateKey);
|
||||
sig.get(), &signatureBytes, ecPrivateKey);
|
||||
|
||||
EC_KEY_free(ecPrivateKey);
|
||||
QByteArray signature(reinterpret_cast<const char*>(sig), signatureBytes);
|
||||
QByteArray signature(reinterpret_cast<const char*>(sig.get()), signatureBytes);
|
||||
if (retrn != -1) {
|
||||
return signature.toBase64();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue