Browse Source

Merge pull request #573 from ethereum/network

return when ciphertext empty
cl-refactor
Gav Wood 10 years ago
parent
commit
d61230ef15
  1. 6
      libdevcrypto/CryptoPP.cpp
  2. 8
      test/crypto.cpp

6
libdevcrypto/CryptoPP.cpp

@ -53,6 +53,12 @@ void Secp256k1::decrypt(Secret const& _k, bytes& io_text)
CryptoPP::ECIES<CryptoPP::ECP>::Decryptor d; CryptoPP::ECIES<CryptoPP::ECP>::Decryptor d;
initializeDLScheme(_k, d); initializeDLScheme(_k, d);
if (!io_text.size())
{
io_text.resize(1);
io_text[0] = 0;
}
size_t clen = io_text.size(); size_t clen = io_text.size();
bytes plain; bytes plain;
plain.resize(d.MaxPlaintextLength(io_text.size())); plain.resize(d.MaxPlaintextLength(io_text.size()));

8
test/crypto.cpp

@ -44,6 +44,14 @@ static CryptoPP::OID s_curveOID(CryptoPP::ASN1::secp256k1());
static CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP> s_params(s_curveOID); static CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP> s_params(s_curveOID);
static CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP>::EllipticCurve s_curve(s_params.GetCurve()); static CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP>::EllipticCurve s_curve(s_params.GetCurve());
BOOST_AUTO_TEST_CASE(cryptopp_patch)
{
KeyPair k = KeyPair::create();
bytes io_text;
s_secp256k1.decrypt(k.sec(), io_text);
BOOST_REQUIRE_EQUAL(io_text.size(), 0);
}
BOOST_AUTO_TEST_CASE(verify_secert) BOOST_AUTO_TEST_CASE(verify_secert)
{ {
h256 empty; h256 empty;

Loading…
Cancel
Save