jabberd2  2.6.1
Data Structures | Macros | Typedefs | Functions | Variables
crypt_blowfish.c File Reference
#include <stdlib.h>
#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_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

◆ __set_errno

#define __set_errno (   val)    errno = (val)

◆ BF_SCALE

#define BF_SCALE   0

Definition at line 60 of file crypt_blowfish.c.

◆ BF_N

#define BF_N   16

Definition at line 67 of file crypt_blowfish.c.

Referenced by BF_crypt(), and BF_set_key().

◆ BF_safe_atoi64

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

Referenced by BF_decode().

◆ BF_INDEX

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

Definition at line 470 of file crypt_blowfish.c.

◆ BF_ROUND

#define BF_ROUND (   L,
  R,
 
)

Definition at line 472 of file crypt_blowfish.c.

◆ BF_ENCRYPT

#define BF_ENCRYPT

Definition at line 494 of file crypt_blowfish.c.

Referenced by BF_crypt().

◆ BF_body

#define BF_body ( )

Definition at line 516 of file crypt_blowfish.c.

Referenced by BF_crypt().

◆ CRYPT_OUTPUT_SIZE

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

Definition at line 992 of file crypt_blowfish.c.

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

◆ CRYPT_GENSALT_OUTPUT_SIZE

#define CRYPT_GENSALT_OUTPUT_SIZE   (7 + 22 + 1)

Definition at line 993 of file crypt_blowfish.c.

Referenced by __crypt_gensalt(), and __crypt_gensalt_ra().

◆ __crypt_gensalt_rn

#define __crypt_gensalt_rn   crypt_gensalt_rn

Definition at line 1125 of file crypt_blowfish.c.

Referenced by __crypt_gensalt(), and __crypt_gensalt_ra().

◆ __crypt_gensalt_ra

#define __crypt_gensalt_ra   crypt_gensalt_ra

Definition at line 1126 of file crypt_blowfish.c.

◆ __crypt_gensalt

#define __crypt_gensalt   bcrypt_gensalt

Definition at line 1127 of file crypt_blowfish.c.

Typedef Documentation

◆ BF_word

typedef unsigned int BF_word

Definition at line 63 of file crypt_blowfish.c.

◆ BF_word_signed

typedef signed int BF_word_signed

Definition at line 64 of file crypt_blowfish.c.

◆ BF_key

typedef BF_word BF_key[BF_N+2]

Definition at line 69 of file crypt_blowfish.c.

Function Documentation

◆ BF_decode()

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

Definition at line 381 of file crypt_blowfish.c.

References BF_safe_atoi64.

Referenced by BF_crypt().

◆ BF_encode()

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

Definition at line 405 of file crypt_blowfish.c.

References BF_itoa64.

Referenced by _crypt_gensalt_blowfish_rn(), and BF_crypt().

◆ BF_swap()

static void BF_swap ( BF_word x,
int  count 
)
static

Definition at line 437 of file crypt_blowfish.c.

Referenced by BF_crypt().

◆ BF_set_key()

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

Definition at line 534 of file crypt_blowfish.c.

References BF_N, and BF_ctx::P.

Referenced by _crypt_blowfish_rn(), and BF_crypt().

◆ BF_crypt()

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

◆ _crypt_output_magic()

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

Definition at line 769 of file crypt_blowfish.c.

Referenced by _crypt_blowfish_rn(), and _crypt_retval_magic().

◆ _crypt_blowfish_rn()

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

◆ _crypt_gensalt_blowfish_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 869 of file crypt_blowfish.c.

References __set_errno, and BF_encode().

Referenced by __crypt_gensalt_rn().

◆ _crypt_gensalt_traditional_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 900 of file crypt_blowfish.c.

References __set_errno, and _crypt_itoa64.

Referenced by __crypt_gensalt_rn().

◆ _crypt_gensalt_extended_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 918 of file crypt_blowfish.c.

References __set_errno, and _crypt_itoa64.

Referenced by __crypt_gensalt_rn().

◆ _crypt_gensalt_md5_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 953 of file crypt_blowfish.c.

References __set_errno, and _crypt_itoa64.

Referenced by __crypt_gensalt_rn().

◆ _crypt_data_alloc()

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

Definition at line 995 of file crypt_blowfish.c.

References __set_errno.

Referenced by _crypt_retval_magic(), and crypt_ra().

◆ _crypt_retval_magic()

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

◆ crypt_rn()

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

Definition at line 1096 of file crypt_blowfish.c.

References _crypt_blowfish_rn().

Referenced by bcrypt(), and crypt_r().

◆ crypt_ra()

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

Definition at line 1101 of file crypt_blowfish.c.

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

◆ crypt_r()

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

Definition at line 1109 of file crypt_blowfish.c.

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

◆ bcrypt()

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

Definition at line 1116 of file crypt_blowfish.c.

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

◆ __crypt_gensalt_rn()

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

◆ __crypt_gensalt_ra()

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

Definition at line 1166 of file crypt_blowfish.c.

References __crypt_gensalt_rn, __set_errno, and CRYPT_GENSALT_OUTPUT_SIZE.

◆ __crypt_gensalt()

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

Definition at line 1187 of file crypt_blowfish.c.

References __crypt_gensalt_rn, and CRYPT_GENSALT_OUTPUT_SIZE.

Variable Documentation

◆ BF_magic_w

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

Definition at line 80 of file crypt_blowfish.c.

Referenced by BF_crypt().

◆ BF_init_state

BF_ctx BF_init_state
static

Definition at line 88 of file crypt_blowfish.c.

◆ BF_itoa64

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

Definition at line 360 of file crypt_blowfish.c.

Referenced by BF_crypt(), and BF_encode().

◆ BF_atoi64

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

Referenced by BF_crypt().

◆ flags_by_subtype

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

Referenced by _crypt_blowfish_rn(), and BF_crypt().

◆ _crypt_itoa64

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

Definition at line 897 of file crypt_blowfish.c.

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