]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/intel-ipsec-mb/include/aesni_emu.h
1 /*******************************************************************************
2 Copyright (c) 2018, Intel Corporation
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of Intel Corporation nor the names of its contributors
13 may be used to endorse or promote products derived from this software
14 without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *******************************************************************************/
32 /* Interface to AESNI emulation routines */
34 /* XMM type definitions and constants */
36 #define MAX_BYTES_PER_XMM 16
37 #define MAX_WORDS_PER_XMM 8
38 #define MAX_DWORDS_PER_XMM 4
39 #define MAX_QWORDS_PER_XMM 2
42 uint8_t byte
[MAX_BYTES_PER_XMM
];
43 uint16_t word
[MAX_WORDS_PER_XMM
];
44 uint32_t dword
[MAX_DWORDS_PER_XMM
];
45 uint64_t qword
[MAX_QWORDS_PER_XMM
];
48 /* AESNI emulation API */
51 * @brief AESKEYGENASIST instruction emulation function
53 * Assist in AES round key generation using an 8 bits Round Constant
54 * (RCON) specified in \a imm8, operating on 128 bits of data
56 * @param dst pointer to 128 bit buffer to store generated key
57 * @param src pointer to 128 bit src key
58 * @param imm8 round constant used to generate key
60 IMB_DLL_LOCAL
void emulate_AESKEYGENASSIST(union xmm_reg
*dst
,
61 const union xmm_reg
*src
,
65 * @brief AESENC instruction emulation function
67 * Perform one round of an AES encryption flow
69 * @param dst pointer to 128 bit data (state) to operate on
70 * @param src pointer to 128 bit round key
72 IMB_DLL_LOCAL
void emulate_AESENC(union xmm_reg
*dst
,
73 const union xmm_reg
*src
);
76 * @brief AESENCLAST instruction emulation function
78 * Perform last round of an AES encryption flow
80 * @param dst pointer to 128 bit data (state) to operate on
81 * @param src pointer to 128 bit round key
83 IMB_DLL_LOCAL
void emulate_AESENCLAST(union xmm_reg
*dst
,
84 const union xmm_reg
*src
);
87 * @brief AESDEC instruction emulation function
89 * Perform one round of an AES decryption flow
91 * @param dst pointer to 128 bit data (state) to operate on
92 * @param src pointer to 128 bit round key
94 IMB_DLL_LOCAL
void emulate_AESDEC(union xmm_reg
*dst
,
95 const union xmm_reg
*src
);
98 * @brief AESDECLAST instruction emulation function
100 * Perform last round of an AES decryption flow
102 * @param dst pointer to 128 bit data (state) to operate on
103 * @param src pointer to 128 bit round key
105 IMB_DLL_LOCAL
void emulate_AESDECLAST(union xmm_reg
*dst
,
106 const union xmm_reg
*src
);
109 * @brief AESIMC instruction emulation function
111 * Perform the InvMixColumn transformation on
112 * a 128 bit round key
114 * @param dst pointer to 128 bit buffer to store result
115 * @param src pointer to 128 bit round key
117 IMB_DLL_LOCAL
void emulate_AESIMC(union xmm_reg
*dst
,
118 const union xmm_reg
*src
);
120 #endif /* _AESNI_EMU_H_ */