nKrawall::nMethod Struct Reference

authentication method information More...

#include <nKrawall.h>

Inheritance diagram for nKrawall::nMethod:

Inheritance graph
[legend]
Collaboration diagram for nKrawall::nMethod:

Collaboration graph
[legend]

List of all members.

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


Detailed Description

authentication method information

Definition at line 103 of file nKrawall.h.


Constructor & Destructor Documentation

nKrawall::nMethod::nMethod (  )  [inline]

Definition at line 133 of file nKrawall.h.

00133 {}

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     }

Here is the call graph for this function:

nKrawall::nMethod::nMethod ( char const *  method_,
char const *  prefix_ = "",
char const *  suffix_ = "" 
)

Definition at line 266 of file nKrawall.cpp.

00269     : method( method_ ),
00270       prefix( prefix_ ),
00271       suffix( suffix_ )
00272 {


Member Function Documentation

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() );

Here is the call graph for this function:

tString nKrawall::nMethod::BestMethod ( tString const &  a,
tString const &  b 
) [static]

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("");

Here is the call graph for this function:

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     }

Here is the call graph for this function:

Here is the caller graph for this function:

void nKrawall::nMethod::ScrambleSalt ( nSalt salt,
tString const &  serverIP 
) const

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 );

Here is the call graph for this function:

nKrawall::nMethod const *const * nKrawall::nMethod::LocalMethods (  )  [static]

fetch NULL-terminated list of locally supported methods

Definition at line 52 of file nKrawallPrivate.cpp.

References NULL, sn_bmd5, and sn_md5.

00053 {
00054     static nMethod const * methods[] =
00055     {
00056         &sn_md5,
00057         &sn_bmd5,
00058         NULL
00059     };
00060 
00061     return methods;
00062 }

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;

bool nKrawall::nMethod::Equal ( nMethod const &  a,
nMethod const &  b 
) [static]

compare two methods

Definition at line 163 of file nKrawall.cpp.

References method, prefix, and suffix.

00165 {
00166     return a.method == b.method && a.prefix == b.prefix && a.suffix == b.suffix;


Member Data Documentation

tString nKrawall::nMethod::method

scrambling method; "bmd5" for old school

Definition at line 105 of file nKrawall.h.

Referenced by Equal(), nAuthentication::HandlePasswordRequest(), nMethod(), PasswordCallback(), ScramblePassword(), and ScrambleWithSalt().

tString nKrawall::nMethod::prefix

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().

tString nKrawall::nMethod::suffix

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().


The documentation for this struct was generated from the following files:
Generated on Sat Mar 15 23:47:36 2008 for Armagetron Advanced by  doxygen 1.5.4