add ecies encrypt/decrypt support to common crypto

This commit is contained in:
subtly 2014-10-23 19:06:31 +02:00
parent 8f6314b923
commit ee062e564b
2 changed files with 19 additions and 17 deletions

View File

@ -21,23 +21,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"
#include <osrng.h>
#include <eccrypto.h> // secp256k1
#include <oids.h> // ec domain
#include <ecp.h> // ec prime field
#include <files.h> // cryptopp buffer
#include <aes.h>
#include <modes.h> // aes modes
#pragma warning(pop)
#pragma GCC diagnostic pop
#include <libdevcrypto/CryptoPP.h>
using namespace std;
using namespace CryptoPP;

View File

@ -37,6 +37,24 @@ using namespace CryptoPP;
BOOST_AUTO_TEST_SUITE(devcrypto)
BOOST_AUTO_TEST_CASE(common_crypt)
{
string message("Now is the time for all good persons to come to the aide of humanity.");
bytes m = asBytes(message);
bytesConstRef bcr(&m);
SecretKeyRef k;
bytes cipher;
encrypt(k.pub(), bcr, cipher);
assert(cipher != asBytes(message) && cipher.size() > 0);
bytes plain;
decrypt(k.sec(), bytesConstRef(&cipher), plain);
assert(asString(plain) == message);
assert(plain == asBytes(message));
}
BOOST_AUTO_TEST_CASE(cryptopp_vs_secp256k1)
{
ECIES<ECP>::Decryptor d(pp::PRNG(), pp::secp256k1());