Anope IRC Services  Version 2.0
Data Structures | Macros | Typedefs | Functions | Variables
enc_bcrypt.cpp File Reference
#include <string.h>
#include "module.h"
#include "modules/encryption.h"
Include dependency graph for enc_bcrypt.cpp:

Go to the source code of this file.

Data Structures

struct  BF_ctx
 
class  EBCRYPT
 

Macros

#define BF_SCALE   0
 
#define BF_N   16
 
#define BF_safe_atoi64(dst, src)
 
#define BF_INDEX(S, i)   (*((BF_word *)(((unsigned char *)S) + (i))))
 
#define BF_ROUND(L, R, N)
 
#define BF_ENCRYPT
 
#define BF_body()
 

Typedefs

typedef unsigned int BF_word
 
typedef signed int BF_word_signed
 
typedef BF_word BF_key [BF_N+2]
 

Functions

static int BF_decode (BF_word *dst, const char *src, int size)
 
static void BF_encode (char *dst, const BF_word *src, int size)
 
static void BF_swap (BF_word *x, int count)
 
static void BF_set_key (const char *key, BF_key expanded, BF_key initial, unsigned char flags)
 
static char * BF_crypt (const char *key, const char *setting, char *output, int size, BF_word min)
 
int _crypt_output_magic (const char *setting, char *output, int size)
 
char * _crypt_blowfish_rn (const char *key, const char *setting, char *output, int size)
 
char * _crypt_gensalt_blowfish_rn (const char *prefix, unsigned long count, const char *input, int size, char *output, int output_size)
 

Variables

static BF_word BF_magic_w [6]
 
static BF_ctx BF_init_state
 
static unsigned char BF_itoa64 [64+1]
 
static unsigned char BF_atoi64 [0x60]
 

Macro Definition Documentation

#define BF_body ( )
Value:
L = R = 0; \
ptr = data.ctx.P; \
do { \
ptr += 2; \
*(ptr - 2) = L; \
*(ptr - 1) = R; \
} while (ptr < &data.ctx.P[BF_N + 2]); \
\
ptr = data.ctx.S[0]; \
do { \
ptr += 2; \
*(ptr - 2) = L; \
*(ptr - 1) = R; \
} while (ptr < &data.ctx.S[3][0xFF]);
#define BF_N
Definition: enc_bcrypt.cpp:72
#define BF_ENCRYPT
Definition: enc_bcrypt.cpp:499

Definition at line 521 of file enc_bcrypt.cpp.

Referenced by BF_crypt().

#define BF_ENCRYPT
Value:
L ^= data.ctx.P[0]; \
BF_ROUND(L, R, 0); \
BF_ROUND(R, L, 1); \
BF_ROUND(L, R, 2); \
BF_ROUND(R, L, 3); \
BF_ROUND(L, R, 4); \
BF_ROUND(R, L, 5); \
BF_ROUND(L, R, 6); \
BF_ROUND(R, L, 7); \
BF_ROUND(L, R, 8); \
BF_ROUND(R, L, 9); \
BF_ROUND(L, R, 10); \
BF_ROUND(R, L, 11); \
BF_ROUND(L, R, 12); \
BF_ROUND(R, L, 13); \
BF_ROUND(L, R, 14); \
BF_ROUND(R, L, 15); \
tmp4 = R; \
R = L; \
L = tmp4 ^ data.ctx.P[BF_N + 1];
#define BF_N
Definition: enc_bcrypt.cpp:72
#define BF_ROUND(L, R, N)
Definition: enc_bcrypt.cpp:477

Definition at line 499 of file enc_bcrypt.cpp.

Referenced by BF_crypt().

#define BF_INDEX (   S,
 
)    (*((BF_word *)(((unsigned char *)S) + (i))))

Definition at line 475 of file enc_bcrypt.cpp.

#define BF_N   16

Definition at line 72 of file enc_bcrypt.cpp.

Referenced by BF_crypt(), and BF_set_key().

