xref: /freebsd/crypto/openssl/include/crypto/aes_platform.h (revision a7148ab39c03abd4d1a84997c70bf96f15dd2a09)
1 /*
2  * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #ifndef OSSL_AES_PLATFORM_H
11 # define OSSL_AES_PLATFORM_H
12 # pragma once
13 
14 # include <openssl/aes.h>
15 
16 # ifdef VPAES_ASM
17 int vpaes_set_encrypt_key(const unsigned char *userKey, int bits,
18                           AES_KEY *key);
19 int vpaes_set_decrypt_key(const unsigned char *userKey, int bits,
20                           AES_KEY *key);
21 void vpaes_encrypt(const unsigned char *in, unsigned char *out,
22                    const AES_KEY *key);
23 void vpaes_decrypt(const unsigned char *in, unsigned char *out,
24                    const AES_KEY *key);
25 void vpaes_cbc_encrypt(const unsigned char *in,
26                        unsigned char *out,
27                        size_t length,
28                        const AES_KEY *key, unsigned char *ivec, int enc);
29 # endif /* VPAES_ASM */
30 
31 # ifdef BSAES_ASM
32 void ossl_bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out,
33                             size_t length, const AES_KEY *key,
34                             unsigned char ivec[16], int enc);
35 void ossl_bsaes_ctr32_encrypt_blocks(const unsigned char *in,
36                                      unsigned char *out, size_t len,
37                                      const AES_KEY *key,
38                                      const unsigned char ivec[16]);
39 void ossl_bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out,
40                             size_t len, const AES_KEY *key1,
41                             const AES_KEY *key2, const unsigned char iv[16]);
42 void ossl_bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out,
43                             size_t len, const AES_KEY *key1,
44                             const AES_KEY *key2, const unsigned char iv[16]);
45 # endif /* BSAES_ASM */
46 
47 # ifdef AES_CTR_ASM
48 void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out,
49                        size_t blocks, const AES_KEY *key,
50                        const unsigned char ivec[AES_BLOCK_SIZE]);
51 # endif /*  AES_CTR_ASM */
52 
53 # ifdef AES_XTS_ASM
54 void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len,
55                      const AES_KEY *key1, const AES_KEY *key2,
56                      const unsigned char iv[16]);
57 void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len,
58                      const AES_KEY *key1, const AES_KEY *key2,
59                      const unsigned char iv[16]);
60 # endif /* AES_XTS_ASM */
61 
62 # if defined(OPENSSL_CPUID_OBJ)
63 #  if (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC))
64 #   include "crypto/ppc_arch.h"
65 #   ifdef VPAES_ASM
66 #    define VPAES_CAPABLE (OPENSSL_ppccap_P & PPC_ALTIVEC)
67 #   endif
68 #   if !defined(OPENSSL_SYS_MACOSX)
69 #   define HWAES_CAPABLE  (OPENSSL_ppccap_P & PPC_CRYPTO207)
70 #   define HWAES_set_encrypt_key aes_p8_set_encrypt_key
71 #   define HWAES_set_decrypt_key aes_p8_set_decrypt_key
72 #   define HWAES_encrypt aes_p8_encrypt
73 #   define HWAES_decrypt aes_p8_decrypt
74 #   define HWAES_cbc_encrypt aes_p8_cbc_encrypt
75 #   define HWAES_ctr32_encrypt_blocks aes_p8_ctr32_encrypt_blocks
76 #   define HWAES_xts_encrypt aes_p8_xts_encrypt
77 #   define HWAES_xts_decrypt aes_p8_xts_decrypt
78 #   endif /* OPENSSL_SYS_MACOSX */
79 #  endif /* PPC */
80 
81 #  if (defined(__arm__) || defined(__arm) || defined(__aarch64__))
82 #   include "arm_arch.h"
83 #   if __ARM_MAX_ARCH__>=7
84 #    if defined(BSAES_ASM)
85 #     define BSAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
86 #    endif
87 #    if defined(VPAES_ASM)
88 #     define VPAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
89 #    endif
90 #    define HWAES_CAPABLE (OPENSSL_armcap_P & ARMV8_AES)
91 #    define HWAES_set_encrypt_key aes_v8_set_encrypt_key
92 #    define HWAES_set_decrypt_key aes_v8_set_decrypt_key
93 #    define HWAES_encrypt aes_v8_encrypt
94 #    define HWAES_decrypt aes_v8_decrypt
95 #    define HWAES_cbc_encrypt aes_v8_cbc_encrypt
96 #    define HWAES_ecb_encrypt aes_v8_ecb_encrypt
97 #    if __ARM_MAX_ARCH__>=8 && defined(__aarch64__)
98 #     define HWAES_xts_encrypt aes_v8_xts_encrypt
99 #     define HWAES_xts_decrypt aes_v8_xts_decrypt
100 #    endif
101 #    define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks
102 #    define AES_PMULL_CAPABLE ((OPENSSL_armcap_P & ARMV8_PMULL) && (OPENSSL_armcap_P & ARMV8_AES))
103 #    define AES_GCM_ENC_BYTES 512
104 #    define AES_GCM_DEC_BYTES 512
105 #    if __ARM_MAX_ARCH__>=8 && defined(__aarch64__)
106 #     define AES_gcm_encrypt armv8_aes_gcm_encrypt
107 #     define AES_gcm_decrypt armv8_aes_gcm_decrypt
108 #     define AES_GCM_ASM(gctx) ((gctx)->ctr==aes_v8_ctr32_encrypt_blocks && \
109                                 (gctx)->gcm.ghash==gcm_ghash_v8)
110 size_t aes_gcm_enc_128_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
111                               uint64_t *Xi, unsigned char ivec[16], const void *key);
112 size_t aes_gcm_enc_192_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
113                               uint64_t *Xi, unsigned char ivec[16], const void *key);
114 size_t aes_gcm_enc_256_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
115                               uint64_t *Xi, unsigned char ivec[16], const void *key);
116 size_t aes_gcm_dec_128_kernel(const uint8_t * ciphertext, uint64_t plaintext_length, uint8_t * plaintext,
117                               uint64_t *Xi, unsigned char ivec[16], const void *key);
118 size_t aes_gcm_dec_192_kernel(const uint8_t * ciphertext, uint64_t plaintext_length, uint8_t * plaintext,
119                               uint64_t *Xi, unsigned char ivec[16], const void *key);
120 size_t aes_gcm_dec_256_kernel(const uint8_t * ciphertext, uint64_t plaintext_length, uint8_t * plaintext,
121                               uint64_t *Xi, unsigned char ivec[16], const void *key);
122 size_t armv8_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key,
123                              unsigned char ivec[16], u64 *Xi);
124 size_t armv8_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key,
125                              unsigned char ivec[16], u64 *Xi);
126 void gcm_ghash_v8(u64 Xi[2],const u128 Htable[16],const u8 *inp, size_t len);
127 #    endif
128 #   endif
129 #  endif
130 # endif /* OPENSSL_CPUID_OBJ */
131 
132 # if     defined(AES_ASM) &&     ( \
133          defined(__x86_64)       || defined(__x86_64__)  || \
134          defined(_M_AMD64)       || defined(_M_X64)      )
135 #  define AES_CBC_HMAC_SHA_CAPABLE 1
136 #  define AESNI_CBC_HMAC_SHA_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
137 # endif
138 
139 # if     defined(AES_ASM) && !defined(I386_ONLY) &&      (  \
140          ((defined(__i386)       || defined(__i386__)    || \
141            defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \
142          defined(__x86_64)       || defined(__x86_64__)  || \
143          defined(_M_AMD64)       || defined(_M_X64)      )
144 
145 /* AES-NI section */
146 
147 #  define AESNI_CAPABLE   (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
148 #  ifdef VPAES_ASM
149 #   define VPAES_CAPABLE   (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
150 #  endif
151 #  ifdef BSAES_ASM
152 #   define BSAES_CAPABLE   (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
153 #  endif
154 
155 #  define AES_GCM_ENC_BYTES 32
156 #  define AES_GCM_DEC_BYTES 16
157 
158 int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
159                           AES_KEY *key);
160 int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
161                           AES_KEY *key);
162 
163 void aesni_encrypt(const unsigned char *in, unsigned char *out,
164                    const AES_KEY *key);
165 void aesni_decrypt(const unsigned char *in, unsigned char *out,
166                    const AES_KEY *key);
167 
168 void aesni_ecb_encrypt(const unsigned char *in,
169                        unsigned char *out,
170                        size_t length, const AES_KEY *key, int enc);
171 void aesni_cbc_encrypt(const unsigned char *in,
172                        unsigned char *out,
173                        size_t length,
174                        const AES_KEY *key, unsigned char *ivec, int enc);
175 #  ifndef OPENSSL_NO_OCB
176 void aesni_ocb_encrypt(const unsigned char *in, unsigned char *out,
177                        size_t blocks, const void *key,
178                        size_t start_block_num,
179                        unsigned char offset_i[16],
180                        const unsigned char L_[][16],
181                        unsigned char checksum[16]);
182 void aesni_ocb_decrypt(const unsigned char *in, unsigned char *out,
183                        size_t blocks, const void *key,
184                        size_t start_block_num,
185                        unsigned char offset_i[16],
186                        const unsigned char L_[][16],
187                        unsigned char checksum[16]);
188 #  endif /* OPENSSL_NO_OCB */
189 
190 void aesni_ctr32_encrypt_blocks(const unsigned char *in,
191                                 unsigned char *out,
192                                 size_t blocks,
193                                 const void *key, const unsigned char *ivec);
194 
195 void aesni_xts_encrypt(const unsigned char *in,
196                        unsigned char *out,
197                        size_t length,
198                        const AES_KEY *key1, const AES_KEY *key2,
199                        const unsigned char iv[16]);
200 
201 void aesni_xts_decrypt(const unsigned char *in,
202                        unsigned char *out,
203                        size_t length,
204                        const AES_KEY *key1, const AES_KEY *key2,
205                        const unsigned char iv[16]);
206 
207 void aesni_ccm64_encrypt_blocks(const unsigned char *in,
208                                 unsigned char *out,
209                                 size_t blocks,
210                                 const void *key,
211                                 const unsigned char ivec[16],
212                                 unsigned char cmac[16]);
213 
214 void aesni_ccm64_decrypt_blocks(const unsigned char *in,
215                                 unsigned char *out,
216                                 size_t blocks,
217                                 const void *key,
218                                 const unsigned char ivec[16],
219                                 unsigned char cmac[16]);
220 
221 #  if defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
222 size_t aesni_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len,
223                          const void *key, unsigned char ivec[16], u64 *Xi);
224 size_t aesni_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len,
225                          const void *key, unsigned char ivec[16], u64 *Xi);
226 void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *in, size_t len);
227 
228 #   define AES_gcm_encrypt aesni_gcm_encrypt
229 #   define AES_gcm_decrypt aesni_gcm_decrypt
230 #   define AES_GCM_ASM(ctx)    (ctx->ctr == aesni_ctr32_encrypt_blocks && \
231                                 ctx->gcm.ghash == gcm_ghash_avx)
232 #  endif
233 
234 
235 # elif defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
236 
237 /* Fujitsu SPARC64 X support */
238 #  include "crypto/sparc_arch.h"
239 
240 #  define SPARC_AES_CAPABLE       (OPENSSL_sparcv9cap_P[1] & CFR_AES)
241 #  define HWAES_CAPABLE           (OPENSSL_sparcv9cap_P[0] & SPARCV9_FJAESX)
242 #  define HWAES_set_encrypt_key aes_fx_set_encrypt_key
243 #  define HWAES_set_decrypt_key aes_fx_set_decrypt_key
244 #  define HWAES_encrypt aes_fx_encrypt
245 #  define HWAES_decrypt aes_fx_decrypt
246 #  define HWAES_cbc_encrypt aes_fx_cbc_encrypt
247 #  define HWAES_ctr32_encrypt_blocks aes_fx_ctr32_encrypt_blocks
248 
249 void aes_t4_set_encrypt_key(const unsigned char *key, int bits, AES_KEY *ks);
250 void aes_t4_set_decrypt_key(const unsigned char *key, int bits, AES_KEY *ks);
251 void aes_t4_encrypt(const unsigned char *in, unsigned char *out,
252                     const AES_KEY *key);
253 void aes_t4_decrypt(const unsigned char *in, unsigned char *out,
254                     const AES_KEY *key);
255 /*
256  * Key-length specific subroutines were chosen for following reason.
257  * Each SPARC T4 core can execute up to 8 threads which share core's
258  * resources. Loading as much key material to registers allows to
259  * minimize references to shared memory interface, as well as amount
260  * of instructions in inner loops [much needed on T4]. But then having
261  * non-key-length specific routines would require conditional branches
262  * either in inner loops or on subroutines' entries. Former is hardly
263  * acceptable, while latter means code size increase to size occupied
264  * by multiple key-length specific subroutines, so why fight?
265  */
266 void aes128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
267                            size_t len, const AES_KEY *key,
268                            unsigned char *ivec, int /*unused*/);
269 void aes128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
270                            size_t len, const AES_KEY *key,
271                            unsigned char *ivec, int /*unused*/);
272 void aes192_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
273                            size_t len, const AES_KEY *key,
274                            unsigned char *ivec, int /*unused*/);
275 void aes192_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
276                            size_t len, const AES_KEY *key,
277                            unsigned char *ivec, int /*unused*/);
278 void aes256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
279                            size_t len, const AES_KEY *key,
280                            unsigned char *ivec, int /*unused*/);
281 void aes256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
282                            size_t len, const AES_KEY *key,
283                            unsigned char *ivec, int /*unused*/);
284 void aes128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
285                              size_t blocks, const AES_KEY *key,
286                              unsigned char *ivec);
287 void aes192_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
288                              size_t blocks, const AES_KEY *key,
289                              unsigned char *ivec);
290 void aes256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
291                              size_t blocks, const AES_KEY *key,
292                              unsigned char *ivec);
293 void aes128_t4_xts_encrypt(const unsigned char *in, unsigned char *out,
294                            size_t blocks, const AES_KEY *key1,
295                            const AES_KEY *key2, const unsigned char *ivec);
296 void aes128_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
297                            size_t blocks, const AES_KEY *key1,
298                            const AES_KEY *key2, const unsigned char *ivec);
299 void aes256_t4_xts_encrypt(const unsigned char *in, unsigned char *out,
300                            size_t blocks, const AES_KEY *key1,
301                            const AES_KEY *key2, const unsigned char *ivec);
302 void aes256_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
303                            size_t blocks, const AES_KEY *key1,
304                            const AES_KEY *key2, const unsigned char *ivec);
305 
306 # elif defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
307 /* IBM S390X support */
308 #  include "s390x_arch.h"
309 
310 
311 /* Convert key size to function code: [16,24,32] -> [18,19,20]. */
312 #  define S390X_AES_FC(keylen)  (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
313 
314 /* Most modes of operation need km for partial block processing. */
315 #  define S390X_aes_128_CAPABLE (OPENSSL_s390xcap_P.km[0] &  \
316                                 S390X_CAPBIT(S390X_AES_128))
317 #  define S390X_aes_192_CAPABLE (OPENSSL_s390xcap_P.km[0] &  \
318                                 S390X_CAPBIT(S390X_AES_192))
319 #  define S390X_aes_256_CAPABLE (OPENSSL_s390xcap_P.km[0] &  \
320                                 S390X_CAPBIT(S390X_AES_256))
321 
322 #  define S390X_aes_128_cbc_CAPABLE     1       /* checked by callee */
323 #  define S390X_aes_192_cbc_CAPABLE     1
324 #  define S390X_aes_256_cbc_CAPABLE     1
325 
326 #  define S390X_aes_128_ecb_CAPABLE     S390X_aes_128_CAPABLE
327 #  define S390X_aes_192_ecb_CAPABLE     S390X_aes_192_CAPABLE
328 #  define S390X_aes_256_ecb_CAPABLE     S390X_aes_256_CAPABLE
329 
330 #  define S390X_aes_128_ofb_CAPABLE (S390X_aes_128_CAPABLE &&           \
331                                     (OPENSSL_s390xcap_P.kmo[0] &        \
332                                      S390X_CAPBIT(S390X_AES_128)))
333 #  define S390X_aes_192_ofb_CAPABLE (S390X_aes_192_CAPABLE &&           \
334                                     (OPENSSL_s390xcap_P.kmo[0] &        \
335                                      S390X_CAPBIT(S390X_AES_192)))
336 #  define S390X_aes_256_ofb_CAPABLE (S390X_aes_256_CAPABLE &&           \
337                                     (OPENSSL_s390xcap_P.kmo[0] &        \
338                                      S390X_CAPBIT(S390X_AES_256)))
339 
340 #  define S390X_aes_128_cfb_CAPABLE (S390X_aes_128_CAPABLE &&           \
341                                     (OPENSSL_s390xcap_P.kmf[0] &        \
342                                      S390X_CAPBIT(S390X_AES_128)))
343 #  define S390X_aes_192_cfb_CAPABLE (S390X_aes_192_CAPABLE &&           \
344                                     (OPENSSL_s390xcap_P.kmf[0] &        \
345                                      S390X_CAPBIT(S390X_AES_192)))
346 #  define S390X_aes_256_cfb_CAPABLE (S390X_aes_256_CAPABLE &&           \
347                                     (OPENSSL_s390xcap_P.kmf[0] &        \
348                                      S390X_CAPBIT(S390X_AES_256)))
349 #  define S390X_aes_128_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] &       \
350                                      S390X_CAPBIT(S390X_AES_128))
351 #  define S390X_aes_192_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] &       \
352                                      S390X_CAPBIT(S390X_AES_192))
353 #  define S390X_aes_256_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] &       \
354                                      S390X_CAPBIT(S390X_AES_256))
355 #  define S390X_aes_128_cfb1_CAPABLE    0
356 #  define S390X_aes_192_cfb1_CAPABLE    0
357 #  define S390X_aes_256_cfb1_CAPABLE    0
358 
359 #  define S390X_aes_128_ctr_CAPABLE     1       /* checked by callee */
360 #  define S390X_aes_192_ctr_CAPABLE     1
361 #  define S390X_aes_256_ctr_CAPABLE     1
362 
363 #  define S390X_aes_128_xts_CAPABLE     1       /* checked by callee */
364 #  define S390X_aes_256_xts_CAPABLE     1
365 
366 # define S390X_aes_128_gcm_CAPABLE (S390X_aes_128_CAPABLE &&        \
367                                     (OPENSSL_s390xcap_P.kma[0] &    \
368                                      S390X_CAPBIT(S390X_AES_128)))
369 # define S390X_aes_192_gcm_CAPABLE (S390X_aes_192_CAPABLE &&        \
370                                     (OPENSSL_s390xcap_P.kma[0] &    \
371                                      S390X_CAPBIT(S390X_AES_192)))
372 # define S390X_aes_256_gcm_CAPABLE (S390X_aes_256_CAPABLE &&        \
373                                     (OPENSSL_s390xcap_P.kma[0] &    \
374                                      S390X_CAPBIT(S390X_AES_256)))
375 
376 #  define S390X_aes_128_ccm_CAPABLE (S390X_aes_128_CAPABLE &&       \
377                                     (OPENSSL_s390xcap_P.kmac[0] &   \
378                                      S390X_CAPBIT(S390X_AES_128)))
379 #  define S390X_aes_192_ccm_CAPABLE (S390X_aes_192_CAPABLE &&       \
380                                     (OPENSSL_s390xcap_P.kmac[0] &   \
381                                      S390X_CAPBIT(S390X_AES_192)))
382 #  define S390X_aes_256_ccm_CAPABLE (S390X_aes_256_CAPABLE &&       \
383                                     (OPENSSL_s390xcap_P.kmac[0] &   \
384                                      S390X_CAPBIT(S390X_AES_256)))
385 #  define S390X_CCM_AAD_FLAG    0x40
386 
387 #  ifndef OPENSSL_NO_OCB
388 #   define S390X_aes_128_ocb_CAPABLE    0
389 #   define S390X_aes_192_ocb_CAPABLE    0
390 #   define S390X_aes_256_ocb_CAPABLE    0
391 #  endif /* OPENSSL_NO_OCB */
392 
393 #  ifndef OPENSSL_NO_SIV
394 #   define S390X_aes_128_siv_CAPABLE    0
395 #   define S390X_aes_192_siv_CAPABLE    0
396 #   define S390X_aes_256_siv_CAPABLE    0
397 #  endif /* OPENSSL_NO_SIV */
398 
399 /* Convert key size to function code: [16,24,32] -> [18,19,20]. */
400 #  define S390X_AES_FC(keylen)  (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
401 # endif
402 
403 # if defined(HWAES_CAPABLE)
404 int HWAES_set_encrypt_key(const unsigned char *userKey, const int bits,
405                           AES_KEY *key);
406 int HWAES_set_decrypt_key(const unsigned char *userKey, const int bits,
407                           AES_KEY *key);
408 void HWAES_encrypt(const unsigned char *in, unsigned char *out,
409                    const AES_KEY *key);
410 void HWAES_decrypt(const unsigned char *in, unsigned char *out,
411                    const AES_KEY *key);
412 void HWAES_cbc_encrypt(const unsigned char *in, unsigned char *out,
413                        size_t length, const AES_KEY *key,
414                        unsigned char *ivec, const int enc);
415 void HWAES_ecb_encrypt(const unsigned char *in, unsigned char *out,
416                        size_t length, const AES_KEY *key,
417                        const int enc);
418 void HWAES_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
419                                 size_t len, const void *key,
420                                 const unsigned char ivec[16]);
421 void HWAES_xts_encrypt(const unsigned char *inp, unsigned char *out,
422                        size_t len, const AES_KEY *key1,
423                        const AES_KEY *key2, const unsigned char iv[16]);
424 void HWAES_xts_decrypt(const unsigned char *inp, unsigned char *out,
425                        size_t len, const AES_KEY *key1,
426                        const AES_KEY *key2, const unsigned char iv[16]);
427 #  ifndef OPENSSL_NO_OCB
428 #   ifdef HWAES_ocb_encrypt
429 void HWAES_ocb_encrypt(const unsigned char *in, unsigned char *out,
430                        size_t blocks, const void *key,
431                        size_t start_block_num,
432                        unsigned char offset_i[16],
433                        const unsigned char L_[][16],
434                        unsigned char checksum[16]);
435 #   else
436 #     define HWAES_ocb_encrypt ((ocb128_f)NULL)
437 #   endif
438 #   ifdef HWAES_ocb_decrypt
439 void HWAES_ocb_decrypt(const unsigned char *in, unsigned char *out,
440                        size_t blocks, const void *key,
441                        size_t start_block_num,
442                        unsigned char offset_i[16],
443                        const unsigned char L_[][16],
444                        unsigned char checksum[16]);
445 #   else
446 #     define HWAES_ocb_decrypt ((ocb128_f)NULL)
447 #   endif
448 #  endif /* OPENSSL_NO_OCB */
449 
450 # endif /* HWAES_CAPABLE */
451 
452 #endif /* OSSL_AES_PLATFORM_H */
453