#include <nKrawall.h>
Public Member Functions | |
void | ScramblePassword (nScrambleInfo const &info, tString const &password, nScrambledPassword &scrambled) const |
void | ScrambleSalt (nSalt &salt, tString const &serverIP) const |
extra salt scrambling step, done on client and server, not on authentication server | |
void | ScrambleWithSalt (nScrambleInfo const &info, nScrambledPassword const &scrambled, nSalt const &salt, nScrambledPassword &result) const |
scramble a password hash with a salt | |
nMethod () | |
nMethod (char const *method_, std::istream &properties) | |
nMethod (char const *method_, char const *prefix_="", char const *suffix_="") | |
Static Public Member Functions | |
static tString | SupportedMethods () |
static tString | BestMethod (tString const &a, tString const &b) |
static nMethod const *const * | LocalMethods () |
fetch NULL-terminated list of locally supported methods | |
static bool | BestLocalMethod (tString const &supportedOnClient, nMethod &result) |
fetch best local method supported by the client | |
static bool | Equal (nMethod const &a, nMethod const &b) |
compare two methods | |
Public Attributes | |
tString | method |
scrambling method; "bmd5" for old school | |
tString | prefix |
thing to prepend the password before hashing it | |
tString | suffix |
thing to append to the password before hashing it |
Definition at line 103 of file nKrawall.h.
nKrawall::nMethod::nMethod | ( | ) | [inline] |
nKrawall::nMethod::nMethod | ( | char const * | method_, | |
std::istream & | properties | |||
) |
Definition at line 243 of file nKrawall.cpp.
References method, prefix, tString::ReadLine(), suffix, and tToLower().
00245 { 00246 method = method_; 00247 00248 while ( !properties.eof() ) 00249 { 00250 tString property; 00251 properties >> property; 00252 tToLower( property ); 00253 00254 std::ws( properties ); 00255 if ( property == "prefix" ) 00256 { 00257 prefix.ReadLine( properties ); 00258 } 00259 else if ( property == "suffix" ) 00260 { 00261 suffix.ReadLine( properties ); 00262 } 00263 00264 }
nKrawall::nMethod::nMethod | ( | char const * | method_, | |
char const * | prefix_ = "" , |
|||
char const * | suffix_ = "" | |||
) |
tString nKrawall::nMethod::SupportedMethods | ( | ) | [static] |
Definition at line 97 of file nKrawall.cpp.
References sn_GetSupportedMethods().
00099 { 00100 std::ostringstream s; 00101 00102 std::vector< tString > methods; 00103 sn_GetSupportedMethods( methods); 00104 00105 bool first = false; 00106 for( std::vector< tString >::iterator iter = methods.begin(); iter != methods.end(); ++iter ) 00107 { 00108 if ( !first ) 00109 { 00110 s << ", "; 00111 } 00112 s << *iter; 00113 00114 first = false; 00115 } 00116 00117 return tString( s.str().c_str() );
Definition at line 126 of file nKrawall.cpp.
References sn_BothHave(), and sn_GetSupportedMethods().
00128 { 00129 tString ret; 00130 00131 // iterate through methods, starting from best, and return the first that fits 00132 std::vector< tString > methods; 00133 sn_GetSupportedMethods( methods); 00134 for( std::vector< tString >::iterator iter = methods.begin(); iter != methods.end(); ++iter ) 00135 { 00136 if ( sn_BothHave( a, b, *iter ) ) 00137 { 00138 return *iter; 00139 } 00140 } 00141 00142 return tString("");
void nKrawall::nMethod::ScramblePassword | ( | nScrambleInfo const & | info, | |
tString const & | password, | |||
nScrambledPassword & | scrambled | |||
) | const |
Definition at line 201 of file nKrawall.cpp.
References nKrawall::BrokenScramblePassword(), method, prefix, nKrawall::ScramblePassword(), sn_Replace(), suffix, and tASSERT.
Referenced by PasswordCallback().
00203 { 00204 if ( method == "bmd5" ) 00205 { 00206 nKrawall::BrokenScramblePassword( password, scramble ); 00207 } 00208 else // must be "md5" 00209 { 00210 tASSERT( method == "md5" ); 00211 nKrawall::ScramblePassword( sn_Replace(info,prefix) + password + sn_Replace(info,suffix), scramble ); 00212 }
extra salt scrambling step, done on client and server, not on authentication server
Definition at line 215 of file nKrawall.cpp.
00217 { 00218 if ( method != "bmd5" ) 00219 { 00220 // just some random operation 00221 nSalt tmp; 00222 nKrawall::ScramblePassword( serverIP, tmp ); 00223 nKrawall::ScrambleWithSalt2( salt, tmp, salt ); 00224 }
void nKrawall::nMethod::ScrambleWithSalt | ( | nScrambleInfo const & | info, | |
nScrambledPassword const & | scrambled, | |||
nSalt const & | salt, | |||
nScrambledPassword & | result | |||
) | const |
scramble a password hash with a salt
Definition at line 227 of file nKrawall.cpp.
References con, method, nKrawall::ScrambleWithSalt2(), and sn_IsSupportedMethod().
00229 { 00230 // sanity check 00231 if ( !sn_IsSupportedMethod( method ) ) 00232 { 00233 memset( &result, sizeof(result), 0); 00234 con << tColoredStringProxy(1,0,0) << "INTERNAL ERROR OR PHARMING ATTEMPT:" << tColoredStringProxy(1,1,1) << " unsupported hash method " << method << " selected.\n"; 00235 return; 00236 } 00237 00238 // nothing fancy heere 00239 nKrawall::ScrambleWithSalt2( scrambled, salt, result );
nKrawall::nMethod const *const * nKrawall::nMethod::LocalMethods | ( | ) | [static] |
bool nKrawall::nMethod::BestLocalMethod | ( | tString const & | supportedOnClient, | |
nMethod & | result | |||
) | [static] |
fetch best local method supported by the client
Definition at line 145 of file nKrawall.cpp.
00147 { 00148 nMethod const * const * run = LocalMethods(); 00149 00150 while ( * run ) 00151 { 00152 if ( sn_IsSupportedMethod( (*run)->method ) && tIsInList( supportedOnClient, (*run)->method ) ) 00153 { 00154 result = **run; 00155 return true; 00156 } 00157 00158 ++run; 00159 } 00160 00161 return false;
scrambling method; "bmd5" for old school
Definition at line 105 of file nKrawall.h.
Referenced by Equal(), nAuthentication::HandlePasswordRequest(), nMethod(), PasswordCallback(), ScramblePassword(), and ScrambleWithSalt().
thing to prepend the password before hashing it
Definition at line 106 of file nKrawall.h.
Referenced by Equal(), nAuthentication::HandlePasswordRequest(), nMethod(), PasswordCallback(), and ScramblePassword().
thing to append to the password before hashing it
Definition at line 107 of file nKrawall.h.
Referenced by Equal(), nAuthentication::HandlePasswordRequest(), nMethod(), PasswordCallback(), and ScramblePassword().