Print this page
4896 Performance improvements for KCF AES modes
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/common/crypto/des/des_impl.h
+++ new/usr/src/common/crypto/des/des_impl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 +/*
26 + * Copyright 2015 by Saso Kiselkov. All rights reserved.
27 + */
25 28
26 29 #ifndef _DES_IMPL_H
27 30 #define _DES_IMPL_H
28 31
29 32 /*
30 33 * Common definitions used by DES
31 34 */
32 35
33 36 #ifdef __cplusplus
34 37 extern "C" {
35 38 #endif
36 39
37 40 #define DES_BLOCK_LEN 8
38 41
39 42 #define DES_COPY_BLOCK(src, dst) \
40 43 (dst)[0] = (src)[0]; \
41 44 (dst)[1] = (src)[1]; \
42 45 (dst)[2] = (src)[2]; \
43 46 (dst)[3] = (src)[3]; \
44 47 (dst)[4] = (src)[4]; \
45 48 (dst)[5] = (src)[5]; \
46 49 (dst)[6] = (src)[6]; \
47 50 (dst)[7] = (src)[7];
48 51
49 52 #define DES_XOR_BLOCK(src, dst) \
50 53 (dst)[0] ^= (src)[0]; \
51 54 (dst)[1] ^= (src)[1]; \
52 55 (dst)[2] ^= (src)[2]; \
53 56 (dst)[3] ^= (src)[3]; \
54 57 (dst)[4] ^= (src)[4]; \
55 58 (dst)[5] ^= (src)[5]; \
56 59 (dst)[6] ^= (src)[6]; \
57 60 (dst)[7] ^= (src)[7]
58 61
59 62 typedef enum des_strength {
60 63 DES = 1,
61 64 DES2,
62 65 DES3
63 66 } des_strength_t;
64 67
65 68 #define DES3_STRENGTH 0x08000000
66 69
67 70 #define DES_KEYSIZE 8
68 71 #define DES_MINBITS 64
69 72 #define DES_MAXBITS 64
70 73 #define DES_MINBYTES (DES_MINBITS / 8)
71 74 #define DES_MAXBYTES (DES_MAXBITS / 8)
72 75 #define DES_IV_LEN 8
73 76
74 77 #define DES2_KEYSIZE (2 * DES_KEYSIZE)
75 78 #define DES2_MINBITS (2 * DES_MINBITS)
76 79 #define DES2_MAXBITS (2 * DES_MAXBITS)
77 80 #define DES2_MINBYTES (DES2_MINBITS / 8)
78 81 #define DES2_MAXBYTES (DES2_MAXBITS / 8)
79 82
80 83 #define DES3_KEYSIZE (3 * DES_KEYSIZE)
81 84 #define DES3_MINBITS (2 * DES_MINBITS) /* DES3 handles CKK_DES2 keys */
82 85 #define DES3_MAXBITS (3 * DES_MAXBITS)
83 86 #define DES3_MINBYTES (DES3_MINBITS / 8)
84 87 #define DES3_MAXBYTES (DES3_MAXBITS / 8)
85 88
86 89 extern int des_encrypt_contiguous_blocks(void *, char *, size_t,
87 90 crypto_data_t *);
88 91 extern int des_decrypt_contiguous_blocks(void *, char *, size_t,
89 92 crypto_data_t *);
↓ open down ↓ |
55 lines elided |
↑ open up ↑ |
90 93 extern uint64_t des_crypt_impl(uint64_t *, uint64_t, int);
91 94 extern void des_ks(uint64_t *, uint64_t);
92 95 extern int des_crunch_block(const void *, const uint8_t *, uint8_t *,
93 96 boolean_t);
94 97 extern int des3_crunch_block(const void *, const uint8_t *, uint8_t *,
95 98 boolean_t);
96 99 extern void des_init_keysched(uint8_t *, des_strength_t, void *);
97 100 extern void *des_alloc_keysched(size_t *, des_strength_t, int);
98 101 extern boolean_t des_keycheck(uint8_t *, des_strength_t, uint8_t *);
99 102 extern void des_parity_fix(uint8_t *, des_strength_t, uint8_t *);
100 -extern void des_copy_block(uint8_t *, uint8_t *);
101 -extern void des_xor_block(uint8_t *, uint8_t *);
103 +extern void des_copy_block(const uint8_t *, uint8_t *);
104 +extern void des_xor_block(const uint8_t *, uint8_t *);
102 105 extern int des_encrypt_block(const void *, const uint8_t *, uint8_t *);
103 106 extern int des3_encrypt_block(const void *, const uint8_t *, uint8_t *);
104 107 extern int des_decrypt_block(const void *, const uint8_t *, uint8_t *);
105 108 extern int des3_decrypt_block(const void *, const uint8_t *, uint8_t *);
106 109
107 110 #ifdef _DES_IMPL
108 111
109 112 #ifdef _KERNEL
110 113 typedef enum des_mech_type {
111 114 DES_ECB_MECH_INFO_TYPE, /* SUN_CKM_DES_ECB */
112 115 DES_CBC_MECH_INFO_TYPE, /* SUN_CKM_DES_CBC */
113 116 DES_CFB_MECH_INFO_TYPE, /* SUN_CKM_DES_CFB */
114 117 DES3_ECB_MECH_INFO_TYPE, /* SUN_CKM_DES3_ECB */
115 118 DES3_CBC_MECH_INFO_TYPE, /* SUN_CKM_DES3_CBC */
116 119 DES3_CFB_MECH_INFO_TYPE /* SUN_CKM_DES3_CFB */
117 120 } des_mech_type_t;
118 121
119 122 #endif /* _KERNEL */
120 123 #endif /* _DES_IMPL */
121 124
122 125 #ifdef __cplusplus
123 126 }
124 127 #endif
125 128
126 129 #endif /* _DES_IMPL_H */
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX