EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PasswordModuleTest.cpp File Reference
#include "eve-test.h"
Include dependency graph for PasswordModuleTest.cpp:

Go to the source code of this file.

Functions

int auth_PasswordModuleTest (int argc, char *argv[])
 

Variables

const std::string USERNAME = " Hello World "
 
const std::string PASSWORD = " Secret Password "
 
const uint8 HASH []
 
const size_t HASH_LEN = sizeof( HASH )
 

Function Documentation

int auth_PasswordModuleTest ( int  argc,
char *  argv[] 
)

Definition at line 41 of file PasswordModuleTest.cpp.

References PasswordModule::GeneratePassHash(), HASH, HASH_LEN, PASSWORD, and USERNAME.

42 {
43  // Print input data
44  ::printf( "username='%s' (len=%lu)\n"
45  "password='%s' (len=%lu)\n",
46  USERNAME.c_str(), USERNAME.length(),
47  PASSWORD.c_str(), PASSWORD.length() );
48 
49  // Generate the hash
50  std::string hash;
52  USERNAME, PASSWORD, hash ) )
53  {
54  ::fprintf( stderr, "Cannot generate the hash" );
55  return EXIT_FAILURE;
56  }
57 
58  // Compare the lengths
59  if( HASH_LEN != hash.length()
60  // Compare the hashes
61  || 0 != ::memcmp( hash.c_str(), HASH, HASH_LEN ) )
62  {
63  ::fprintf( stderr, "The computed and the reference"
64  " hashes do not match" );
65  return EXIT_FAILURE;
66  }
67 
68  ::puts( "Hash computation OK" );
69  return EXIT_SUCCESS;
70 }
const std::string PASSWORD
const std::string USERNAME
const size_t HASH_LEN
static bool GeneratePassHash(const std::string &user, const std::string &pass, std::string &hash)
Generates a SHA-1 hash from a username and a password.
const uint8 HASH[]

Here is the call graph for this function:

Variable Documentation

const uint8 HASH[]
Initial value:
=
{
0x1b, 0xe6, 0xdf, 0x86, 0x42, 0x1d, 0xcf, 0x2c,
0xfa, 0x71, 0x90, 0x0f, 0x34, 0x27, 0x75, 0xb0,
0x31, 0x98, 0xdc, 0xe5
}

Definition at line 33 of file PasswordModuleTest.cpp.

Referenced by auth_PasswordModuleTest().

const size_t HASH_LEN = sizeof( HASH )

Definition at line 39 of file PasswordModuleTest.cpp.

Referenced by auth_PasswordModuleTest().

const std::string PASSWORD = " Secret Password "

Definition at line 31 of file PasswordModuleTest.cpp.

Referenced by auth_PasswordModuleTest().

const std::string USERNAME = " Hello World "

Definition at line 29 of file PasswordModuleTest.cpp.

Referenced by auth_PasswordModuleTest().