heimdal  7.7.0
About: Heimdal is a free implementation of Kerberos 5 (a system for authenticating users and services on a network).
  Fossies Dox: heimdal-7.7.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

DES crypto functions

See the DES - Data Encryption Standard crypto interface for description and examples. More...

Functions

void hc_DES_set_odd_parity (DES_cblock *key)
 
int hc_DES_check_key_parity (DES_cblock *key)
 
int hc_DES_is_weak_key (DES_cblock *key)
 
int hc_DES_set_key (DES_cblock *key, DES_key_schedule *ks)
 
int hc_DES_set_key_unchecked (DES_cblock *key, DES_key_schedule *ks)
 
int hc_DES_set_key_checked (DES_cblock *key, DES_key_schedule *ks)
 
int hc_DES_key_sched (DES_cblock *key, DES_key_schedule *ks)
 
void hc_DES_encrypt (uint32_t u[2], DES_key_schedule *ks, int encp)
 
void hc_DES_ecb_encrypt (DES_cblock *input, DES_cblock *output, DES_key_schedule *ks, int encp)
 
void hc_DES_cbc_encrypt (const void *in, void *out, long length, DES_key_schedule *ks, DES_cblock *iv, int encp)
 
void hc_DES_pcbc_encrypt (const void *in, void *out, long length, DES_key_schedule *ks, DES_cblock *iv, int encp)
 
void hc_DES_ecb3_encrypt (DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, int encp)
 
void hc_DES_ede3_cbc_encrypt (const void *in, void *out, long length, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *iv, int encp)
 
void hc_DES_cfb64_encrypt (const void *in, void *out, long length, DES_key_schedule *ks, DES_cblock *iv, int *num, int encp)
 
uint32_t hc_DES_cbc_cksum (const void *in, DES_cblock *output, long length, DES_key_schedule *ks, DES_cblock *iv)
 
void hc_DES_string_to_key (const char *str, DES_cblock *key)
 
int hc_DES_new_random_key (DES_cblock *key)
 
void hc_DES_init_random_number_generator (DES_cblock *seed)
 
void hc_DES_random_key (DES_cblock *key)
 

Detailed Description

See the DES - Data Encryption Standard crypto interface for description and examples.

Function Documentation

◆ hc_DES_cbc_cksum()

uint32_t hc_DES_cbc_cksum ( const void in,
DES_cblock output,
long  length,
DES_key_schedule ks,
DES_cblock iv 
)

Crete a checksum using DES in CBC encryption mode. This mode is only used for Kerberos 4, and it should stay that way.

The IV must always be diffrent for diffrent input data blocks.

Parameters
indata to checksum
outputthe checksum
lengthlength of data
kskey schedule to use
ivinitial vector to use

Definition at line 764 of file des.c.

References DES_CBLOCK_LEN, DES_encrypt, input(), gen-errorlist::length, load(), and store().

◆ hc_DES_cbc_encrypt()

void hc_DES_cbc_encrypt ( const void in,
void out,
long  length,
DES_key_schedule ks,
DES_cblock iv,
int  encp 
)

Encrypt/decrypt a block using DES in Chain Block Cipher mode (cbc).

The IV must always be diffrent for diffrent input data blocks.

Parameters
indata to encrypt
outdata to encrypt
lengthlength of data
kskey schedule to use
ivinitial vector to use
encpif non zero, encrypt. if zero, decrypt.

Definition at line 406 of file des.c.

References DES_CBLOCK_LEN, DES_encrypt, input(), gen-errorlist::length, load(), store(), and t.

◆ hc_DES_cfb64_encrypt()

void hc_DES_cfb64_encrypt ( const void in,
void out,
long  length,
DES_key_schedule ks,
DES_cblock iv,
int *  num,
int  encp 
)

Encrypt/decrypt using DES in cipher feedback mode with 64 bit feedback.

The IV must always be diffrent for diffrent input data blocks.

Parameters
indata to encrypt
outdata to encrypt
lengthlength of data
kskey schedule to use
ivinitial vector to use
numoffset into in cipher block encryption/decryption stop last time.
encpif non zero, encrypt. if zero, decrypt.

