jabberd2  2.3.3
Data Structures | Macros | Typedefs | Functions | Variables
crypt_blowfish.c File Reference
#include <string.h>
#include <errno.h>
#include "crypt_blowfish.h"

Go to the source code of this file.

Data Structures

struct  BF_ctx
 

Macros

#define __set_errno(val)   errno = (val)
 
#define BF_ASM   0
 
#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()
 
#define CRYPT_OUTPUT_SIZE   (7 + 22 + 31 + 1)
 
#define CRYPT_GENSALT_OUTPUT_SIZE   (7 + 22 + 1)
 
#define __crypt_gensalt_rn   crypt_gensalt_rn
 
#define __crypt_gensalt_ra   crypt_gensalt_ra
 
#define __crypt_gensalt   bcrypt_gensalt
 

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)
 
char * _crypt_gensalt_traditional_rn (const char *prefix, unsigned long count, const char *input, int size, char *output, int output_size)
 
char * _crypt_gensalt_extended_rn (const char *prefix, unsigned long count, const char *input, int size, char *output, int output_size)
 
char * _crypt_gensalt_md5_rn (const char *prefix, unsigned long count, const char *input, int size, char *output, int output_size)
 
static int _crypt_data_alloc (void **data, int *size, int need)
 
static char * _crypt_retval_magic (char *retval, const char *setting, char *output, int size)
 
char * crypt_rn (const char *key, const char *setting, void *data, int size)
 
char * crypt_ra (const char *key, const char *setting, void **data, int *size)
 
char * crypt_r (const char *key, const char *setting, void *data)
 
char * bcrypt (const char *key, const char *setting)
 
char * __crypt_gensalt_rn (const char *prefix, unsigned long count, const char *input, int size, char *output, int output_size)
 
char * __crypt_gensalt_ra (const char *prefix, unsigned long count, const char *input, int size)
 
char * __crypt_gensalt (const char *prefix, unsigned long count, const char *input, int 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]
 
static const unsigned char flags_by_subtype [26]
 
unsigned char _crypt_itoa64 [64+1]
 

Macro Definition Documentation

#define __set_errno (   val)    errno = (val)
#define BF_ASM   0

Definition at line 63 of file crypt_blowfish.c.

#define BF_SCALE   0

Definition at line 64 of file crypt_blowfish.c.

#define BF_N   16

Definition at line 71 of file crypt_blowfish.c.

Referenced by BF_crypt(), and BF_set_key().

#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 at line 376 of file crypt_blowfish.c.

Referenced by BF_decode().

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

Definition at line 474 of file crypt_blowfish.c.

#define BF_ROUND (   L,
  R,
 
)

Definition at line 476 of file crypt_blowfish.c.

#define BF_ENCRYPT

Definition at line 498 of file crypt_blowfish.c.

Referenced by BF_crypt().

#define BF_body ( )

Definition at line 524 of file crypt_blowfish.c.

Referenced by BF_crypt().

#define CRYPT_OUTPUT_SIZE   (7 + 22 + 31 + 1)

Definition at line 1004 of file crypt_blowfish.c.

Referenced by bcrypt(), crypt_r(), and crypt_ra().

#define CRYPT_GENSALT_OUTPUT_SIZE   (7 + 22 + 1)

Definition at line 1005 of file crypt_blowfish.c.

Referenced by __crypt_gensalt(), and __crypt_gensalt_ra().

#define __crypt_gensalt_rn   crypt_gensalt_rn

Definition at line 1137 of file crypt_blowfish.c.

Referenced by __crypt_gensalt(), and __crypt_gensalt_ra().

#define __crypt_gensalt_ra   crypt_gensalt_ra

Definition at line 1138 of file crypt_blowfish.c.

#define __crypt_gensalt   bcrypt_gensalt

Definition at line 1139 of file crypt_blowfish.c.

Typedef Documentation

typedef unsigned int BF_word

Definition at line 67 of file crypt_blowfish.c.

typedef signed int BF_word_signed

Definition at line 68 of file crypt_blowfish.c.

typedef BF_word BF_key[BF_N+2]

Definition at line 73 of file crypt_blowfish.c.

Function Documentation

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

Definition at line 385 of file crypt_blowfish.c.

References BF_safe_atoi64.

Referenced by BF_crypt().

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

Definition at line 409 of file crypt_blowfish.c.

References BF_itoa64.

