#include <nKrawall.h>
Public Types | |
typedef nScrambledPassword | nSalt |
Static Public Member Functions | |
static tString | EncodeScrambledPassword (nScrambledPassword const &scrambled) |
static tString | EncodeString (tString const &original) |
static void | WriteScrambledPassword (const nScrambledPassword &scrambled, nMessage &m) |
static void | ReadScrambledPassword (nMessage &m, nScrambledPassword &scrambled) |
static void | WriteScrambledPassword (const nScrambledPassword &scrambled, std::ostream &s) |
static void | ReadScrambledPassword (std::istream &s, nScrambledPassword &scrambled) |
static void | WriteSalt (const nSalt &salt, nMessage &m) |
static void | ReadSalt (nMessage &m, nSalt &salt) |
static bool | ArePasswordsEqual (const nScrambledPassword &a, const nScrambledPassword &b) |
static void | ScramblePassword (const tString &password, nScrambledPassword &scrambled) |
static void | BrokenScramblePassword (const tString &password, nScrambledPassword &scrambled) |
static void | ScrambleWithSalt2 (const nScrambledPassword &source, const nSalt &salt, nScrambledPassword &dest) |
static void | RandomSalt (nSalt &salt) |
Classes | |
struct | nCheckResult |
struct | nCheckResultBase |
struct | nMethod |
authentication method information More... | |
struct | nPasswordAnswer |
struct | nPasswordCheckData |
struct | nPasswordRequest |
class | nScrambledPassword |
struct | nScrambleInfo |
extra information for password scrambling More... |
Definition at line 61 of file nKrawall.h.
typedef nScrambledPassword nKrawall::nSalt |
Definition at line 89 of file nKrawall.h.
tString nKrawall::EncodeScrambledPassword | ( | nScrambledPassword const & | scrambled | ) | [static] |
Definition at line 319 of file nKrawall.cpp.
References sn_WriteHexByte().
00321 { 00322 std::ostringstream s; 00323 for( int i = 0; i < 16; ++i ) 00324 { 00325 unsigned int val = scrambled[i]; 00326 sn_WriteHexByte( s, val ); 00327 } 00328 00329 return tString( s.str().c_str() );
Definition at line 332 of file nKrawall.cpp.
References c, in, and sn_WriteHexByte().
00334 { 00335 std::istringstream in( static_cast< char const * >( original ) ); 00336 std::ostringstream out; 00337 00338 char c = in.get(); 00339 while ( !in.eof() ) 00340 { 00341 if ( c == ' ' ) 00342 { 00343 out.put( '+' ); 00344 } 00345 else if ( isalnum( c ) ) 00346 { 00347 out.put( c ); 00348 } 00349 else 00350 { 00351 out.put('%'); 00352 out << std::uppercase; 00353 sn_WriteHexByte( out, c ); 00354 } 00355 c = in.get(); 00356 } 00357 00358 return tString( out.str().c_str() );
void nKrawall::WriteScrambledPassword | ( | const nScrambledPassword & | scrambled, | |
nMessage & | m | |||
) | [static] |
Definition at line 361 of file nKrawall.cpp.
References nMessage::Write().
Referenced by FinishHandlePasswordRequest(), WriteSalt(), and tConfItemPassword::WriteVal().
00364 { 00365 for (int i = 7; i>=0; i--) 00366 m.Write(scrambled[i << 1] + (scrambled[(i << 1) + 1] << 8));
void nKrawall::ReadScrambledPassword | ( | nMessage & | m, | |
nScrambledPassword & | scrambled | |||
) | [static] |
Definition at line 368 of file nKrawall.cpp.
References nMessage::Read(), and x.
Referenced by login_accept_handler(), ReadSalt(), and tConfItemPassword::ReadVal().
00371 { 00372 for (int i = 7; i>=0; i--) 00373 { 00374 unsigned short x; 00375 m.Read(x); 00376 unsigned char low = x & 255; 00377 unsigned char high = (x - low) >> 8; 00378 00379 scrambled[ i << 1 ] = low; 00380 scrambled[(i << 1) + 1] = high; 00381 }
void nKrawall::WriteScrambledPassword | ( | const nScrambledPassword & | scrambled, | |
std::ostream & | s | |||
) | [static] |
void nKrawall::ReadScrambledPassword | ( | std::istream & | s, | |
nScrambledPassword & | scrambled | |||
) | [static] |
Definition at line 391 of file nKrawall.cpp.
References x.
00394 { 00395 for (int i = 15; i>=0; i--) 00396 { 00397 int x; 00398 s >> x; 00399 scrambled[i] = x; 00400 }
Definition at line 221 of file nKrawall.h.
References WriteScrambledPassword().
00223 { 00224 WriteScrambledPassword(salt, m); 00225 }
Definition at line 227 of file nKrawall.h.
References ReadScrambledPassword().
Referenced by nAuthentication::HandlePasswordRequest().
00229 { 00230 ReadScrambledPassword(m, salt); 00231 }
bool nKrawall::ArePasswordsEqual | ( | const nScrambledPassword & | a, | |
const nScrambledPassword & | b | |||
) | [static] |
Definition at line 290 of file nKrawall.cpp.
00293 { 00294 for (int i=15; i>=0; i--) 00295 if (a[i] != b[i]) 00296 return false; 00297 00298 return true;
void nKrawall::ScramblePassword | ( | const tString & | password, | |
nScrambledPassword & | scrambled | |||
) | [static] |
Definition at line 405 of file nKrawall.cpp.
References nKrawall::nScrambledPassword::content, md5_append(), md5_finish(), and md5_init().
Referenced by nKrawall::nMethod::ScramblePassword().
00408 { 00409 md5_state_t state; 00410 md5_init(&state); 00411 md5_append(&state, (md5_byte_t const *)(password.c_str()), password.size()); 00412 md5_finish(&state, scrambled.content);
void nKrawall::BrokenScramblePassword | ( | const tString & | password, | |
nScrambledPassword & | scrambled | |||
) | [static] |
Definition at line 415 of file nKrawall.cpp.
References nKrawall::nScrambledPassword::content, tString::Len(), md5_append(), md5_finish(), and md5_init().
Referenced by nKrawall::nMethod::ScramblePassword().
00418 { 00419 md5_state_t state; 00420 md5_init(&state); 00421 md5_append(&state, (md5_byte_t const *)(password.c_str()), password.Len()); 00422 md5_finish(&state, scrambled.content);
void nKrawall::ScrambleWithSalt2 | ( | const nScrambledPassword & | source, | |
const nSalt & | salt, | |||
nScrambledPassword & | dest | |||
) | [static] |
Definition at line 426 of file nKrawall.cpp.
References nKrawall::nScrambledPassword::content, md5_append(), md5_finish(), and md5_init().
Referenced by nKrawall::nMethod::ScrambleWithSalt().
00430 { 00431 md5_state_t state; 00432 md5_init(&state); 00433 md5_append(&state, source.content, 16); 00434 md5_append(&state, salt.content , 16); 00435 md5_finish(&state, dest.content);
void nKrawall::RandomSalt | ( | nSalt & | salt | ) | [static] |
Definition at line 446 of file nKrawall.cpp.
References tRandomizer::Get(), and tRandomizer::GetInstance().
00448 { 00449 // oh dear. getting a random salt value with this method is EVIL... 00450 tRandomizer & randomizer = tRandomizer::GetInstance(); 00451 for (int i=15; i>=0; i--) 00452 salt[i] = randomizer.Get( 256 ); 00453 // salt[i] = (int)(256.0 * rand() / (RAND_MAX + 1.0));