des.h revision 1.2 1 1.2 itojun /* $NetBSD: des.h,v 1.2 2000/08/31 07:33:04 itojun Exp $ */
2 1.2 itojun /* $KAME: des.h,v 1.5 2000/08/31 07:27:26 itojun Exp $ */
3 1.1 thorpej
4 1.1 thorpej /* lib/des/des.h */
5 1.1 thorpej /* Copyright (C) 1995-1996 Eric Young (eay (at) mincom.oz.au)
6 1.1 thorpej * All rights reserved.
7 1.1 thorpej *
8 1.1 thorpej * This file is part of an SSL implementation written
9 1.1 thorpej * by Eric Young (eay (at) mincom.oz.au).
10 1.1 thorpej * The implementation was written so as to conform with Netscapes SSL
11 1.1 thorpej * specification. This library and applications are
12 1.1 thorpej * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
13 1.1 thorpej * as long as the following conditions are aheared to.
14 1.1 thorpej *
15 1.1 thorpej * Copyright remains Eric Young's, and as such any Copyright notices in
16 1.1 thorpej * the code are not to be removed. If this code is used in a product,
17 1.1 thorpej * Eric Young should be given attribution as the author of the parts used.
18 1.1 thorpej * This can be in the form of a textual message at program startup or
19 1.1 thorpej * in documentation (online or textual) provided with the package.
20 1.1 thorpej *
21 1.1 thorpej * Redistribution and use in source and binary forms, with or without
22 1.1 thorpej * modification, are permitted provided that the following conditions
23 1.1 thorpej * are met:
24 1.1 thorpej * 1. Redistributions of source code must retain the copyright
25 1.1 thorpej * notice, this list of conditions and the following disclaimer.
26 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
27 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
28 1.1 thorpej * documentation and/or other materials provided with the distribution.
29 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
30 1.1 thorpej * must display the following acknowledgement:
31 1.1 thorpej * This product includes software developed by Eric Young (eay (at) mincom.oz.au)
32 1.1 thorpej *
33 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
34 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 1.1 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 1.1 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
37 1.1 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 1.1 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 1.1 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 1.1 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 1.1 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 1.1 thorpej * SUCH DAMAGE.
44 1.1 thorpej *
45 1.1 thorpej * The licence and distribution terms for any publically available version or
46 1.1 thorpej * derivative of this code cannot be changed. i.e. this code cannot simply be
47 1.1 thorpej * copied and put under another distribution licence
48 1.1 thorpej * [including the GNU Public Licence.]
49 1.1 thorpej */
50 1.1 thorpej
51 1.1 thorpej #ifndef HEADER_DES_H
52 1.1 thorpej #define HEADER_DES_H
53 1.1 thorpej
54 1.1 thorpej #ifdef __cplusplus
55 1.1 thorpej extern "C" {
56 1.1 thorpej #endif
57 1.1 thorpej
58 1.2 itojun /* must be 32bit quantity */
59 1.2 itojun #define DES_LONG u_int32_t
60 1.1 thorpej
61 1.1 thorpej typedef unsigned char des_cblock[8];
62 1.1 thorpej typedef struct des_ks_struct
63 1.1 thorpej {
64 1.1 thorpej union {
65 1.1 thorpej des_cblock _;
66 1.1 thorpej /* make sure things are correct size on machines with
67 1.1 thorpej * 8 byte longs */
68 1.1 thorpej DES_LONG pad[2];
69 1.1 thorpej } ks;
70 1.1 thorpej #undef _
71 1.1 thorpej #define _ ks._
72 1.1 thorpej } des_key_schedule[16];
73 1.1 thorpej
74 1.1 thorpej #define DES_KEY_SZ (sizeof(des_cblock))
75 1.1 thorpej #define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
76 1.1 thorpej
77 1.1 thorpej #define DES_ENCRYPT 1
78 1.1 thorpej #define DES_DECRYPT 0
79 1.1 thorpej
80 1.1 thorpej #define DES_CBC_MODE 0
81 1.1 thorpej #define DES_PCBC_MODE 1
82 1.1 thorpej
83 1.1 thorpej extern int des_check_key; /* defaults to false */
84 1.1 thorpej
85 1.1 thorpej /* The next line is used to disable full ANSI prototypes, if your
86 1.1 thorpej * compiler has problems with the prototypes, make sure this line always
87 1.1 thorpej * evaluates to true :-) */
88 1.2 itojun char *des_options __P((void));
89 1.2 itojun struct mbuf;
90 1.2 itojun int des_cbc_encrypt __P((struct mbuf *, size_t, size_t,
91 1.2 itojun des_key_schedule, des_cblock *, int));
92 1.2 itojun void des_3cbc_encrypt __P((des_cblock *, des_cblock *, long,
93 1.2 itojun des_key_schedule, des_key_schedule,
94 1.2 itojun des_cblock *, des_cblock *, int));
95 1.2 itojun extern int des_3cbc_process __P((struct mbuf *, size_t, size_t,
96 1.2 itojun des_key_schedule *, des_cblock *, int));
97 1.2 itojun void des_ecb_encrypt __P((des_cblock *, des_cblock *,
98 1.2 itojun des_key_schedule, int));
99 1.2 itojun void des_encrypt __P((DES_LONG *, des_key_schedule, int));
100 1.2 itojun void des_encrypt2 __P((DES_LONG *, des_key_schedule, int));
101 1.2 itojun
102 1.2 itojun void des_set_odd_parity __P((des_cblock *));
103 1.2 itojun int des_is_weak_key __P((des_cblock *));
104 1.2 itojun int des_set_key __P((des_cblock *, des_key_schedule));
105 1.2 itojun int des_key_sched __P((des_cblock *, des_key_schedule));
106 1.1 thorpej
107 1.1 thorpej #ifdef __cplusplus
108 1.1 thorpej }
109 1.1 thorpej #endif
110 1.1 thorpej
111 1.1 thorpej #endif
112