Referenced by _crypt_gensalt_blowfish_rn(), and BF_crypt().

static void BF_swap ( BF_word x,
int  count 
)
static

Definition at line 441 of file crypt_blowfish.c.

Referenced by BF_crypt().

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

Definition at line 543 of file crypt_blowfish.c.

References BF_N, and BF_ctx::P.

Referenced by _crypt_blowfish_rn(), and BF_crypt().

static char* BF_crypt ( const char *  key,
const char *  setting,
char *  output,
int  size,
BF_word  min 
)
static
int _crypt_output_magic ( const char *  setting,
char *  output,
int  size 
)

Definition at line 781 of file crypt_blowfish.c.

Referenced by _crypt_blowfish_rn(), and _crypt_retval_magic().

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

Definition at line 816 of file crypt_blowfish.c.

References __set_errno, _crypt_output_magic(), BF_crypt(), BF_set_key(), and flags_by_subtype.

Referenced by crypt_ra(), and crypt_rn().

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

Definition at line 881 of file crypt_blowfish.c.

References __set_errno, and BF_encode().

Referenced by __crypt_gensalt_rn().

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

Definition at line 912 of file crypt_blowfish.c.

References __set_errno, and _crypt_itoa64.

Referenced by __crypt_gensalt_rn().

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

Definition at line 930 of file crypt_blowfish.c.

References __set_errno, and _crypt_itoa64.

Referenced by __crypt_gensalt_rn().

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

Definition at line 965 of file crypt_blowfish.c.

References __set_errno, and _crypt_itoa64.

Referenced by __crypt_gensalt_rn().

static int _crypt_data_alloc ( void **  data,
int *  size,
int  need 
)
static

Definition at line 1007 of file crypt_blowfish.c.

References __set_errno.

Referenced by crypt_ra().

static char* _crypt_retval_magic ( char *  retval,
const char *  setting,
char *  output,
int  size 
)
static

Definition at line 1029 of file crypt_blowfish.c.

References _crypt_output_magic().

Referenced by bcrypt(), and crypt_r().

char* crypt_rn ( const char *  key,
const char *  setting,
void *  data,
int  size 
)

Definition at line 1108 of file crypt_blowfish.c.

References _crypt_blowfish_rn().

Referenced by bcrypt(), and crypt_r().

char* crypt_ra ( const char *  key,
const char *  setting,
void **  data,
int *  size 
)

Definition at line 1113 of file crypt_blowfish.c.

References _crypt_blowfish_rn(), _crypt_data_alloc(), and CRYPT_OUTPUT_SIZE.

char* crypt_r ( const char *  key,
const char *  setting,
void *  data 
)

Definition at line 1121 of file crypt_blowfish.c.

References _crypt_retval_magic(), CRYPT_OUTPUT_SIZE, and crypt_rn().

char* bcrypt ( const char *  key,
const char *  setting 
)

Definition at line 1128 of file crypt_blowfish.c.

References _crypt_retval_magic(), CRYPT_OUTPUT_SIZE, and crypt_rn().

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

Definition at line 1178 of file crypt_blowfish.c.

References __crypt_gensalt_rn, __set_errno, and CRYPT_GENSALT_OUTPUT_SIZE.

char* __crypt_gensalt ( const char *  prefix,
unsigned long  count,
const char *  input,
int  size 
)

Definition at line 1199 of file crypt_blowfish.c.

References __crypt_gensalt_rn, and CRYPT_GENSALT_OUTPUT_SIZE.

Variable Documentation

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

Definition at line 84 of file crypt_blowfish.c.

Referenced by BF_crypt().

BF_ctx BF_init_state
static

Definition at line 92 of file crypt_blowfish.c.

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

Definition at line 364 of file crypt_blowfish.c.

Referenced by BF_crypt(), and BF_encode().

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 367 of file crypt_blowfish.c.

Referenced by BF_crypt().

const unsigned char flags_by_subtype[26]
static
Initial value:
=
{2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0}

Definition at line 645 of file crypt_blowfish.c.

Referenced by _crypt_blowfish_rn(), and BF_crypt().

unsigned char _crypt_itoa64[64+1]
Initial value:
=
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Definition at line 909 of file crypt_blowfish.c.

Referenced by __crypt_gensalt_rn(), _crypt_gensalt_extended_rn(), _crypt_gensalt_md5_rn(), and _crypt_gensalt_traditional_rn().