From bc1b47470fa3b60d7a492abe978b5cd4e8a6da6d Mon Sep 17 00:00:00 2001 From: subtly Date: Sat, 18 Oct 2014 23:01:42 +0200 Subject: [PATCH] cleanup headers --- libdevcrypto/CryptoHeaders.h | 5 +++++ libdevcrypto/EC.h | 28 +++------------------------- libdevcrypto/ECIES.h | 18 +++--------------- test/crypto.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/libdevcrypto/CryptoHeaders.h b/libdevcrypto/CryptoHeaders.h index 333c03a2f..79fc517cd 100644 --- a/libdevcrypto/CryptoHeaders.h +++ b/libdevcrypto/CryptoHeaders.h @@ -38,6 +38,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #pragma warning(pop) #pragma GCC diagnostic pop diff --git a/libdevcrypto/EC.h b/libdevcrypto/EC.h index 5db0cb4bf..1f3bd6d26 100644 --- a/libdevcrypto/EC.h +++ b/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 -#include -#include -#include -#include -#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 { diff --git a/libdevcrypto/ECIES.h b/libdevcrypto/ECIES.h index 0c2c386a5..376942f4c 100644 --- a/libdevcrypto/ECIES.h +++ b/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 -#include -#include -#include -#pragma warning(pop) -#pragma GCC diagnostic pop #include +#include "CryptoHeaders.h" #include "Common.h" namespace dev @@ -76,4 +63,5 @@ private: }; } -} \ No newline at end of file +} + diff --git a/test/crypto.cpp b/test/crypto.cpp index 428fcb270..484b8714d 100644 --- a/test/crypto.cpp +++ b/test/crypto.cpp @@ -41,14 +41,18 @@ BOOST_AUTO_TEST_SUITE(devcrypto) 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()); }