Browse Source

cleanup headers

cl-refactor
subtly 10 years ago
parent
commit
bc1b47470f
  1. 5
      libdevcrypto/CryptoHeaders.h
  2. 28
      libdevcrypto/EC.h
  3. 16
      libdevcrypto/ECIES.h
  4. 6
      test/crypto.cpp

5
libdevcrypto/CryptoHeaders.h

@ -38,6 +38,11 @@
#include <pwdbased.h>
#include <modes.h>
#include <filters.h>
#include <eccrypto.h>
#include <ecp.h>
#include <files.h>
#include <osrng.h>
#include <oids.h>
#include <secp256k1/secp256k1.h>
#pragma warning(pop)
#pragma GCC diagnostic pop

28
libdevcrypto/EC.h

@ -23,22 +23,7 @@
#pragma once
#pragma warning(push)
#pragma warning(disable:4100 4244)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-Wunused-function"
#include <osrng.h>
#include <oids.h>
#include <filters.h>
#include <eccrypto.h>
#include <ecp.h>
#pragma warning(pop)
#pragma GCC diagnostic pop
#include "CryptoHeaders.h"
#include "Common.h"
namespace dev
@ -46,16 +31,9 @@ namespace dev
namespace crypto
{
inline CryptoPP::AutoSeededRandomPool& PRNG()
{
static CryptoPP::AutoSeededRandomPool prng;
return prng;
}
inline CryptoPP::AutoSeededRandomPool& PRNG() { static CryptoPP::AutoSeededRandomPool prng; return prng; }
inline CryptoPP::OID secp256k1()
{
return CryptoPP::ASN1::secp256k1();
}
inline CryptoPP::OID secp256k1() { return CryptoPP::ASN1::secp256k1(); }
class ECKeyPair
{

16
libdevcrypto/ECIES.h

@ -23,21 +23,8 @@
#pragma once
#pragma warning(push)
#pragma warning(disable:4100 4244)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wextra"
#include <eccrypto.h>
#include <ecp.h>
#include <files.h>
#include <filters.h>
#pragma warning(pop)
#pragma GCC diagnostic pop
#include <libdevcore/Exceptions.h>
#include "CryptoHeaders.h"
#include "Common.h"
namespace dev
@ -77,3 +64,4 @@ private:
}
}

6
test/crypto.cpp

@ -43,12 +43,16 @@ BOOST_AUTO_TEST_CASE(ecies)
ECKeyPair k = ECKeyPair::create();
string message("Now is the time for all good men to come to the aide of humanity.");
bytes b = bytesConstRef(message).toBytes();
bytes b = bytesRef(message).toBytes();
ECIESEncryptor(&k).encrypt(b);
bytesConstRef br(&b);
bytes plain = ECIESDecryptor(&k).decrypt(br);
// ideally, decryptor will go a step further, accept a bytesRef and zero input.
assert(plain != b);
// plaintext is same as output
assert(plain == bytesConstRef(message).toBytes());
}

Loading…
Cancel
Save