xref: /isa-l_crypto/include/aes_cbc_internal.h (revision e4a84933e1bf6f71c1dc3b1cc2ab577691c784d9)
1 /**********************************************************************
2   Copyright(c) 2024 Intel Corporation All rights reserved.
3 
4   Redistribution and use in source and binary forms, with or without
5   modification, are permitted provided that the following conditions
6   are met:
7     * Redistributions of source code must retain the above copyright
8       notice, 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
11       the documentation and/or other materials provided with the
12       distribution.
13     * Neither the name of Intel Corporation nor the names of its
14       contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16 
17   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 **********************************************************************/
29 
30 /**
31  *  @file aes_cbc_internal.h
32  *  @brief AES CBC encryption/decryption internal function prototypes.
33  *
34  */
35 #ifndef _AES_CBC_INTERNAL_H
36 #define _AES_CBC_INTERNAL_H
37 
38 #include <stdint.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 
43 #endif
44 
45 /** @brief CBC-AES 128 bit key Decryption
46  *
47  * @requires SSE4.1 and AESNI
48  *
49  * arg 1: in:   pointer to input (cipher text)
50  * arg 2: IV:   pointer to IV, Must be 16 bytes aligned to a 16 byte boundary
51  * arg 3: keys: pointer to keys, Must be on a 16 byte boundary and length of key size * key rounds
52  * arg 4: OUT:  pointer to output (plain text ... in-place allowed)
53  * arg 5: len_bytes:  length in bytes (multiple of 16)
54  */
55 void
56 _aes_cbc_dec_128(void *in,          //!< Input cipher text
57                  uint8_t *IV,       //!< Must be 16 bytes aligned to a 16 byte boundary
58                  uint8_t *keys,     //!< Must be on a 16 byte boundary and length of key size * key
59                                     //!< rounds or dec_keys of isal_cbc_key_data
60                  void *out,         //!< Output plain text
61                  uint64_t len_bytes //!< Must be a multiple of 16 bytes
62 );
63 
64 /** @brief CBC-AES 192 bit key Decryption
65  *
66  * @requires SSE4.1 and AESNI
67  *
68  */
69 void
70 _aes_cbc_dec_192(void *in,          //!< Input cipher text
71                  uint8_t *IV,       //!< Must be 16 bytes aligned to a 16 byte boundary
72                  uint8_t *keys,     //!< Must be on a 16 byte boundary and length of key size * key
73                                     //!< rounds or dec_keys of isal_cbc_key_data
74                  void *out,         //!< Output plain text
75                  uint64_t len_bytes //!< Must be a multiple of 16 bytes
76 );
77 
78 /** @brief CBC-AES 256 bit key Decryption
79  *
80  * @requires SSE4.1 and AESNI
81  *
82  */
83 void
84 _aes_cbc_dec_256(void *in,          //!< Input cipher text
85                  uint8_t *IV,       //!< Must be 16 bytes aligned to a 16 byte boundary
86                  uint8_t *keys,     //!< Must be on a 16 byte boundary and length of key size * key
87                                     //!< rounds or dec_keys of isal_cbc_key_data
88                  void *out,         //!< Output plain text
89                  uint64_t len_bytes //!< Must be a multiple of 16 bytes
90 );
91 
92 /** @brief CBC-AES 128 bit key Encryption
93  *
94  * @requires SSE4.1 and AESNI
95  *
96  * arg 1: in:   pointer to input (plain text)
97  * arg 2: IV:   pointer to IV, Must be 16 bytes aligned to a 16 byte boundary
98  * arg 3: keys: pointer to keys, Must be on a 16 byte boundary and length of key size * key rounds
99  * arg 4: OUT:  pointer to output (cipher text ... in-place allowed)
100  * arg 5: len_bytes:  length in bytes (multiple of 16)
101  */
102 int
103 _aes_cbc_enc_128(void *in,          //!< Input plain text
104                  uint8_t *IV,       //!< Must be 16 bytes aligned to a 16 byte boundary
105                  uint8_t *keys,     //!< Must be on a 16 byte boundary and length of key size * key
106                                     //!< rounds or enc_keys of isal_cbc_key_data
107                  void *out,         //!< Output cipher text
108                  uint64_t len_bytes //!< Must be a multiple of 16 bytes
109 );
110 /** @brief CBC-AES 192 bit key Encryption
111  *
112  * @requires SSE4.1 and AESNI
113  *
114  */
115 int
116 _aes_cbc_enc_192(void *in,          //!< Input plain text
117                  uint8_t *IV,       //!< Must be 16 bytes aligned to a 16 byte boundary
118                  uint8_t *keys,     //!< Must be on a 16 byte boundary and length of key size * key
119                                     //!< rounds or enc_keys of isal_cbc_key_data
120                  void *out,         //!< Output cipher text
121                  uint64_t len_bytes //!< Must be a multiple of 16 bytes
122 );
123 
124 /** @brief CBC-AES 256 bit key Encryption
125  *
126  * @requires SSE4.1 and AESNI
127  *
128  */
129 int
130 _aes_cbc_enc_256(void *in,          //!< Input plain text
131                  uint8_t *IV,       //!< Must be 16 bytes aligned to a 16 byte boundary
132                  uint8_t *keys,     //!< Must be on a 16 byte boundary and length of key size * key
133                                     //!< rounds or enc_keys of isal_cbc_key_data
134                  void *out,         //!< Output cipher text
135                  uint64_t len_bytes //!< Must be a multiple of 16 bytes
136 );
137 
138 #ifdef __cplusplus
139 }
140 #endif //__cplusplus
141 #endif // ifndef _AES_CBC_INTERNAL_H
142