/* * "$Id: dirtest.cc,v 1.1 2007-02-19 20:08:30 rmf24 Exp $" * * RetroShare C++ Interface. * * Copyright 2012-2012 by Cyril Soler * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License Version 2 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * * Please report all bugs and problems to "retroshare@lunamutt.com". * */ #include "util/rsaes.h" #include "util/utest.h" #include #include #include #include #include void printHelp(int argc,char *argv[]) { std::cerr << argv[0] << ": tests AES encryption/decryption functions." << std::endl; std::cerr << "Usage: " << argv[0] << std::endl ; } void printHex(unsigned char *data,uint32_t length) { static const char outh[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ; static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ; for(uint32_t j = 0; j < length; j++) { std::cerr << outh[ (data[j]>>4) ] ; std::cerr << outh[ data[j] & 0xf ] ; } } INITTEST() ; int main(int argc,char *argv[]) { std::string inputfile ; argstream as(argc,argv) ; as >> help() ; as.defaultErrorHandling() ; std::cerr << "Testing AES crypt" << std::endl; std::string source_string = "This is a very secret string, but ultimately it will always be decyphered" ; std::cerr << "Input string: length=" << source_string.length() << ", s=\"" << source_string << "\"" << std::endl; unsigned char key_data[16] ; unsigned char salt[8] ; for(int i=0;i<16;++i) key_data[i] = lrand48() & 0xff ; std::cerr << "Key: " ; printHex(key_data,16); std::cerr << std::endl; for(int i=5;i