From 78d71e9cd6710b59ec4c2608fb37aeda66afdbce Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Fri, 7 Aug 2015 00:32:06 +0200 Subject: [PATCH] ed25519signers.cc scoped_ptr -> uniqe_ptr --- pdns/ed25519signers.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pdns/ed25519signers.cc b/pdns/ed25519signers.cc index e4208b6fe..3060b6a8a 100644 --- a/pdns/ed25519signers.cc +++ b/pdns/ed25519signers.cc @@ -7,8 +7,6 @@ extern "C" { #include "ext/ed25519/crypto_hash_sha512.h" } #include "dnssecinfra.hh" -#include -using boost::scoped_ptr; #define SECRETBYTES SECRETKEYBYTES-PUBLICKEYBYTES @@ -109,8 +107,8 @@ std::string ED25519DNSCryptoKeyEngine::sign(const std::string& msg) const { string hash=this->hash(msg); unsigned long long smlen = hash.length() + SIGNATUREBYTES; + std::unique_ptr sm(new unsigned char[smlen]); - scoped_ptr sm(new unsigned char[smlen]); crypto_sign(sm.get(), &smlen, (const unsigned char*)hash.c_str(), hash.length(), d_seckey); return string((const char*)sm.get(), SIGNATUREBYTES); @@ -118,22 +116,23 @@ std::string ED25519DNSCryptoKeyEngine::sign(const std::string& msg) const std::string ED25519DNSCryptoKeyEngine::hash(const std::string& orig) const { - unsigned char out[crypto_hash_sha512_BYTES]; - crypto_hash_sha512(out, (const unsigned char*)orig.c_str(), orig.length()); + std::unique_ptr out(new unsigned char[crypto_hash_sha512_BYTES]); - return string((char*)out, crypto_hash_sha512_BYTES); + crypto_hash_sha512(out.get(), (const unsigned char*)orig.c_str(), orig.length()); + + return string((const char*)out.get(), crypto_hash_sha512_BYTES); } bool ED25519DNSCryptoKeyEngine::verify(const std::string& msg, const std::string& signature) const { string hash=this->hash(msg); unsigned long long smlen = hash.length() + SIGNATUREBYTES; + std::unique_ptr sm(new unsigned char[smlen]); - scoped_ptr sm(new unsigned char[smlen]); memcpy(sm.get(), signature.c_str(), SIGNATUREBYTES); memcpy(sm.get() + SIGNATUREBYTES, hash.c_str(), hash.length()); - scoped_ptr m(new unsigned char[smlen]); + std::unique_ptr m(new unsigned char[smlen]); return crypto_sign_open(m.get(), &smlen, sm.get(), smlen, d_pubkey) == 0; } -- 2.40.0