xref: /freebsd/sys/contrib/openzfs/module/icp/algs/aes/aes_impl_x86-64.c (revision 271171e0d97b88ba2a7c3bf750c9672b484c1c13)
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 https://opensource.org/licenses/CDDL-1.0.
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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #if defined(__x86_64)
26 
27 #include <sys/simd.h>
28 #include <aes/aes_impl.h>
29 
30 /*
31  * Expand the 32-bit AES cipher key array into the encryption and decryption
32  * key schedules.
33  *
34  * Parameters:
35  * key		AES key schedule to be initialized
36  * keyarr32	User key
37  * keyBits	AES key size (128, 192, or 256 bits)
38  */
39 static void
aes_x86_64_generate(aes_key_t * key,const uint32_t * keyarr32,int keybits)40 aes_x86_64_generate(aes_key_t *key, const uint32_t *keyarr32, int keybits)
41 {
42 	key->nr = rijndael_key_setup_enc_amd64(&(key->encr_ks.ks32[0]),
43 	    keyarr32, keybits);
44 	key->nr = rijndael_key_setup_dec_amd64(&(key->decr_ks.ks32[0]),
45 	    keyarr32, keybits);
46 }
47 
48 static boolean_t
aes_x86_64_will_work(void)49 aes_x86_64_will_work(void)
50 {
51 	return (B_TRUE);
52 }
53 
54 const aes_impl_ops_t aes_x86_64_impl = {
55 	.generate = &aes_x86_64_generate,
56 	.encrypt = &aes_encrypt_amd64,
57 	.decrypt = &aes_decrypt_amd64,
58 	.is_supported = &aes_x86_64_will_work,
59 	.needs_byteswap = B_FALSE,
60 	.name = "x86_64"
61 };
62 
63 #endif /* defined(__x86_64) */
64