des.c File Reference

Go to the source code of this file.

Functions

static uint64_t shuffle (uint64_t in, const uint8_t *shuffle, int shuffle_len)
static uint64_t shuffle_inv (uint64_t in, const uint8_t *shuffle, int shuffle_len)
static uint32_t f_func (uint32_t r, uint64_t k)
static uint64_t key_shift_left (uint64_t CDn)
 rotate the two halves of the expanded 56 bit key each 1 bit left
uint64_t ff_des_encdec (uint64_t in, uint64_t key, int decrypt)
 en- or decrypt an 64-bit block of data with DES
static uint64_t rand64 (void)
int main (void)

Variables

static const uint8_t IP_shuffle []
static const uint8_t P_shuffle []
static const uint8_t PC1_shuffle []
static const uint8_t PC2_shuffle []
static const uint8_t S_boxes [8][32]
static const uint32_t S_boxes_P_shuffle [8][64]
 This table contains the results of applying both the S-box and P-shuffle.


Function Documentation

static uint64_t shuffle ( uint64_t  in,
const uint8_t *  shuffle,
int  shuffle_len 
) [static]

Definition at line 193 of file des.c.

Referenced by f_func(), ff_des_encdec(), main(), and LCDProcClient::outputMusic().

static uint64_t shuffle_inv ( uint64_t  in,
const uint8_t *  shuffle,
int  shuffle_len 
) [static]

Definition at line 201 of file des.c.

Referenced by ff_des_encdec().

static uint32_t f_func ( uint32_t  r,
uint64_t  k 
) [static]

Definition at line 212 of file des.c.

Referenced by ff_des_encdec().

static uint64_t key_shift_left ( uint64_t  CDn  )  [static]

rotate the two halves of the expanded 56 bit key each 1 bit left

Note: the specification calls this "shift", so I kept it although it is confusing.

Definition at line 243 of file des.c.

Referenced by ff_des_encdec().

uint64_t ff_des_encdec ( uint64_t  in,
uint64_t  key,
int  decrypt 
)

en- or decrypt an 64-bit block of data with DES

Parameters:
in data to process.
key key to use for en-/decryption.
decrypt if 0 encrypt, else decrypt.
Returns:
processed data
If your input data is in 8-bit blocks treat it as big-endian (use e.g. AV_RB64 and AV_WB64).

Definition at line 251 of file des.c.

Referenced by ff_asfcrypt_dec(), and main().

static uint64_t rand64 ( void   )  [static]

Definition at line 283 of file des.c.

Referenced by main().

int main ( void   ) 

Definition at line 289 of file des.c.


Variable Documentation

const uint8_t IP_shuffle[] [static]

Initial value:

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

Definition at line 25 of file des.c.

Referenced by ff_des_encdec().

const uint8_t P_shuffle[] [static]

Initial value:

 {
    T(16,  7, 20, 21),
    T(29, 12, 28, 17),
    T( 1, 15, 23, 26),
    T( 5, 18, 31, 10),
    T( 2,  8, 24, 14),
    T(32, 27,  3,  9),
    T(19, 13, 30,  6),
    T(22, 11,  4, 25)
}

Definition at line 38 of file des.c.

Referenced by f_func(), and main().

const uint8_t PC1_shuffle[] [static]

Initial value:

 {
    T(57, 49, 41, 33, 25, 17,  9),
    T( 1, 58, 50, 42, 34, 26, 18),
    T(10,  2, 59, 51, 43, 35, 27),
    T(19, 11,  3, 60, 52, 44, 36),
    T(63, 55, 47, 39, 31, 23, 15),
    T( 7, 62, 54, 46, 38, 30, 22),
    T(14,  6, 61, 53, 45, 37, 29),
    T(21, 13,  5, 28, 20, 12,  4)
}

Definition at line 51 of file des.c.

Referenced by ff_des_encdec().

const uint8_t PC2_shuffle[] [static]

Initial value:

 {
    T(14, 17, 11, 24,  1,  5),
    T( 3, 28, 15,  6, 21, 10),
    T(23, 19, 12,  4, 26,  8),
    T(16,  7, 27, 20, 13,  2),
    T(41, 52, 31, 37, 47, 55),
    T(30, 40, 51, 45, 33, 48),
    T(44, 49, 39, 56, 34, 53),
    T(46, 42, 50, 36, 29, 32)
}

