xref: /titanic_41/usr/src/common/crypto/des/des_impl.h (revision 63360950109af2ce85a962ca61f40b8782f11100)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_DES_IMPL_H
27 #define	_DES_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Common definitions used by DES
33  */
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	DES_BLOCK_LEN	8
40 
41 #define	DES_XOR_BLOCK(src, dst) \
42 	(dst)[0] ^= (src)[0]; \
43 	(dst)[1] ^= (src)[1]; \
44 	(dst)[2] ^= (src)[2]; \
45 	(dst)[3] ^= (src)[3]; \
46 	(dst)[4] ^= (src)[4]; \
47 	(dst)[5] ^= (src)[5]; \
48 	(dst)[6] ^= (src)[6]; \
49 	(dst)[7] ^= (src)[7]
50 
51 typedef enum des_strength {
52 	DES = 1,
53 	DES2,
54 	DES3
55 } des_strength_t;
56 
57 #define	DES_KEYSIZE	8
58 #define	DES_MINBITS	64
59 #define	DES_MAXBITS	64
60 #define	DES_MINBYTES	(DES_MINBITS / 8)
61 #define	DES_MAXBYTES	(DES_MAXBITS / 8)
62 #define	DES_IV_LEN	8
63 
64 #define	DES2_KEYSIZE	(2 * DES_KEYSIZE)
65 #define	DES2_MINBITS	(2 * DES_MINBITS)
66 #define	DES2_MAXBITS	(2 * DES_MAXBITS)
67 
68 #define	DES3_KEYSIZE	(3 * DES_KEYSIZE)
69 #define	DES3_MINBITS	(3 * DES_MINBITS)
70 #define	DES3_MAXBITS	(3 * DES_MAXBITS)
71 #define	DES3_MINBYTES	(DES3_MINBITS / 8)
72 #define	DES3_MAXBYTES	(DES3_MAXBITS / 8)
73 
74 extern uint64_t des_crypt_impl(uint64_t *, uint64_t, int);
75 extern void des_ks(uint64_t *, uint64_t);
76 extern void des_crunch_block(void *, uint8_t *, uint8_t *, boolean_t);
77 extern void des3_crunch_block(void *, uint8_t *, uint8_t *, boolean_t);
78 extern void des_init_keysched(uint8_t *, des_strength_t, void *);
79 extern void *des_alloc_keysched(size_t *, des_strength_t, int);
80 extern boolean_t des_keycheck(uint8_t *, des_strength_t, uint8_t *);
81 extern void des_parity_fix(uint8_t *, des_strength_t, uint8_t *);
82 
83 #ifdef	__cplusplus
84 }
85 #endif
86 
87 #endif	/* _DES_IMPL_H */
88