Definition at line 688 of file des.c.

References DES_CBLOCK_LEN, DES_encrypt, gen-map::i, input(), gen-errorlist::length, load(), and store().

◆ hc_DES_check_key_parity()

int hc_DES_check_key_parity ( DES_cblock key)

Check if the key have correct parity.

Parameters
keykey to check the parity.
Returns
1 on success, 0 on failure.

Definition at line 133 of file des.c.

References DES_CBLOCK_LEN, gen-map::i, key, and odd_parity.

◆ hc_DES_ecb3_encrypt()

void hc_DES_ecb3_encrypt ( DES_cblock input,
DES_cblock output,
DES_key_schedule ks1,
DES_key_schedule ks2,
DES_key_schedule ks3,
int  encp 
)

Encrypt/decrypt a block using triple DES using EDE mode, encrypt/decrypt/encrypt.

Parameters
inputdata to encrypt
outputdata to encrypt
ks1key schedule to use
ks2key schedule to use
ks3key schedule to use
encpif non zero, encrypt. if zero, decrypt.

Definition at line 577 of file des.c.

References _des3_encrypt(), input(), load(), and store().

◆ hc_DES_ecb_encrypt()

void hc_DES_ecb_encrypt ( DES_cblock input,
DES_cblock output,
DES_key_schedule ks,
int  encp 
)

Encrypt/decrypt a block using DES.

Parameters
inputdata to encrypt
outputdata to encrypt
kskey schedule to use
encpif non zero, encrypt. if zero, decrypt.

Definition at line 381 of file des.c.

References DES_encrypt, input(), load(), and store().

◆ hc_DES_ede3_cbc_encrypt()

void hc_DES_ede3_cbc_encrypt ( const void in,
void out,
long  length,
DES_key_schedule ks1,
DES_key_schedule ks2,
DES_key_schedule ks3,
DES_cblock iv,
int  encp 
)

Encrypt/decrypt using Triple DES in Chain Block Cipher mode (cbc).

The IV must always be diffrent for diffrent input data blocks.

Parameters
indata to encrypt
outdata to encrypt
lengthlength of data
ks1key schedule to use
ks2key schedule to use
ks3key schedule to use
ivinitial vector to use
encpif non zero, encrypt. if zero, decrypt.

Definition at line 609 of file des.c.

References _des3_encrypt(), DES_CBLOCK_LEN, input(), gen-errorlist::length, load(), store(), and t.

◆ hc_DES_encrypt()

void hc_DES_encrypt ( uint32_t  u[2],
DES_key_schedule ks,
int  encp 
)

Encrypt/decrypt a block using DES. Also called ECB mode

Parameters
udata to encrypt
kskey schedule to use
encpif non zero, encrypt. if zero, decrypt.

Definition at line 362 of file des.c.

References desx(), FP(), and IP().

◆ hc_DES_init_random_number_generator()

void hc_DES_init_random_number_generator ( DES_cblock seed)

Seed the random number generator. Deprecated, use RAND - random number

Parameters
seeda seed to seed that random number generate with.

Definition at line 119 of file rnd_keys.c.

References RAND_seed().

◆ hc_DES_is_weak_key()

int hc_DES_is_weak_key ( DES_cblock key)

Checks if the key is any of the weaks keys that makes DES attacks trival.

Parameters
keykey to check.
Returns
1 if the key is weak, 0 otherwise.

Definition at line 178 of file des.c.

References ct_memcmp(), DES_CBLOCK_LEN, gen-map::i, key, and weak_keys.

◆ hc_DES_key_sched()

int hc_DES_key_sched ( DES_cblock key,
DES_key_schedule ks 
)

Compatibility function for eay libdes, works just like DES_set_key_checked().

Parameters
keya key to initialize the key schedule with.
ksa key schedule to initialize.
Returns
0 on success, -1 on invalid parity, -2 on weak key.

Definition at line 316 of file des.c.

References DES_set_key_checked, and key.

