]> git.saurik.com Git - apple/security.git/blob - AppleCSP/MiscCSPAlgs/DES.h
Security-163.tar.gz
[apple/security.git] / AppleCSP / MiscCSPAlgs / DES.h
1 /* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
2 *
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE COMPUTER, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE COMPUTER,
7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
10 *
11 * DES.h - raw DES encryption engine interface
12 *
13 * Revision History
14 * ----------------
15 * 31 Mar 97 Doug Mitchell at Apple
16 * Put per-instance data in struct _desInst
17 * 21 Aug 96 Doug Mitchell at NeXT
18 * Broke out from NSDESCryptor.m
19 * 22 Feb 96 Blaine Garst at NeXT
20 * Created.
21 */
22
23 #ifndef _CK_DES_H_
24 #define _CK_DES_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define DES_BLOCK_SIZE_BYTES 8 /* in bytes */
31 #define DES_KEY_SIZE_BITS 56 /* effective key size in bits */
32 #define DES_KEY_SIZE_BITS_EXTERNAL 64 /* clients actually pass in this much */
33 #define DES_KEY_SIZE_BYTES_EXTERNAL (DES_KEY_SIZE_BITS_EXTERNAL / 8)
34
35 #define DES_MODE_STD 0 /* standard Data Encryption Algorithm */
36 #define DES_MODE_FAST 1 /* DEA without initial and final */
37 /* permutations for speed */
38 #define DES_MODE_128 2 /* DEA without permutations and with */
39 /* 128-byte key (completely independent */
40 /* subkeys for each round) */
41
42 /*
43 * Per-instance data.
44 */
45 struct _desInst {
46 /* 8 16-bit subkeys for each of 16 rounds, initialized by setkey()
47 */
48 unsigned char kn[16][8];
49 int desmode;
50 };
51
52 typedef struct _desInst *desInst;
53
54 /* Warning: desinit() is NOT thread safe. Caller must single-thread. */
55 int desinit(desInst dinst, int mode);
56 void dessetkey(desInst dinst, char *key);
57 void endes(desInst dinst, char *block);
58 void dedes(desInst dinst, char *block);
59 void desdone(desInst dinst);
60
61 #ifdef __cplusplus
62 }
63 #endif
64
65 #endif /*_CK_DES_H_*/