summaryrefslogtreecommitdiffstats
path: root/src/include/kerberosIV/des.h
blob: e861d72c51206fc473acef6ef5e528d0539cabb9 (plain)
1
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
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 * include/kerberosIV/des.h
 *
 * Copyright 1987, 1988, 1994 by the Massachusetts Institute of Technology.
 * All Rights Reserved.
 *
 * Export of this software from the United States of America may
 *   require a specific license from the United States Government.
 *   It is the responsibility of any person or organization contemplating
 *   export to obtain such a license before exporting.
 * 
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
 * distribute this software and its documentation for any purpose and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of M.I.T. not be used in advertising or publicity pertaining
 * to distribution of the software without specific, written prior
 * permission.  Furthermore if you modify this software you must label
 * your software as modified software and not distribute it in such a
 * fashion that it might be confused with the original M.I.T. software.
 * M.I.T. makes no representations about the suitability of
 * this software for any purpose.  It is provided "as is" without express
 * or implied warranty.
 * 
 * Include file for the Data Encryption Standard library.
 */

/* only do the whole thing once	 */
#ifndef DES_DEFS
#define DES_DEFS

#if defined(_WIN32) && !defined(_WINDOWS)
#define _WINDOWS
#endif

#if defined(_WINDOWS)
#ifndef KRB4
#define KRB4 1
#endif
#include <win-mac.h>
#endif
#ifdef __STDC__
#include <limits.h>
#endif

/* Windows declarations */
#ifndef KRB5_CALLCONV
#define KRB5_CALLCONV
#define KRB5_CALLCONV_C
#define KRB5_DLLIMP
#define GSS_DLLIMP
#define KRB5_EXPORTVAR
#endif
#ifndef FAR
#define FAR
#define NEAR
#endif

#ifndef KRB4_32
#ifdef SIZEOF_INT
#if SIZEOF_INT >= 4
#define KRB4_32 int
#else  /* !(SIZEOF_INT >= 4) */
#define KRB4_32 long
#endif /* !(SIZEOF_INT >= 4) */
#else  /* !defined(SIZEOF_INT) */
#ifdef __STDC__
#if INT_MAX >= 0x7fffffff
#define KRB4_32 int
#else  /* !(INT_MAX >= 0x7ffffff) */
#define KRB4_32 long
#endif /* !(INT_MAX >= 0x7ffffff) */
#else  /* !defined(__STDC__) */
#define KRB4_32 long		/* worst case */
#endif /* !defined(__STDC__) */
#endif /* !defined(SIZEOF_INT) */
#endif /* !defined(KRB4_32) */

#ifndef PROTOTYPE
#if (defined(__STDC__) || defined(_WINDOWS)) && !defined(KRB5_NO_PROTOTYPES)
#define PROTOTYPE(x) x
#else
#define PROTOTYPE(x) ()
#endif
#endif

typedef unsigned char des_cblock[8];	/* crypto-block size */

/* Key schedule */
/* Ick.  We need this in here unfortunately... */
#ifndef DES_INT32
#define DES_INT32 KRB4_32
#endif

typedef struct des_ks_struct {  DES_INT32 _[2]; } des_key_schedule[16];

#define DES_KEY_SZ 	(sizeof(des_cblock))
#define DES_ENCRYPT	1
#define DES_DECRYPT	0

#ifndef NCOMPAT
#define C_Block des_cblock
#define Key_schedule des_key_schedule
#define ENCRYPT DES_ENCRYPT
#define DECRYPT DES_DECRYPT
#define KEY_SZ DES_KEY_SZ
#define string_to_key des_string_to_key
#define read_pw_string des_read_pw_string
#define random_key des_random_key
#define pcbc_encrypt des_pcbc_encrypt
#define key_sched des_key_sched
#define cbc_encrypt des_cbc_encrypt
#define cbc_cksum des_cbc_cksum
#define C_Block_print des_cblock_print
#define quad_cksum des_quad_cksum
typedef struct des_ks_struct bit_64;
#endif

#define des_cblock_print(x) des_cblock_print_file(x, stdout)


/*
 * Function Prototypes
 */

KRB5_DLLIMP int KRB5_CALLCONV
des_key_sched
	PROTOTYPE((C_Block, Key_schedule));

KRB5_DLLIMP int KRB5_CALLCONV
des_pcbc_encrypt
	PROTOTYPE((C_Block FAR *in, C_Block FAR *out, long length,
		   Key_schedule schedule, C_Block FAR *ivec, int encrypt));

KRB5_DLLIMP unsigned long KRB5_CALLCONV
des_quad_cksum
	PROTOTYPE((unsigned char FAR *in, unsigned KRB4_32 FAR *out,
		   long length, int out_count, C_Block FAR *seed));

KRB5_DLLIMP int KRB5_CALLCONV
des_string_to_key
	PROTOTYPE((char FAR *, C_Block));
#endif	/* DES_DEFS */