◆ hc_DES_new_random_key()

int hc_DES_new_random_key ( DES_cblock key)

Generate a random des key using a random block, fixup parity and skip weak keys.

Parameters
keyis set to a random key.
Returns
0 on success, non zero on random number generator failure.

Definition at line 99 of file rnd_keys.c.

References DES_is_weak_key, DES_set_odd_parity, key, and RAND_bytes().

◆ hc_DES_pcbc_encrypt()

void hc_DES_pcbc_encrypt ( const void in,
void out,
long  length,
DES_key_schedule ks,
DES_cblock iv,
int  encp 
)

Encrypt/decrypt a block using DES in Propagating Cipher Block Chaining mode. This mode is only used for Kerberos 4, and it should stay that way.

The IV must always be diffrent for diffrent input data blocks.

Parameters
indata to encrypt
outdata to encrypt
lengthlength of data
kskey schedule to use
ivinitial vector to use
encpif non zero, encrypt. if zero, decrypt.

Definition at line 482 of file des.c.

References DES_CBLOCK_LEN, DES_encrypt, input(), gen-errorlist::length, load(), store(), and t.

◆ hc_DES_random_key()

void hc_DES_random_key ( DES_cblock key)

Generate a random key, deprecated since it doesn't return an error code, use DES_new_random_key().

Parameters
keyis set to a random key.

Definition at line 134 of file rnd_keys.c.

References DES_new_random_key, and key.

◆ hc_DES_set_key()

int hc_DES_set_key ( DES_cblock key,
DES_key_schedule ks 
)

Setup a des key schedule from a key. Deprecated function, use DES_set_key_unchecked() or DES_set_key_checked() instead.

Parameters
keya key to initialize the key schedule with.
ksa key schedule to initialize.
Returns
0 on success

Definition at line 201 of file des.c.

References DES_set_key_checked, and key.

◆ hc_DES_set_key_checked()

int hc_DES_set_key_checked ( DES_cblock key,
DES_key_schedule ks 
)

Just like DES_set_key_unchecked() except checking that the key is not weak for or have correct parity.

Parameters
keya key to initialize the key schedule with.
ksa key schedule to initialize.
Returns
0 on success, -1 on invalid parity, -2 on weak key.

Definition at line 291 of file des.c.

References DES_check_key_parity, DES_is_weak_key, DES_set_key_unchecked, and key.

◆ hc_DES_set_key_unchecked()

int hc_DES_set_key_unchecked ( DES_cblock key,
DES_key_schedule ks 
)

Setup a des key schedule from a key. The key is no longer needed after this transaction and can cleared.

Does NOT check that the key is weak for or have wrong parity.

Parameters
keya key to initialize the key schedule with.
ksa key schedule to initialize.
Returns
0 on success

Definition at line 220 of file des.c.

References d, gen-map::i, DES_key_schedule::ks, L, pc1_c_3, pc1_c_4, pc1_d_3, pc1_d_4, pc2_c_1, pc2_c_2, pc2_c_3, pc2_c_4, pc2_d_1, pc2_d_2, pc2_d_3, pc2_d_4, ROTATE_LEFT28, and gen-errorlist::t2.

◆ hc_DES_set_odd_parity()

void hc_DES_set_odd_parity ( DES_cblock key)

Set the parity of the key block, used to generate a des key from a random key. See DES key generation.

Parameters
keykey to fixup the parity for.

Definition at line 117 of file des.c.

References DES_CBLOCK_LEN, gen-map::i, key, and odd_parity.

◆ hc_DES_string_to_key()

void hc_DES_string_to_key ( const char *  str,
DES_cblock key 
)

Convert a string to a DES key. Use something like PKCS5_PBKDF2_HMAC_SHA1() to create key from passwords.

Parameters
strThe string to convert to a key
keythe resulting key

Definition at line 824 of file des.c.

References bitswap8(), DES_cbc_cksum, DES_is_weak_key, DES_set_key, DES_set_odd_parity, gen-map::i, key, len, gen-combining::s, and str.