#define BF_ROUND (   L,
  R,
 
)
Value:
tmp1 = L & 0xFF; \
tmp1 <<= 2; \
tmp2 = L >> 6; \
tmp2 &= 0x3FC; \
tmp3 = L >> 14; \
tmp3 &= 0x3FC; \
tmp4 = L >> 22; \
tmp4 &= 0x3FC; \
tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \
tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \
tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \
tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \
tmp3 ^= tmp2; \
R ^= data.ctx.P[N + 1]; \
tmp3 += tmp1; \
R ^= tmp3;
#define BF_INDEX(S, i)
Definition: enc_bcrypt.cpp:475

Definition at line 477 of file enc_bcrypt.cpp.

#define BF_safe_atoi64 (   dst,
  src 
)
Value:
{ \
tmp = (unsigned char)(src); \
if ((unsigned int)(tmp -= 0x20) >= 0x60) return -1; \
tmp = BF_atoi64[tmp]; \
if (tmp > 63) return -1; \
(dst) = tmp; \
}
static unsigned char BF_atoi64[0x60]
Definition: enc_bcrypt.cpp:368

Definition at line 377 of file enc_bcrypt.cpp.

Referenced by BF_decode().

#define BF_SCALE   0

Definition at line 65 of file enc_bcrypt.cpp.

Typedef Documentation

typedef BF_word BF_key[BF_N+2]

Definition at line 74 of file enc_bcrypt.cpp.

typedef unsigned int BF_word

Definition at line 68 of file enc_bcrypt.cpp.

typedef signed int BF_word_signed

Definition at line 69 of file enc_bcrypt.cpp.

Function Documentation

char* _crypt_blowfish_rn ( const char *  key,
const char *  setting,
char *  output,
int  size 
)

Definition at line 804 of file enc_bcrypt.cpp.

References _crypt_output_magic(), and BF_crypt().

Referenced by EBCRYPT::Generate().

char* _crypt_gensalt_blowfish_rn ( const char *  prefix,
unsigned long  count,
const char *  input,
int  size,
char *  output,
int  output_size 
)

Definition at line 811 of file enc_bcrypt.cpp.

References BF_encode().

Referenced by EBCRYPT::Salt().

int _crypt_output_magic ( const char *  setting,
char *  output,
int  size 
)

Definition at line 769 of file enc_bcrypt.cpp.

Referenced by _crypt_blowfish_rn().

static char* BF_crypt ( const char *  key,
const char *  setting,
char *  output,
int  size,
BF_word  min 
)
static
static int BF_decode ( BF_word dst,
const char *  src,
int  size 
)
static

Definition at line 386 of file enc_bcrypt.cpp.

References BF_safe_atoi64.

Referenced by BF_crypt().

static void BF_encode ( char *  dst,
const BF_word src,
int  size 
)
static

Definition at line 410 of file enc_bcrypt.cpp.

References BF_itoa64.

Referenced by _crypt_gensalt_blowfish_rn(), and BF_crypt().

static void BF_set_key ( const char *  key,
BF_key  expanded,
BF_key  initial,
unsigned char  flags 
)
static

Definition at line 539 of file enc_bcrypt.cpp.

References BF_N, and BF_ctx::P.

Referenced by BF_crypt(), and DHBS::ProcessMessage().

static void BF_swap ( BF_word x,
int  count 
)
static

Definition at line 442 of file enc_bcrypt.cpp.

Referenced by BF_crypt().

Variable Documentation

unsigned char BF_atoi64[0x60]
static
Initial value:
= {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 64, 64,
64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 64, 64, 64, 64, 64,
64, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 64, 64, 64, 64, 64
}

Definition at line 368 of file enc_bcrypt.cpp.

Referenced by BF_crypt().

BF_ctx BF_init_state
static

Definition at line 93 of file enc_bcrypt.cpp.

unsigned char BF_itoa64[64+1]
static
Initial value:
=
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

Definition at line 365 of file enc_bcrypt.cpp.

Referenced by BF_crypt(), and BF_encode().

BF_word BF_magic_w[6]
static
Initial value:
= {
0x4F727068, 0x65616E42, 0x65686F6C,
0x64657253, 0x63727944, 0x6F756274
}

Definition at line 85 of file enc_bcrypt.cpp.

Referenced by BF_crypt().