* Added AES and AES-CTR modules. AES-CTR conforms to the same counter mode used with AES in *OpenSSL*. * All algorithms now work on Big-Endian architectures. * Now uses CMake for building rather than make files and Visual Studio projects. CMake will generate whatever system is required. * Input function parameters are now marked `const` * File names have been changed to have the prefix `CryptLib_` rather than `Lib`. * Various formatting changes to the files.
75 lines
2.2 KiB
C
75 lines
2.2 KiB
C
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// CryptLibTest
|
|
//
|
|
// Tests the cryptography functions against known test vectors to verify algorithms are correct.
|
|
//
|
|
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// IMPORTS
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include "CryptLibTest_Aes.h"
|
|
#include "CryptLibTest_AesCtr.h"
|
|
#include "CryptLibTest_Hashes.h"
|
|
#include "CryptLibTest_Rc4.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// FUNCTIONS
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// main
|
|
//
|
|
// Program entry point
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
int
|
|
main
|
|
(
|
|
void
|
|
)
|
|
{
|
|
bool success;
|
|
bool allSuccess = true;
|
|
|
|
printf(
|
|
"CryptLibTest\n"
|
|
"------------\n"
|
|
"\n" );
|
|
|
|
success = TestHashes( );
|
|
if( !success ) { allSuccess = false; }
|
|
|
|
success = TestRc4( );
|
|
if( !success ) { allSuccess = false; }
|
|
printf( "Test RC4 - %s\n", success?"Pass":"Fail" );
|
|
|
|
success = TestAes( );
|
|
if( !success ) { allSuccess = false; }
|
|
printf( "Test AES - %s\n", success?"Pass":"Fail" );
|
|
|
|
success = TestAesCtr( );
|
|
if( !success ) { allSuccess = false; }
|
|
printf( "Test AES CTR- %s\n", success?"Pass":"Fail" );
|
|
|
|
|
|
printf( "\n" );
|
|
if( allSuccess )
|
|
{
|
|
printf( "All tests passed.\n" );
|
|
}
|
|
else
|
|
{
|
|
printf( "Fail.\n" );
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|