1 | /* |
---|
2 | * des.h |
---|
3 | * |
---|
4 | * Copyright 1987, 1988 by the Massachusetts Institute of Technology. |
---|
5 | * |
---|
6 | * For copying and distribution information, please see the file |
---|
7 | * <mit-copyright.h>. |
---|
8 | * |
---|
9 | * Include file for the Data Encryption Standard library. |
---|
10 | */ |
---|
11 | |
---|
12 | /* only do the whole thing once */ |
---|
13 | #ifndef DES_DEFS |
---|
14 | #define DES_DEFS |
---|
15 | |
---|
16 | #include "mit-copyright.h" |
---|
17 | #include "conf.h" |
---|
18 | |
---|
19 | #ifndef KRB_INT32 |
---|
20 | #define KRB_INT32 long |
---|
21 | #endif |
---|
22 | #ifndef KRB_UINT32 |
---|
23 | #define KRB_UINT32 unsigned KRB_INT32 |
---|
24 | #endif |
---|
25 | |
---|
26 | /* There are some declarations in the system-specific header files which |
---|
27 | can't be done until KRB_INT32 is defined. So they are in a macro, |
---|
28 | which we expand here if defined. */ |
---|
29 | |
---|
30 | #ifdef DECL_THAT_NEEDS_KRB_INT32 |
---|
31 | DECL_THAT_NEEDS_KRB_INT32 |
---|
32 | #endif |
---|
33 | |
---|
34 | typedef unsigned char des_cblock[8]; /* crypto-block size */ |
---|
35 | /* Key schedule */ |
---|
36 | typedef struct des_ks_struct { union { KRB_INT32 pad; des_cblock _;} __; } des_key_schedule[16]; |
---|
37 | |
---|
38 | #define DES_KEY_SZ (sizeof(des_cblock)) |
---|
39 | #define DES_ENCRYPT 1 |
---|
40 | #define DES_DECRYPT 0 |
---|
41 | |
---|
42 | #ifndef NCOMPAT |
---|
43 | #define C_Block des_cblock |
---|
44 | #define Key_schedule des_key_schedule |
---|
45 | #define ENCRYPT DES_ENCRYPT |
---|
46 | #define DECRYPT DES_DECRYPT |
---|
47 | #define KEY_SZ DES_KEY_SZ |
---|
48 | #define string_to_key des_string_to_key |
---|
49 | #define read_pw_string des_read_pw_string |
---|
50 | #define random_key des_random_key |
---|
51 | #define pcbc_encrypt des_pcbc_encrypt |
---|
52 | #define key_sched des_key_sched |
---|
53 | #define cbc_encrypt des_cbc_encrypt |
---|
54 | #define cbc_cksum des_cbc_cksum |
---|
55 | #define C_Block_print des_cblock_print |
---|
56 | #define quad_cksum des_quad_cksum |
---|
57 | typedef struct des_ks_struct bit_64; |
---|
58 | #endif |
---|
59 | |
---|
60 | #define des_cblock_print(x) des_cblock_print_file(x, stdout) |
---|
61 | |
---|
62 | /* Function declarations */ |
---|
63 | |
---|
64 | extern unsigned long INTERFACE |
---|
65 | quad_cksum PROTOTYPE (( |
---|
66 | unsigned char *in, /* input block */ |
---|
67 | unsigned KRB_INT32 *out,/* optional longer output */ |
---|
68 | long length, /* original length in bytes */ |
---|
69 | int out_count, /* number of iterations */ |
---|
70 | des_cblock c_seed)); /* secret seed, 8 bytes */ |
---|
71 | |
---|
72 | int INTERFACE |
---|
73 | des_key_sched PROTOTYPE ((des_cblock FAR, des_key_schedule FAR)); |
---|
74 | |
---|
75 | int INTERFACE |
---|
76 | des_ecb_encrypt PROTOTYPE ((des_cblock FAR, des_cblock FAR, |
---|
77 | des_key_schedule FAR, int)); |
---|
78 | |
---|
79 | int INTERFACE |
---|
80 | des_pcbc_encrypt PROTOTYPE ((des_cblock FAR, des_cblock FAR, long, |
---|
81 | des_key_schedule FAR, des_cblock FAR, int)); |
---|
82 | |
---|
83 | int INTERFACE |
---|
84 | des_is_weak_key PROTOTYPE ((des_cblock FAR)); |
---|
85 | |
---|
86 | void INTERFACE |
---|
87 | des_fixup_key_parity PROTOTYPE ((des_cblock FAR)); |
---|
88 | |
---|
89 | int INTERFACE |
---|
90 | des_check_key_parity PROTOTYPE ((des_cblock FAR)); |
---|
91 | |
---|
92 | /* |
---|
93 | These random_key routines are made external here |
---|
94 | for the Macintosh Driver which exports pointers to them |
---|
95 | to applications via a driver level interface. |
---|
96 | Preserved for KClient compatability. |
---|
97 | */ |
---|
98 | |
---|
99 | int INTERFACE |
---|
100 | des_new_random_key PROTOTYPE (( des_cblock )); |
---|
101 | |
---|
102 | void INTERFACE |
---|
103 | des_init_random_number_generator PROTOTYPE (( des_cblock )); |
---|
104 | |
---|
105 | void INTERFACE |
---|
106 | des_set_random_generator_seed PROTOTYPE (( des_cblock )); |
---|
107 | |
---|
108 | |
---|
109 | /* FIXME, put the rest of the function declarations here */ |
---|
110 | |
---|
111 | #endif /* DES_DEFS */ |
---|