Definition at line 64 of file des.c.

Referenced by ff_des_encdec().

const uint8_t S_boxes[8][32] [static]

Initial value:

 {
    {
    0x0e, 0xf4, 0x7d, 0x41, 0xe2, 0x2f, 0xdb, 0x18, 0xa3, 0x6a, 0xc6, 0xbc, 0x95, 0x59, 0x30, 0x87,
    0xf4, 0xc1, 0x8e, 0x28, 0x4d, 0x96, 0x12, 0x7b, 0x5f, 0xbc, 0x39, 0xe7, 0xa3, 0x0a, 0x65, 0xd0,
    }, {
    0x3f, 0xd1, 0x48, 0x7e, 0xf6, 0x2b, 0x83, 0xe4, 0xc9, 0x07, 0x12, 0xad, 0x6c, 0x90, 0xb5, 0x5a,
    0xd0, 0x8e, 0xa7, 0x1b, 0x3a, 0xf4, 0x4d, 0x21, 0xb5, 0x68, 0x7c, 0xc6, 0x09, 0x53, 0xe2, 0x9f,
    }, {
    0xda, 0x70, 0x09, 0x9e, 0x36, 0x43, 0x6f, 0xa5, 0x21, 0x8d, 0x5c, 0xe7, 0xcb, 0xb4, 0xf2, 0x18,
    0x1d, 0xa6, 0xd4, 0x09, 0x68, 0x9f, 0x83, 0x70, 0x4b, 0xf1, 0xe2, 0x3c, 0xb5, 0x5a, 0x2e, 0xc7,
    }, {
    0xd7, 0x8d, 0xbe, 0x53, 0x60, 0xf6, 0x09, 0x3a, 0x41, 0x72, 0x28, 0xc5, 0x1b, 0xac, 0xe4, 0x9f,
    0x3a, 0xf6, 0x09, 0x60, 0xac, 0x1b, 0xd7, 0x8d, 0x9f, 0x41, 0x53, 0xbe, 0xc5, 0x72, 0x28, 0xe4,
    }, {
    0xe2, 0xbc, 0x24, 0xc1, 0x47, 0x7a, 0xdb, 0x16, 0x58, 0x05, 0xf3, 0xaf, 0x3d, 0x90, 0x8e, 0x69,
    0xb4, 0x82, 0xc1, 0x7b, 0x1a, 0xed, 0x27, 0xd8, 0x6f, 0xf9, 0x0c, 0x95, 0xa6, 0x43, 0x50, 0x3e,
    }, {
    0xac, 0xf1, 0x4a, 0x2f, 0x79, 0xc2, 0x96, 0x58, 0x60, 0x1d, 0xd3, 0xe4, 0x0e, 0xb7, 0x35, 0x8b,
    0x49, 0x3e, 0x2f, 0xc5, 0x92, 0x58, 0xfc, 0xa3, 0xb7, 0xe0, 0x14, 0x7a, 0x61, 0x0d, 0x8b, 0xd6,
    }, {
    0xd4, 0x0b, 0xb2, 0x7e, 0x4f, 0x90, 0x18, 0xad, 0xe3, 0x3c, 0x59, 0xc7, 0x25, 0xfa, 0x86, 0x61,
    0x61, 0xb4, 0xdb, 0x8d, 0x1c, 0x43, 0xa7, 0x7e, 0x9a, 0x5f, 0x06, 0xf8, 0xe0, 0x25, 0x39, 0xc2,
    }, {
    0x1d, 0xf2, 0xd8, 0x84, 0xa6, 0x3f, 0x7b, 0x41, 0xca, 0x59, 0x63, 0xbe, 0x05, 0xe0, 0x9c, 0x27,
    0x27, 0x1b, 0xe4, 0x71, 0x49, 0xac, 0x8e, 0xd2, 0xf0, 0xc6, 0x9a, 0x0d, 0x3f, 0x53, 0x65, 0xb8,
    }
}

Definition at line 77 of file des.c.

Referenced by f_func(), and main().

const uint32_t S_boxes_P_shuffle[8][64] [static]

This table contains the results of applying both the S-box and P-shuffle.

It can be regenerated by compiling this file with -DCONFIG_SMALL -DTEST -DGENTABLES

Definition at line 109 of file des.c.

Referenced by f_func().


Generated on Sat Dec 18 05:15:51 2010 for MythTV by  doxygen 1.5.5