Print this page
5072963 Need an optimized AES implementation for amd64
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/common/crypto/aes/aes_cbc_crypt.h
+++ new/usr/src/common/crypto/aes/aes_cbc_crypt.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.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
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.
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 - * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
22 + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #ifndef _AES_CBC_CRYPT_H
27 27 #define _AES_CBC_CRYPT_H
28 28
29 -#pragma ident "@(#)aes_cbc_crypt.h 1.6 07/09/11 SMI"
29 +#pragma ident "@(#)aes_cbc_crypt.h 1.7 08/05/21 SMI"
30 30
31 31 #ifdef __cplusplus
32 32 extern "C" {
33 33 #endif
34 34
35 35 #include <sys/crypto/common.h>
36 36 #include "aes_impl.h"
37 37
38 38 /*
39 39 * ac_keysched: Pointer to key schedule.
40 40 *
41 41 * ac_keysched_len: Length of the key schedule.
42 42 *
43 43 * ac_remainder: This is for residual data, i.e. data that can't
44 44 * be processed because there are too few bytes.
45 45 * Must wait until more data arrives.
46 46 *
47 47 * ac_remainder_len: Number of bytes in ac_remainder.
48 48 *
49 49 * ac_iv: Scratch buffer that sometimes contains the IV.
50 50 *
51 51 * ac_lastblock: Scratch buffer.
52 52 *
53 53 * ac_lastp: Pointer to previous block of ciphertext.
54 54 *
55 55 * ac_copy_to: Pointer to where encrypted residual data needs
56 56 * to be copied.
57 57 *
58 58 * ac_flags: AES_PROVIDER_OWNS_KEY_SCHEDULE
59 59 * When a context is freed, it is necessary
60 60 * to know whether the key schedule was allocated
61 61 * by the caller, or by aes_encrypt_init() or
62 62 * aes_decrypt_init(). If allocated by the latter,
63 63 * then it needs to be freed.
64 64 *
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
65 65 * AES_ECB_MODE, AES_CBC_MODE, or AES_CTR_MODE
66 66 * AES_CCM_MODE
67 67 *
68 68 * ac_ccm_mac_len: Stores length of the MAC in CCM mode.
69 69 * ac_ccm_mac_buf: Stores the intermediate value for MAC in CCM encrypt.
70 70 * In CCM decrypt, stores the input MAC value.
71 71 * ac_ccm_data_len: Length of the plaintext for CCM mode encrypt, or
72 72 * length of the ciphertext for CCM mode decrypt.
73 73 * ac_ccm_processed_data_len:
74 74 * Length of processed plaintext in CCM mode encrypt,
75 - * or length of processed ciphertex for CCM mode decrypt.
75 + * or length of processed ciphertext for CCM mode decrypt.
76 76 * ac_ccm_processed_mac_len:
77 77 * Length of MAC data accumulated in CCM mode decrypt.
78 78 *
79 79 * ac_ccm_pt_buf: Only used in CCM mode decrypt. It stores the
80 80 * decrypted plaintext to be returned when
81 81 * MAC verification succeeds in decrypt_final.
82 82 * Memory for this should be allocated in the AES module.
83 83 *
84 84 */
85 85 typedef struct aes_ctx {
86 86 void *ac_keysched;
87 87 size_t ac_keysched_len;
88 88 uint64_t ac_iv[2];
89 89 uint64_t ac_lastblock[2];
90 90 uint64_t ac_remainder[2];
91 91 size_t ac_remainder_len;
92 92 uint8_t *ac_lastp;
93 93 uint8_t *ac_copy_to;
94 94 uint32_t ac_flags;
95 95 size_t ac_ccm_mac_len;
96 96 uint64_t ac_ccm_mac_buf[2];
97 97 size_t ac_ccm_data_len;
98 98 size_t ac_ccm_processed_data_len;
99 99 size_t ac_ccm_processed_mac_len;
100 100 uint8_t *ac_ccm_pt_buf;
101 101 uint64_t ac_ccm_mac_input_buf[2];
102 102 } aes_ctx_t;
103 103
104 104 /*
105 105 * ac_cb Counter block.
106 106 *
107 107 * ac_counter_mask Mask of counter bits in the last 8 bytes of the
108 108 * counter block.
109 109 */
110 110 #define ac_cb ac_iv
111 111 #define ac_counter_mask ac_lastblock[0]
112 112
113 113 #define AES_PROVIDER_OWNS_KEY_SCHEDULE 0x00000001
114 114 #define AES_ECB_MODE 0x00000002
115 115 #define AES_CBC_MODE 0x00000004
116 116 #define AES_CTR_MODE 0x00000008
117 117 #define AES_CCM_MODE 0x00000010
118 118
119 119 extern int aes_encrypt_contiguous_blocks(aes_ctx_t *, char *, size_t,
120 120 crypto_data_t *);
121 121 extern int aes_decrypt_contiguous_blocks(aes_ctx_t *, char *, size_t,
122 122 crypto_data_t *);
123 123 extern int aes_counter_final(aes_ctx_t *, crypto_data_t *);
124 124 extern int aes_ccm_init(aes_ctx_t *, unsigned char *, size_t,
125 125 unsigned char *, size_t);
126 126 extern int aes_ccm_validate_args(CK_AES_CCM_PARAMS *, boolean_t);
127 127 extern int aes_ccm_encrypt_final(aes_ctx_t *, crypto_data_t *);
128 128 extern int aes_ccm_decrypt_final(aes_ctx_t *, crypto_data_t *);
129 129
130 130 #ifdef __cplusplus
131 131 }
132 132 #endif
133 133
134 134 #endif /* _AES_CBC_CRYPT_H */
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX