1 /* aes.h
2  *
3  * Copyright (C) 2006-2021 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 /*!
23     \file wolfssl/wolfcrypt/aes.h
24 */
25 /*
26 
27 DESCRIPTION
28 This library provides the interfaces to the Advanced Encryption Standard (AES)
29 for encrypting and decrypting data. AES is the standard known for a symmetric
30 block cipher mechanism that uses n-bit binary string parameter key with 128-bits,
31 192-bits, and 256-bits of key sizes.
32 
33 */
34 #ifndef WOLF_CRYPT_AES_H
35 #define WOLF_CRYPT_AES_H
36 
37 #include <wolfssl/wolfcrypt/types.h>
38 
39 #ifndef NO_AES
40 
41 #if defined(HAVE_FIPS) && \
42     defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
43     #include <wolfssl/wolfcrypt/fips.h>
44 #endif /* HAVE_FIPS_VERSION >= 2 */
45 
46 /* included for fips @wc_fips */
47 #if defined(HAVE_FIPS) && \
48     (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
49 #include <cyassl/ctaocrypt/aes.h>
50 #if defined(CYASSL_AES_COUNTER) && !defined(WOLFSSL_AES_COUNTER)
51     #define WOLFSSL_AES_COUNTER
52 #endif
53 #if !defined(WOLFSSL_AES_DIRECT) && defined(CYASSL_AES_DIRECT)
54     #define WOLFSSL_AES_DIRECT
55 #endif
56 #endif
57 
58 #ifndef WC_NO_RNG
59     #include <wolfssl/wolfcrypt/random.h>
60 #endif
61 #ifdef STM32_CRYPTO
62     #include <wolfssl/wolfcrypt/port/st/stm32.h>
63 #endif
64 
65 #ifdef WOLFSSL_IMXRT_DCP
66     #include "fsl_dcp.h"
67 #endif
68 
69 #ifdef WOLFSSL_XILINX_CRYPT
70 #include "xsecure_aes.h"
71 #endif
72 
73 #ifdef WOLFSSL_SE050
74     #include <wolfssl/wolfcrypt/port/nxp/se050_port.h>
75 #endif
76 
77 #if defined(WOLFSSL_AFALG) || defined(WOLFSSL_AFALG_XILINX_AES)
78 /* included for struct msghdr */
79 #include <wolfssl/wolfcrypt/port/af_alg/wc_afalg.h>
80 #endif
81 
82 #if defined(WOLFSSL_KCAPI_AES)
83 #include <wolfssl/wolfcrypt/port/kcapi/wc_kcapi.h>
84 #endif
85 
86 #if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)
87 #include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h>
88 #endif
89 
90 #ifdef WOLFSSL_SILABS_SE_ACCEL
91     #include <wolfssl/wolfcrypt/port/silabs/silabs_aes.h>
92 #endif
93 
94 
95 #if defined(HAVE_AESGCM) && !defined(WC_NO_RNG)
96     #include <wolfssl/wolfcrypt/random.h>
97 #endif
98 
99 #if defined(WOLFSSL_CRYPTOCELL)
100     #include <wolfssl/wolfcrypt/port/arm/cryptoCell.h>
101 #endif
102 
103 #if defined(WOLFSSL_RENESAS_TSIP_TLS) && \
104     defined(WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT)
105     #include <wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h>
106 #endif
107 
108 #ifdef __cplusplus
109     extern "C" {
110 #endif
111 
112 #ifndef WOLFSSL_AES_KEY_SIZE_ENUM
113 #define WOLFSSL_AES_KEY_SIZE_ENUM
114 /* these are required for FIPS and non-FIPS */
115 enum {
116     AES_128_KEY_SIZE    = 16,  /* for 128 bit             */
117     AES_192_KEY_SIZE    = 24,  /* for 192 bit             */
118     AES_256_KEY_SIZE    = 32,  /* for 256 bit             */
119 
120     AES_IV_SIZE         = 16,  /* always block size       */
121 };
122 #endif
123 
124 /* avoid redefinition of structs */
125 #if !defined(HAVE_FIPS) || \
126     (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
127 
128 #ifdef WOLFSSL_ASYNC_CRYPT
129     #include <wolfssl/wolfcrypt/async.h>
130 #endif
131 
132 enum {
133     AES_ENC_TYPE   = WC_CIPHER_AES,   /* cipher unique type */
134     AES_ENCRYPTION = 0,
135     AES_DECRYPTION = 1,
136 
137     AES_BLOCK_SIZE      = 16,
138 
139     KEYWRAP_BLOCK_SIZE  = 8,
140 
141     GCM_NONCE_MAX_SZ = 16, /* wolfCrypt's maximum nonce size allowed. */
142     GCM_NONCE_MID_SZ = 12, /* The default nonce size for AES-GCM. */
143     GCM_NONCE_MIN_SZ = 8,  /* wolfCrypt's minimum nonce size allowed. */
144     CCM_NONCE_MIN_SZ = 7,
145     CCM_NONCE_MAX_SZ = 13,
146     CTR_SZ   = 4,
147     AES_IV_FIXED_SZ = 4,
148 #ifdef WOLFSSL_AES_CFB
149     AES_CFB_MODE = 1,
150 #endif
151 #ifdef WOLFSSL_AES_OFB
152     AES_OFB_MODE = 2,
153 #endif
154 #ifdef WOLFSSL_AES_XTS
155     AES_XTS_MODE = 3,
156 #endif
157 
158 #ifdef HAVE_PKCS11
159     AES_MAX_ID_LEN      = 32,
160     AES_MAX_LABEL_LEN   = 32,
161 #endif
162 };
163 
164 
165 struct Aes {
166     /* AESNI needs key first, rounds 2nd, not sure why yet */
167     ALIGN16 word32 key[60];
168     word32  rounds;
169     int     keylen;
170 
171     ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)];      /* for CBC mode */
172     ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)];      /* same         */
173 
174 #if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
175     word32 invokeCtr[2];
176     word32 nonceSz;
177 #endif
178 #ifdef HAVE_AESGCM
179     ALIGN16 byte H[AES_BLOCK_SIZE];
180 #ifdef OPENSSL_EXTRA
181     word32 aadH[4]; /* additional authenticated data GHASH */
182     word32 aadLen;  /* additional authenticated data len */
183 #endif
184 
185 #ifdef WOLFSSL_SE050
186     sss_symmetric_t aes_ctx; /* used as the function context */
187     int ctxInitDone;
188     int keyId;
189 #endif
190 
191 #ifdef GCM_TABLE
192     /* key-based fast multiplication table. */
193     ALIGN16 byte M0[256][AES_BLOCK_SIZE];
194 #elif defined(GCM_TABLE_4BIT)
195     #if defined(BIG_ENDIAN_ORDER) || defined(WC_16BIT_CPU)
196         ALIGN16 byte M0[16][AES_BLOCK_SIZE];
197     #else
198         ALIGN16 byte M0[32][AES_BLOCK_SIZE];
199     #endif
200 #endif /* GCM_TABLE */
201 #ifdef HAVE_CAVIUM_OCTEON_SYNC
202     word32 y0;
203 #endif
204 #endif /* HAVE_AESGCM */
205 #ifdef WOLFSSL_AESNI
206     byte use_aesni;
207 #endif /* WOLFSSL_AESNI */
208 #ifdef WOLF_CRYPTO_CB
209     int    devId;
210     void*  devCtx;
211 #endif
212 #ifdef HAVE_PKCS11
213     byte id[AES_MAX_ID_LEN];
214     int  idLen;
215     char label[AES_MAX_LABEL_LEN];
216     int  labelLen;
217 #endif
218 #ifdef WOLFSSL_ASYNC_CRYPT
219     WC_ASYNC_DEV asyncDev;
220 #endif /* WOLFSSL_ASYNC_CRYPT */
221 #if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
222     defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS)
223     word32  left;            /* unused bytes left from last call */
224 #endif
225 #ifdef WOLFSSL_XILINX_CRYPT
226     XSecure_Aes xilAes;
227     XCsuDma     dma;
228     word32      key_init[8];
229     word32      kup;
230 #endif
231 #if defined(WOLFSSL_AFALG) || defined(WOLFSSL_AFALG_XILINX_AES)
232     int alFd; /* server socket to bind to */
233     int rdFd; /* socket to read from */
234     struct msghdr msg;
235     int dir;  /* flag for encrpyt or decrypt */
236 #ifdef WOLFSSL_AFALG_XILINX_AES
237     word32 msgBuf[CMSG_SPACE(4) + CMSG_SPACE(sizeof(struct af_alg_iv) +
238                   GCM_NONCE_MID_SZ)];
239 #endif
240 #endif
241 #if defined(WOLFSSL_KCAPI_AES)
242     struct kcapi_handle* handle;
243     int                  init;
244 #endif
245 #if defined(WOLF_CRYPTO_CB) || (defined(WOLFSSL_DEVCRYPTO) && \
246     (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))) || \
247     (defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)) || \
248     defined(WOLFSSL_KCAPI_AES)
249     word32 devKey[AES_MAX_KEY_SIZE/WOLFSSL_BIT_SIZE/sizeof(word32)]; /* raw key */
250 #ifdef HAVE_CAVIUM_OCTEON_SYNC
251     int    keySet;
252 #endif
253 #endif
254 #if defined(WOLFSSL_DEVCRYPTO) && \
255     (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))
256     WC_CRYPTODEV ctx;
257 #endif
258 #if defined(WOLFSSL_CRYPTOCELL)
259     aes_context_t ctx;
260 #endif
261 #if defined(WOLFSSL_RENESAS_TSIP_TLS) && \
262     defined(WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT)
263     TSIP_AES_CTX ctx;
264 #endif
265 #if defined(WOLFSSL_RENESAS_SCEPROTECT)
266     SCE_AES_CTX ctx;
267 #endif
268 #if defined(WOLFSSL_IMXRT_DCP)
269     dcp_handle_t handle;
270 #endif
271 #if defined(WOLFSSL_SILABS_SE_ACCEL)
272     silabs_aes_t ctx;
273 #endif
274     void*  heap; /* memory hint to use */
275 #ifdef WOLFSSL_AESGCM_STREAM
276 #if !defined(WOLFSSL_SMALL_STACK) || defined(WOLFSSL_AESNI)
277     ALIGN16 byte streamData[5 * AES_BLOCK_SIZE];
278 #else
279     byte*        streamData;
280 #endif
281     word32       aSz;
282     word32       cSz;
283     byte         over;
284     byte         aOver;
285     byte         cOver;
286     byte         gcmKeySet:1;
287     byte         nonceSet:1;
288     byte         ctrSet:1;
289 #endif
290 };
291 
292 #ifndef WC_AES_TYPE_DEFINED
293     typedef struct Aes Aes;
294     #define WC_AES_TYPE_DEFINED
295 #endif
296 
297 #ifdef WOLFSSL_AES_XTS
298 typedef struct XtsAes {
299     Aes aes;
300     Aes tweak;
301 } XtsAes;
302 #endif
303 
304 #ifdef HAVE_AESGCM
305 typedef struct Gmac {
306     Aes aes;
307 } Gmac;
308 #endif /* HAVE_AESGCM */
309 #endif /* HAVE_FIPS */
310 
311 
312 /* Authenticate cipher function prototypes */
313 typedef int (*wc_AesAuthEncryptFunc)(Aes* aes, byte* out,
314                                    const byte* in, word32 sz,
315                                    const byte* iv, word32 ivSz,
316                                    byte* authTag, word32 authTagSz,
317                                    const byte* authIn, word32 authInSz);
318 typedef int (*wc_AesAuthDecryptFunc)(Aes* aes, byte* out,
319                                    const byte* in, word32 sz,
320                                    const byte* iv, word32 ivSz,
321                                    const byte* authTag, word32 authTagSz,
322                                    const byte* authIn, word32 authInSz);
323 
324 /* AES-CBC */
325 WOLFSSL_API int  wc_AesSetKey(Aes* aes, const byte* key, word32 len,
326                               const byte* iv, int dir);
327 WOLFSSL_API int  wc_AesSetIV(Aes* aes, const byte* iv);
328 
329 #ifdef HAVE_AES_CBC
330 WOLFSSL_API int  wc_AesCbcEncrypt(Aes* aes, byte* out,
331                                   const byte* in, word32 sz);
332 WOLFSSL_API int  wc_AesCbcDecrypt(Aes* aes, byte* out,
333                                   const byte* in, word32 sz);
334 #endif
335 
336 #ifdef WOLFSSL_AES_CFB
337 WOLFSSL_API int wc_AesCfbEncrypt(Aes* aes, byte* out,
338                                     const byte* in, word32 sz);
339 WOLFSSL_API int wc_AesCfb1Encrypt(Aes* aes, byte* out,
340                                     const byte* in, word32 sz);
341 WOLFSSL_API int wc_AesCfb8Encrypt(Aes* aes, byte* out,
342                                     const byte* in, word32 sz);
343 #ifdef HAVE_AES_DECRYPT
344 WOLFSSL_API int wc_AesCfbDecrypt(Aes* aes, byte* out,
345                                     const byte* in, word32 sz);
346 WOLFSSL_API int wc_AesCfb1Decrypt(Aes* aes, byte* out,
347                                     const byte* in, word32 sz);
348 WOLFSSL_API int wc_AesCfb8Decrypt(Aes* aes, byte* out,
349                                     const byte* in, word32 sz);
350 #endif /* HAVE_AES_DECRYPT */
351 #endif /* WOLFSSL_AES_CFB */
352 
353 #ifdef WOLFSSL_AES_OFB
354 WOLFSSL_API int wc_AesOfbEncrypt(Aes* aes, byte* out,
355                                     const byte* in, word32 sz);
356 #ifdef HAVE_AES_DECRYPT
357 WOLFSSL_API int wc_AesOfbDecrypt(Aes* aes, byte* out,
358                                     const byte* in, word32 sz);
359 #endif /* HAVE_AES_DECRYPT */
360 #endif /* WOLFSSL_AES_OFB */
361 
362 #ifdef HAVE_AES_ECB
363 WOLFSSL_API int wc_AesEcbEncrypt(Aes* aes, byte* out,
364                                   const byte* in, word32 sz);
365 WOLFSSL_API int wc_AesEcbDecrypt(Aes* aes, byte* out,
366                                   const byte* in, word32 sz);
367 #endif
368 
369 /* AES-CTR */
370 #ifdef WOLFSSL_AES_COUNTER
371  WOLFSSL_API int wc_AesCtrEncrypt(Aes* aes, byte* out,
372                                    const byte* in, word32 sz);
373 #endif
374 /* AES-DIRECT */
375 #if defined(WOLFSSL_AES_DIRECT)
376 #ifdef WOLFSSL_LINUXKM
377  WOLFSSL_API __must_check int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
378  WOLFSSL_API __must_check int wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
379 #else
380  WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
381  WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
382 #endif
383  WOLFSSL_API int  wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
384                                 const byte* iv, int dir);
385 #endif
386 
387 #ifdef HAVE_AESGCM
388 #ifdef WOLFSSL_XILINX_CRYPT
389  WOLFSSL_API int  wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len,
390          word32 kup);
391 #elif defined(WOLFSSL_AFALG_XILINX_AES)
392  WOLFSSL_LOCAL int  wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len,
393          word32 kup);
394 #endif
395  WOLFSSL_API int  wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
396  WOLFSSL_API int  wc_AesGcmEncrypt(Aes* aes, byte* out,
397                                    const byte* in, word32 sz,
398                                    const byte* iv, word32 ivSz,
399                                    byte* authTag, word32 authTagSz,
400                                    const byte* authIn, word32 authInSz);
401  WOLFSSL_API int  wc_AesGcmDecrypt(Aes* aes, byte* out,
402                                    const byte* in, word32 sz,
403                                    const byte* iv, word32 ivSz,
404                                    const byte* authTag, word32 authTagSz,
405                                    const byte* authIn, word32 authInSz);
406 #ifdef WOLFSSL_AESGCM_STREAM
407 WOLFSSL_API int wc_AesGcmInit(Aes* aes, const byte* key, word32 len,
408         const byte* iv, word32 ivSz);
409 
410 WOLFSSL_API int wc_AesGcmEncryptInit(Aes* aes, const byte* key, word32 len,
411         const byte* iv, word32 ivSz);
412 WOLFSSL_API int wc_AesGcmEncryptInit_ex(Aes* aes, const byte* key, word32 len,
413         byte* ivOut, word32 ivOutSz);
414 WOLFSSL_API int wc_AesGcmEncryptUpdate(Aes* aes, byte* out, const byte* in,
415         word32 sz, const byte* authIn, word32 authInSz);
416 WOLFSSL_API int wc_AesGcmEncryptFinal(Aes* aes, byte* authTag,
417         word32 authTagSz);
418 
419 WOLFSSL_API int wc_AesGcmDecryptInit(Aes* aes, const byte* key, word32 len,
420         const byte* iv, word32 ivSz);
421 WOLFSSL_API int wc_AesGcmDecryptUpdate(Aes* aes, byte* out, const byte* in,
422         word32 sz, const byte* authIn, word32 authInSz);
423 WOLFSSL_API int wc_AesGcmDecryptFinal(Aes* aes, const byte* authTag,
424         word32 authTagSz);
425 #endif
426 
427 #ifndef WC_NO_RNG
428  WOLFSSL_API int  wc_AesGcmSetExtIV(Aes* aes, const byte* iv, word32 ivSz);
429  WOLFSSL_API int  wc_AesGcmSetIV(Aes* aes, word32 ivSz,
430                                    const byte* ivFixed, word32 ivFixedSz,
431                                    WC_RNG* rng);
432  WOLFSSL_API int  wc_AesGcmEncrypt_ex(Aes* aes, byte* out,
433                                    const byte* in, word32 sz,
434                                    byte* ivOut, word32 ivOutSz,
435                                    byte* authTag, word32 authTagSz,
436                                    const byte* authIn, word32 authInSz);
437 #endif /* WC_NO_RNG */
438 
439  WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
440  WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
441                                const byte* authIn, word32 authInSz,
442                                byte* authTag, word32 authTagSz);
443 #ifndef WC_NO_RNG
444  WOLFSSL_API int wc_Gmac(const byte* key, word32 keySz, byte* iv, word32 ivSz,
445                                const byte* authIn, word32 authInSz,
446                                byte* authTag, word32 authTagSz, WC_RNG* rng);
447  WOLFSSL_API int wc_GmacVerify(const byte* key, word32 keySz,
448                                const byte* iv, word32 ivSz,
449                                const byte* authIn, word32 authInSz,
450                                const byte* authTag, word32 authTagSz);
451 #endif /* WC_NO_RNG */
452  WOLFSSL_LOCAL void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
453                                word32 cSz, byte* s, word32 sSz);
454 #endif /* HAVE_AESGCM */
455 #ifdef HAVE_AESCCM
456  WOLFSSL_LOCAL int wc_AesCcmCheckTagSize(int sz);
457  WOLFSSL_API int  wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
458  WOLFSSL_API int  wc_AesCcmEncrypt(Aes* aes, byte* out,
459                                    const byte* in, word32 inSz,
460                                    const byte* nonce, word32 nonceSz,
461                                    byte* authTag, word32 authTagSz,
462                                    const byte* authIn, word32 authInSz);
463  WOLFSSL_API int  wc_AesCcmDecrypt(Aes* aes, byte* out,
464                                    const byte* in, word32 inSz,
465                                    const byte* nonce, word32 nonceSz,
466                                    const byte* authTag, word32 authTagSz,
467                                    const byte* authIn, word32 authInSz);
468  WOLFSSL_API int  wc_AesCcmSetNonce(Aes* aes,
469                                    const byte* nonce, word32 nonceSz);
470  WOLFSSL_API int  wc_AesCcmEncrypt_ex(Aes* aes, byte* out,
471                                    const byte* in, word32 sz,
472                                    byte* ivOut, word32 ivOutSz,
473                                    byte* authTag, word32 authTagSz,
474                                    const byte* authIn, word32 authInSz);
475 #endif /* HAVE_AESCCM */
476 #ifdef HAVE_AES_KEYWRAP
477  WOLFSSL_API int  wc_AesKeyWrap(const byte* key, word32 keySz,
478                                 const byte* in, word32 inSz,
479                                 byte* out, word32 outSz,
480                                 const byte* iv);
481  WOLFSSL_API int  wc_AesKeyWrap_ex(Aes *aes,
482                                 const byte* in, word32 inSz,
483                                 byte* out, word32 outSz,
484                                 const byte* iv);
485  WOLFSSL_API int  wc_AesKeyUnWrap(const byte* key, word32 keySz,
486                                 const byte* in, word32 inSz,
487                                 byte* out, word32 outSz,
488                                 const byte* iv);
489  WOLFSSL_API int  wc_AesKeyUnWrap_ex(Aes *aes,
490                                 const byte* in, word32 inSz,
491                                 byte* out, word32 outSz,
492                                 const byte* iv);
493 #endif /* HAVE_AES_KEYWRAP */
494 
495 #ifdef WOLFSSL_AES_XTS
496 
497 WOLFSSL_API int wc_AesXtsSetKey(XtsAes* aes, const byte* key,
498          word32 len, int dir, void* heap, int devId);
499 
500 WOLFSSL_API int wc_AesXtsEncryptSector(XtsAes* aes, byte* out,
501          const byte* in, word32 sz, word64 sector);
502 
503 WOLFSSL_API int wc_AesXtsDecryptSector(XtsAes* aes, byte* out,
504          const byte* in, word32 sz, word64 sector);
505 
506 WOLFSSL_API int wc_AesXtsEncrypt(XtsAes* aes, byte* out,
507          const byte* in, word32 sz, const byte* i, word32 iSz);
508 
509 WOLFSSL_API int wc_AesXtsDecrypt(XtsAes* aes, byte* out,
510         const byte* in, word32 sz, const byte* i, word32 iSz);
511 
512 WOLFSSL_API int wc_AesXtsFree(XtsAes* aes);
513 #endif
514 
515 WOLFSSL_API int wc_AesGetKeySize(Aes* aes, word32* keySize);
516 
517 WOLFSSL_API int  wc_AesInit(Aes* aes, void* heap, int devId);
518 #ifdef HAVE_PKCS11
519 WOLFSSL_API int  wc_AesInit_Id(Aes* aes, unsigned char* id, int len, void* heap,
520         int devId);
521 WOLFSSL_API int  wc_AesInit_Label(Aes* aes, const char* label, void* heap,
522         int devId);
523 #endif
524 WOLFSSL_API void wc_AesFree(Aes* aes);
525 
526 #ifdef __cplusplus
527     } /* extern "C" */
528 #endif
529 
530 
531 #endif /* NO_AES */
532 #endif /* WOLF_CRYPT_AES_H */
533