A unitary test to check that the hashfunctions implementing the cryptoTools::SHAx interface compute the correct hashes using test vectors from the NIST. More...
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include "cryptotools.hpp"
Go to the source code of this file.
Functions | |
bool | parseInput (std::vector< unsigned char > &in) |
Reads a line from stdin and turns it into a vector of unsigned char. Then returns true if there is a line left in stdin; false otherwise. | |
int | main (int argc, char **argv) |
A unitary test to check that the hashfunctions implementing the cryptoTools::SHAx interface compute the correct hashes using test vectors from the NIST.
The binary file obtained from the compilation of this one takes as argument either "SHA-256", "SHA-384" or "SHA-512" and reads from the standard input bytes to hash. These have to be "explicit" in the sense that the byte 0x10 is encoded as the character '1' and then the character 'zero'.
It reads one line of input, hashes it using the hashfunction specified in the argument and outputs the hash in the same way. It stops when the input is empty.
Definition in file shatest.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 100 of file shatest.cpp.
bool parseInput | ( | std::vector< unsigned char > & | in | ) |
Reads a line from stdin and turns it into a vector of unsigned char. Then returns true if there is a line left in stdin; false otherwise.
Reads characters from the input two by two and turns them into the corresponding hexadecimal bytes. It is assumed that the input is correctly formated; no verifications are made.
in | This vector is emptied in the beginning and then receives the bytes read from stdin. At the end of the call, it contains the bytes encoded in the current line. |
Definition at line 46 of file shatest.cpp.