rotest.cpp File Reference

Contains a unitary test of the random oracle, i.e. the cryptoTools::RO class. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include "cryptotools.hpp"

Go to the source code of this file.

Functions

void printBytes (std::vector< uint8_t > v)
int main (void)

Detailed Description

Contains a unitary test of the random oracle, i.e. the cryptoTools::RO class.

Author
Léo Perrin
Date
Time-stamp: <2012-08-26 00:08:10 leo>

This test is a unitary test since the behaviour of this class basically boils down to outputing numbers. Note however that the only for only one number for each hashfunction is used: this is not a lot.

Definition in file rotest.cpp.

Function Documentation

int main ( void  )

Definition at line 33 of file rotest.cpp.

{
SHAx * hash;
RO * ro;
std::vector<uint8_t> input;
for (unsigned int i=0; i<32; i++)
input.push_back(i);
// Testing the SHA256 version
hash = new SHA256();
ro = new RO(hash,65);
printBytes(ro->query(input));
ro = new RO(hash,261);
printBytes(ro->query(input));
// Testing the SHA384 version
hash = new SHA384();
ro = new RO(hash,93);
printBytes(ro->query(input));
ro = new RO(hash,411);
printBytes(ro->query(input));
// Testing the SHA512 version
hash = new SHA512();
ro = new RO(hash,111);
printBytes(ro->query(input));
ro = new RO(hash,579);
printBytes(ro->query(input));
return 0;
}
void printBytes ( std::vector< uint8_t >  v)

Definition at line 25 of file rotest.cpp.

{
for (unsigned int i=0; i<v.size(); i++)
std::cout<<std::hex<<std::setw(2)<<std::setfill('0')<<(int)v[i];
std::cout<<std::endl;
}