mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-22 07:41:20 -04:00
added method for removign signatures in a PGP certificate, and a test program to test it. Not yet plugged in into RS
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4831 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7c11c6efac
commit
4422d6557b
6 changed files with 552 additions and 2 deletions
|
@ -8,11 +8,14 @@ DHT_TOP_DIR = ../../../../libbitdht/src
|
|||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = netsetup_test.o random_test.o memory_management_test.o
|
||||
TESTS = netsetup_test random_test memory_management_test
|
||||
TESTOBJ = netsetup_test.o random_test.o memory_management_test.o pgpkey_test.o
|
||||
TESTS = netsetup_test random_test memory_management_test pgpkey_test
|
||||
|
||||
all: tests
|
||||
|
||||
pgpkey_test: pgpkey_test.o
|
||||
$(CC) $(CFLAGS) -o pgpkey_test pgpkey_test.o $(LIBS)
|
||||
|
||||
netsetup_test: netsetup_test.o
|
||||
$(CC) $(CFLAGS) -o netsetup_test netsetup_test.o $(LIBS)
|
||||
|
||||
|
|
59
libretroshare/src/tests/general/pgpkey_test.cc
Normal file
59
libretroshare/src/tests/general/pgpkey_test.cc
Normal file
|
@ -0,0 +1,59 @@
|
|||
#ifdef LINUX
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "util/utest.h"
|
||||
#include "util/pgpkey.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifdef LINUX
|
||||
feenableexcept(FE_INVALID) ;
|
||||
feenableexcept(FE_DIVBYZERO) ;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
std::cerr << argv[0] << ": test gpg certificate cleaning method. " << std::endl;
|
||||
std::cerr << " Usage: " << argv[0] << " certificate.asc" << std::endl;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
FILE *f = fopen(argv[1],"r") ;
|
||||
|
||||
if(f == NULL)
|
||||
throw std::runtime_error(std::string("Could not open file ") + argv[1]) ;
|
||||
|
||||
std::string cert ;
|
||||
int c ;
|
||||
|
||||
while((c = getc(f) ) != EOF)
|
||||
cert += (char)c ;
|
||||
|
||||
std::cerr << "got this certificate: " << std::endl;
|
||||
std::cerr << cert << std::endl;
|
||||
|
||||
std::cerr << "Calling cert simplification code..." << std::endl;
|
||||
std::string cleaned_key ;
|
||||
|
||||
PGPKeyManagement::createMinimalKey(cert,cleaned_key) ;
|
||||
|
||||
std::cerr << "Minimal key produced: " << std::endl;
|
||||
std::cerr << cleaned_key << std::endl;
|
||||
FINALREPORT("pgpkey_test");
|
||||
exit(TESTRESULT());
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception never handled: " << e.what() << std::endl ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue