aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2014-10-24 01:06:31 +0800
committersubtly <subtly@users.noreply.github.com>2014-10-24 01:06:31 +0800
commitee062e564b4cac38a14d755abcde1c68b3ad8b53 (patch)
treea340bbea6537bbc20a16ec1d41ab62595ec5f4ff
parent8f6314b923efd4b7e3d39e53c8a1cdb518a160bf (diff)
downloaddexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.gz
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.bz2
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.lz
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.xz
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.zst
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.zip
add ecies encrypt/decrypt support to common crypto
-rw-r--r--TestHelperCrypto.h18
-rw-r--r--crypto.cpp18
2 files changed, 19 insertions, 17 deletions
diff --git a/TestHelperCrypto.h b/TestHelperCrypto.h
index 24104f11..01e97c21 100644
--- a/TestHelperCrypto.h
+++ b/TestHelperCrypto.h
@@ -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;
diff --git a/crypto.cpp b/crypto.cpp
index 40e0a6a4..3662bb83 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -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());