NCBI C++ ToolKit
Macros | Functions | Variables
des.c File Reference
#include <config.h>
#include <tds_sysdep_public.h>
#include <freetds/bytes.h>
#include <freetds/utils/des.h>
+ Include dependency graph for des.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define P32I_INDEX_ROW(n, i, a, b, c, d)    n==a ? 0+i : n==b ? 1+i : n==c ? 2+i : n==d ? 3+i
 
#define P32I_INDEX(n)
 

Functions

void tds_des_set_odd_parity (des_cblock key)
 
static void permute_ip (const des_cblock inblock, const DES_KEY *key, des_cblock outblock)
 
static void permute_fp (const des_cblock inblock, const DES_KEY *key, des_cblock outblock)
 
static void perminit_ip (DES_KEY *key)
 
static void spinit (DES_KEY *key)
 
static void perminit_fp (DES_KEY *key)
 
static uint32_t f (const DES_KEY *key, register uint32_t r, register const unsigned char *subkey)
 
static int des_init (DES_KEY *key)
 
int tds_des_set_key (DES_KEY *dkey, const des_cblock user_key, size_t len)
 
void tds_des_encrypt (const DES_KEY *key, des_cblock block)
 
int tds_des_ecb_encrypt (const void *plaintext, size_t len, DES_KEY *akey, unsigned char *output)
 

Variables

static const char ip []
 
static const char fp []
 
static const char pc1 []
 
static const char totrot []
 
static const char pc2 []
 
static const char si [8][64]
 
static const char pbox [32]
 
static const int bytebit []
 
static const int nibblebit []
 

Macro Definition Documentation

◆ P32I_INDEX

#define P32I_INDEX (   n)
Value:
(P32I_INDEX_ROW(n, 0, 16, 7, 20, 21) :\
P32I_INDEX_ROW(n, 4, 29, 12, 28, 17) :\
P32I_INDEX_ROW(n, 8, 1, 15, 23, 26) :\
P32I_INDEX_ROW(n,12, 5, 18, 31, 10) :\
P32I_INDEX_ROW(n,16, 2, 8, 24, 14) :\
P32I_INDEX_ROW(n,20, 32, 27, 3, 9) :\
P32I_INDEX_ROW(n,24, 19, 13, 30, 6) :\
P32I_INDEX_ROW(n,28, 22, 11, 4, 25) : 0x7f)
#define P32I_INDEX_ROW(n, i, a, b, c, d)
Definition: des.c:211
yy_size_t n

Definition at line 213 of file des.c.

◆ P32I_INDEX_ROW

#define P32I_INDEX_ROW (   n,
  i,
  a,
  b,
  c,
 
)     n==a ? 0+i : n==b ? 1+i : n==c ? 2+i : n==d ? 3+i

Definition at line 211 of file des.c.

Function Documentation

◆ des_init()

static int des_init ( DES_KEY key)
static

Definition at line 275 of file des.c.

References ncbi::grid::netcache::search::fields::key, perminit_fp(), perminit_ip(), and spinit().

Referenced by tds_des_set_key().

◆ f()

static uint32_t f ( const DES_KEY key,
register uint32_t  r,
register const unsigned char *  subkey 
)
static

◆ perminit_fp()

static void perminit_fp ( DES_KEY key)
static

Definition at line 577 of file des.c.

References bytebit, fp, i, ncbi::grid::netcache::search::fields::key, l(), and nibblebit.

Referenced by des_init().

◆ perminit_ip()

static void perminit_ip ( DES_KEY key)
static

Definition at line 555 of file des.c.

References bytebit, i, ip, ncbi::grid::netcache::search::fields::key, l(), and nibblebit.

Referenced by des_init().

◆ permute_fp()

static void permute_fp ( const des_cblock  inblock,
const DES_KEY key,
des_cblock  outblock 
)
static

Definition at line 473 of file des.c.

References ncbi::grid::netcache::search::fields::key.

Referenced by tds_des_encrypt().

◆ permute_ip()

static void permute_ip ( const des_cblock  inblock,
const DES_KEY key,
des_cblock  outblock 
)
static

Definition at line 444 of file des.c.

References ncbi::grid::netcache::search::fields::key.

Referenced by tds_des_encrypt().

◆ spinit()

static void spinit ( DES_KEY key)
static

Definition at line 600 of file des.c.

References i, ncbi::grid::netcache::search::fields::key, pbox, si, and val.

Referenced by des_init().

◆ tds_des_ecb_encrypt()

int tds_des_ecb_encrypt ( const void *  plaintext,
size_t  len,
DES_KEY akey,
unsigned char *  output 
)

Definition at line 627 of file des.c.

References len, output, and tds_des_encrypt().

◆ tds_des_encrypt()

void tds_des_encrypt ( const DES_KEY key,
des_cblock  block 
)

◆ tds_des_set_key()

int tds_des_set_key ( DES_KEY dkey,
const des_cblock  user_key,
size_t  len 
)

Definition at line 288 of file des.c.

References bytebit, des_init(), i, des_key::kn, l(), pc1, pc2, and totrot.

◆ tds_des_set_odd_parity()

void tds_des_set_odd_parity ( des_cblock  key)

Definition at line 46 of file des.c.

References i, and ncbi::grid::netcache::search::fields::key.

Variable Documentation

◆ bytebit

const int bytebit[]
static
Initial value:
= {
0200, 0100, 040, 020, 010, 04, 02, 01
}

Definition at line 263 of file des.c.

Referenced by perminit_fp(), perminit_ip(), and tds_des_set_key().

◆ fp

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

Definition at line 87 of file des.c.

Referenced by perminit_fp().

◆ ip

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

Definition at line 75 of file des.c.

Referenced by perminit_ip().

◆ nibblebit

const int nibblebit[]
static
Initial value:
= {
010, 04, 02, 01
}

Definition at line 267 of file des.c.

Referenced by perminit_fp(), and perminit_ip().

◆ pbox

const char pbox[32]
static

Definition at line 223 of file des.c.

Referenced by spinit().

◆ pc1

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

Definition at line 116 of file des.c.

Referenced by tds_des_set_key().

◆ pc2

const char pc2[]
static
Initial value:
= {
14, 17, 11, 24, 1, 5,
3, 28, 15, 6, 21, 10,
23, 19, 12, 4, 26, 8,
16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55,
30, 40, 51, 45, 33, 48,
44, 49, 39, 56, 34, 53,
46, 42, 50, 36, 29, 32
}

Definition at line 134 of file des.c.

Referenced by tds_des_set_key().

◆ si

const char si[8][64]
static

Definition at line 146 of file des.c.

Referenced by spinit().

◆ totrot

const char totrot[]
static
Initial value:
= {
1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28
}

Definition at line 129 of file des.c.

Referenced by tds_des_set_key().

Modified on Fri Sep 20 14:58:18 2024 by modify_doxy.py rev. 669887