Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Typedefs | Functions | Variables
crypto.cpp File Reference
#include <ctype.h>
#include <string.h>
#include <algorithm>
#include "inexor/shared/cube_endian.hpp"
#include "inexor/shared/cube_formatting.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_types.hpp"

Classes

union  tiger::hashval
 
struct  bigint< BI_DIGITS >
 
struct  gfield
 
struct  ecjacobian
 

Namespaces

 tiger
 

Macros

#define TIGER_PASSES   3
 
#define sb1   (sboxes)
 
#define sb2   (sboxes+256)
 
#define sb3   (sboxes+256*2)
 
#define sb4   (sboxes+256*3)
 
#define round(a, b, c, x)
 
#define BI_DIGIT_BITS   16
 
#define BI_DIGIT_MASK   ((1<<BI_DIGIT_BITS)-1)
 
#define GF_BITS   192
 
#define GF_DIGITS   ((GF_BITS+BI_DIGIT_BITS-1)/BI_DIGIT_BITS)
 

Typedefs

typedef unsigned long long int tiger::chunk
 
typedef bigint< GF_DIGITS+1 > gfint
 

Functions

void tiger::compress (const chunk *str, chunk state[3])
 
void tiger::gensboxes ()
 
void tiger::hash (const uchar *str, int length, hashval &val)
 
bool hashstring (const char *str, char *result, int maxlen)
 
void hashpassword (int cn, int sessionid, const char *pwd, char *result, int maxlen)
 Get the session hash. More...
 
bool checkpassword (int cn, int sessionid, const char *wanted, const char *given)
 Checks if the given session hash results from our pw or not. More...
 

Variables

chunk tiger::sboxes [4 *256]
 

Class Documentation

union tiger::hashval
Class Members
uchar bytes[3 *8]
chunk chunks[3]

Macro Definition Documentation

#define BI_DIGIT_BITS   16
#define BI_DIGIT_MASK   ((1<<BI_DIGIT_BITS)-1)
#define GF_BITS   192
#define GF_DIGITS   ((GF_BITS+BI_DIGIT_BITS-1)/BI_DIGIT_BITS)

Referenced by gfield::reduce().

#define round (   a,
  b,
  c,
 
)
Value:
c ^= x; \
a -= sb1[((c)>>(0*8))&0xFF] ^ sb2[((c)>>(2*8))&0xFF] ^ \
sb3[((c)>>(4*8))&0xFF] ^ sb4[((c)>>(6*8))&0xFF] ; \
b += sb4[((c)>>(1*8))&0xFF] ^ sb3[((c)>>(3*8))&0xFF] ^ \
sb2[((c)>>(5*8))&0xFF] ^ sb1[((c)>>(7*8))&0xFF] ; \
b *= mul;
#define sb4
#define sb1
#define sb3
#define sb2

Referenced by server::autoteam(), and tiger::compress().

#define sb1   (sboxes)
#define sb2   (sboxes+256)
#define sb3   (sboxes+256*2)
#define sb4   (sboxes+256*3)
#define TIGER_PASSES   3

Referenced by tiger::compress().

Typedef Documentation

typedef bigint<GF_DIGITS+1> gfint

Function Documentation

bool checkpassword ( int  cn,
int  sessionid,
const char *  wanted,
const char *  given 
)

Checks if the given session hash results from our pw or not.

It answers: is our hash valid for our password?

References tiger::hash(), and hashpassword().

Referenced by server::allowconnect(), and server::setmaster().

void hashpassword ( int  cn,
int  sessionid,
const char *  pwd,
char *  result,
int  maxlen = MAXSTRLEN 
)

Get the session hash.

Formats the sessionid, the cn and a password string together to give a session hash.

References concatstring(), formatstring(), and hashstring().

Referenced by checkpassword(), game::hashpwd(), game::sendintro(), and game::setmaster().

bool hashstring ( const char *  str,
char *  result,
int  maxlen 
)

References tiger::hashval::bytes, tiger::hash(), and loopi().

Referenced by hashpassword().