From: Kees Monshouwer Date: Wed, 23 Dec 2015 23:58:49 +0000 (+0100) Subject: Fix "random" ECDSA signature failures when using cryptopp X-Git-Tag: dnsdist-1.0.0-alpha1~1^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b995f453fe7eccb593e317b4f249cf14eaf4e091;p=pdns Fix "random" ECDSA signature failures when using cryptopp --- diff --git a/pdns/cryptoppsigners.cc b/pdns/cryptoppsigners.cc index 348ac8124..df4241da8 100644 --- a/pdns/cryptoppsigners.cc +++ b/pdns/cryptoppsigners.cc @@ -80,8 +80,9 @@ DNSCryptoKeyEngine::storvector_t CryptoPPECDSADNSCryptoKeyEngineGetPrivateExponent(); - unsigned char buffer[pe.MinEncodedSize()]; - pe.Encode(buffer, pe.MinEncodedSize()); + size_t len = BITS/8; + unsigned char buffer[len]; + pe.Encode(buffer, len); storvect.push_back(make_pair("PrivateKey", string((char*)buffer, sizeof(buffer)))); return storvect; } @@ -117,11 +118,12 @@ std::string CryptoPPECDSADNSCryptoKeyEngine::getPublicKeyStri const CryptoPP::Integer& qx = q.x; const CryptoPP::Integer& qy = q.y; - - unsigned char buffer[qx.MinEncodedSize() + qy.MinEncodedSize()]; - qx.Encode(buffer, qx.MinEncodedSize()); - qy.Encode(buffer + qx.MinEncodedSize(), qy.MinEncodedSize()); - + + size_t len = BITS/8; + unsigned char buffer[len*2]; + qx.Encode(buffer, len); + qy.Encode(buffer + len, len); + return string((char*)buffer, sizeof(buffer)); } template