From 311a9652d4437e3e8738f00554dfc5abb868ce7c Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 13 Aug 2013 13:57:16 -0400 Subject: [PATCH] bug fixes and tests for aes --- CMakeLists.txt | 2 ++ include/fc/crypto/aes.hpp | 3 ++- tests/aes_test.cpp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/aes_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fa1840c..901a70e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,4 +134,6 @@ set( BOOST_LIBRARIES ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FIL #add_executable( test_compress tests/compress.cpp ) #target_link_libraries( test_compress fc ${BOOST_LIBRARIES} ) +#add_executable( test_aes tests/aes_test.cpp ) +#target_link_libraries( test_aes fc ${BOOST_LIBRARIES} ) diff --git a/include/fc/crypto/aes.hpp b/include/fc/crypto/aes.hpp index a840be7..7a7bfa7 100644 --- a/include/fc/crypto/aes.hpp +++ b/include/fc/crypto/aes.hpp @@ -1,5 +1,6 @@ #pragma once -#include +#include +#include namespace fc { diff --git a/tests/aes_test.cpp b/tests/aes_test.cpp new file mode 100644 index 0000000..00fc016 --- /dev/null +++ b/tests/aes_test.cpp @@ -0,0 +1,31 @@ +#include +#include +#include + +int main( int argc, char** ) +{ + std::string line; + std::getline( std::cin, line ); + auto key = fc::sha512::hash( "hello", 5 ); + while( std::cin && line != "q" ) + { + try { + std::vector data( line.c_str(),line.c_str()+line.size()+1 ); + std::vector crypt = fc::aes_encrypt( key, data ); + std::vector dcrypt = fc::aes_decrypt( key, crypt ); + + std::cout<<"line.size: '"<