Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
sPymbed
Date:
Tue Nov 19 14:32:16 2019 +0000
Revision:
16:048e5e270a58
Parent:
15:117db924cf7c
working ssl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 15:117db924cf7c 1 /* aes.h
wolfSSL 15:117db924cf7c 2 *
wolfSSL 15:117db924cf7c 3 * Copyright (C) 2006-2017 wolfSSL Inc.
wolfSSL 15:117db924cf7c 4 *
wolfSSL 15:117db924cf7c 5 * This file is part of wolfSSL.
wolfSSL 15:117db924cf7c 6 *
wolfSSL 15:117db924cf7c 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 15:117db924cf7c 8 * it under the terms of the GNU General Public License as published by
wolfSSL 15:117db924cf7c 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 15:117db924cf7c 10 * (at your option) any later version.
wolfSSL 15:117db924cf7c 11 *
wolfSSL 15:117db924cf7c 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 15:117db924cf7c 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 15:117db924cf7c 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 15:117db924cf7c 15 * GNU General Public License for more details.
wolfSSL 15:117db924cf7c 16 *
wolfSSL 15:117db924cf7c 17 * You should have received a copy of the GNU General Public License
wolfSSL 15:117db924cf7c 18 * along with this program; if not, write to the Free Software
wolfSSL 15:117db924cf7c 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 15:117db924cf7c 20 */
wolfSSL 15:117db924cf7c 21
wolfSSL 15:117db924cf7c 22 /*!
wolfSSL 15:117db924cf7c 23 \file wolfssl/wolfcrypt/aes.h
wolfSSL 15:117db924cf7c 24 */
wolfSSL 15:117db924cf7c 25
wolfSSL 15:117db924cf7c 26
wolfSSL 15:117db924cf7c 27 #ifndef WOLF_CRYPT_AES_H
wolfSSL 15:117db924cf7c 28 #define WOLF_CRYPT_AES_H
wolfSSL 15:117db924cf7c 29
wolfSSL 15:117db924cf7c 30 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 15:117db924cf7c 31
wolfSSL 15:117db924cf7c 32 #ifndef NO_AES
wolfSSL 15:117db924cf7c 33
wolfSSL 15:117db924cf7c 34 #if defined(HAVE_FIPS) && \
wolfSSL 15:117db924cf7c 35 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
wolfSSL 15:117db924cf7c 36 #include <wolfssl/wolfcrypt/fips.h>
wolfSSL 15:117db924cf7c 37 #endif /* HAVE_FIPS_VERSION >= 2 */
wolfSSL 15:117db924cf7c 38
wolfSSL 15:117db924cf7c 39 /* included for fips @wc_fips */
wolfSSL 15:117db924cf7c 40 #if defined(HAVE_FIPS) && \
wolfSSL 15:117db924cf7c 41 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
wolfSSL 15:117db924cf7c 42 #include <cyassl/ctaocrypt/aes.h>
wolfSSL 15:117db924cf7c 43 #if defined(CYASSL_AES_COUNTER) && !defined(WOLFSSL_AES_COUNTER)
wolfSSL 15:117db924cf7c 44 #define WOLFSSL_AES_COUNTER
wolfSSL 15:117db924cf7c 45 #endif
wolfSSL 15:117db924cf7c 46 #if !defined(WOLFSSL_AES_DIRECT) && defined(CYASSL_AES_DIRECT)
wolfSSL 15:117db924cf7c 47 #define WOLFSSL_AES_DIRECT
wolfSSL 15:117db924cf7c 48 #endif
wolfSSL 15:117db924cf7c 49 #endif
wolfSSL 15:117db924cf7c 50
wolfSSL 15:117db924cf7c 51
wolfSSL 15:117db924cf7c 52 #ifdef WOLFSSL_AESNI
wolfSSL 15:117db924cf7c 53
wolfSSL 15:117db924cf7c 54 #include <wmmintrin.h>
wolfSSL 15:117db924cf7c 55 #include <emmintrin.h>
wolfSSL 15:117db924cf7c 56 #include <smmintrin.h>
wolfSSL 15:117db924cf7c 57
wolfSSL 15:117db924cf7c 58 #endif /* WOLFSSL_AESNI */
wolfSSL 15:117db924cf7c 59
wolfSSL 15:117db924cf7c 60
wolfSSL 15:117db924cf7c 61 #ifdef WOLFSSL_XILINX_CRYPT
wolfSSL 15:117db924cf7c 62 #include "xsecure_aes.h"
wolfSSL 15:117db924cf7c 63 #endif
wolfSSL 15:117db924cf7c 64
wolfSSL 15:117db924cf7c 65 #if defined(HAVE_AESGCM) && !defined(WC_NO_RNG)
wolfSSL 15:117db924cf7c 66 #include <wolfssl/wolfcrypt/random.h>
wolfSSL 15:117db924cf7c 67 #endif
wolfSSL 15:117db924cf7c 68
wolfSSL 15:117db924cf7c 69
wolfSSL 15:117db924cf7c 70 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 71 extern "C" {
wolfSSL 15:117db924cf7c 72 #endif
wolfSSL 15:117db924cf7c 73
wolfSSL 15:117db924cf7c 74 /* these are required for FIPS and non-FIPS */
wolfSSL 15:117db924cf7c 75 enum {
wolfSSL 15:117db924cf7c 76 AES_128_KEY_SIZE = 16, /* for 128 bit */
wolfSSL 15:117db924cf7c 77 AES_192_KEY_SIZE = 24, /* for 192 bit */
wolfSSL 15:117db924cf7c 78 AES_256_KEY_SIZE = 32, /* for 256 bit */
wolfSSL 15:117db924cf7c 79
wolfSSL 15:117db924cf7c 80 AES_IV_SIZE = 16, /* always block size */
wolfSSL 15:117db924cf7c 81 };
wolfSSL 15:117db924cf7c 82
wolfSSL 15:117db924cf7c 83
wolfSSL 15:117db924cf7c 84 /* avoid redefinition of structs */
wolfSSL 15:117db924cf7c 85 #if !defined(HAVE_FIPS) || \
wolfSSL 15:117db924cf7c 86 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
wolfSSL 15:117db924cf7c 87
wolfSSL 15:117db924cf7c 88 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 15:117db924cf7c 89 #include <wolfssl/wolfcrypt/async.h>
wolfSSL 15:117db924cf7c 90 #endif
wolfSSL 15:117db924cf7c 91
wolfSSL 15:117db924cf7c 92 enum {
wolfSSL 15:117db924cf7c 93 AES_ENC_TYPE = WC_CIPHER_AES, /* cipher unique type */
wolfSSL 15:117db924cf7c 94 AES_ENCRYPTION = 0,
wolfSSL 15:117db924cf7c 95 AES_DECRYPTION = 1,
wolfSSL 15:117db924cf7c 96
wolfSSL 15:117db924cf7c 97 AES_BLOCK_SIZE = 16,
wolfSSL 15:117db924cf7c 98
wolfSSL 15:117db924cf7c 99 KEYWRAP_BLOCK_SIZE = 8,
wolfSSL 15:117db924cf7c 100
wolfSSL 15:117db924cf7c 101 GCM_NONCE_MAX_SZ = 16, /* wolfCrypt's maximum nonce size allowed. */
wolfSSL 15:117db924cf7c 102 GCM_NONCE_MID_SZ = 12, /* The usual default nonce size for AES-GCM. */
wolfSSL 15:117db924cf7c 103 GCM_NONCE_MIN_SZ = 8, /* wolfCrypt's minimum nonce size allowed. */
wolfSSL 15:117db924cf7c 104 CCM_NONCE_MIN_SZ = 7,
wolfSSL 15:117db924cf7c 105 CCM_NONCE_MAX_SZ = 13,
wolfSSL 15:117db924cf7c 106 CTR_SZ = 4,
wolfSSL 15:117db924cf7c 107 AES_IV_FIXED_SZ = 4
wolfSSL 15:117db924cf7c 108 };
wolfSSL 15:117db924cf7c 109
wolfSSL 15:117db924cf7c 110
wolfSSL 15:117db924cf7c 111 typedef struct Aes {
wolfSSL 15:117db924cf7c 112 /* AESNI needs key first, rounds 2nd, not sure why yet */
wolfSSL 15:117db924cf7c 113 ALIGN16 word32 key[60];
wolfSSL 15:117db924cf7c 114 word32 rounds;
wolfSSL 15:117db924cf7c 115 int keylen;
wolfSSL 15:117db924cf7c 116
wolfSSL 15:117db924cf7c 117 ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
wolfSSL 15:117db924cf7c 118 ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
wolfSSL 15:117db924cf7c 119
wolfSSL 15:117db924cf7c 120 #if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
wolfSSL 15:117db924cf7c 121 word32 invokeCtr[2];
wolfSSL 15:117db924cf7c 122 word32 nonceSz;
wolfSSL 15:117db924cf7c 123 #endif
wolfSSL 15:117db924cf7c 124 #ifdef HAVE_AESGCM
wolfSSL 15:117db924cf7c 125 ALIGN16 byte H[AES_BLOCK_SIZE];
wolfSSL 15:117db924cf7c 126 #ifdef GCM_TABLE
wolfSSL 15:117db924cf7c 127 /* key-based fast multiplication table. */
wolfSSL 15:117db924cf7c 128 ALIGN16 byte M0[256][AES_BLOCK_SIZE];
wolfSSL 15:117db924cf7c 129 #endif /* GCM_TABLE */
wolfSSL 15:117db924cf7c 130 #endif /* HAVE_AESGCM */
wolfSSL 15:117db924cf7c 131 #ifdef WOLFSSL_AESNI
wolfSSL 15:117db924cf7c 132 byte use_aesni;
wolfSSL 15:117db924cf7c 133 #endif /* WOLFSSL_AESNI */
wolfSSL 15:117db924cf7c 134 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 15:117db924cf7c 135 word32 asyncKey[AES_MAX_KEY_SIZE/8/sizeof(word32)]; /* raw key */
wolfSSL 15:117db924cf7c 136 word32 asyncIv[AES_BLOCK_SIZE/sizeof(word32)]; /* raw IV */
wolfSSL 15:117db924cf7c 137 WC_ASYNC_DEV asyncDev;
wolfSSL 15:117db924cf7c 138 #endif /* WOLFSSL_ASYNC_CRYPT */
wolfSSL 15:117db924cf7c 139 #if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB)
wolfSSL 15:117db924cf7c 140 word32 left; /* unused bytes left from last call */
wolfSSL 15:117db924cf7c 141 #endif
wolfSSL 15:117db924cf7c 142 #ifdef WOLFSSL_XILINX_CRYPT
wolfSSL 15:117db924cf7c 143 XSecure_Aes xilAes;
wolfSSL 15:117db924cf7c 144 XCsuDma dma;
wolfSSL 15:117db924cf7c 145 word32 key_init[8];
wolfSSL 15:117db924cf7c 146 word32 kup;
wolfSSL 15:117db924cf7c 147 #endif
wolfSSL 15:117db924cf7c 148 void* heap; /* memory hint to use */
wolfSSL 15:117db924cf7c 149 } Aes;
wolfSSL 15:117db924cf7c 150
wolfSSL 15:117db924cf7c 151 #ifdef WOLFSSL_AES_XTS
wolfSSL 15:117db924cf7c 152 typedef struct XtsAes {
wolfSSL 15:117db924cf7c 153 Aes aes;
wolfSSL 15:117db924cf7c 154 Aes tweak;
wolfSSL 15:117db924cf7c 155 } XtsAes;
wolfSSL 15:117db924cf7c 156 #endif
wolfSSL 15:117db924cf7c 157
wolfSSL 15:117db924cf7c 158 #ifdef HAVE_AESGCM
wolfSSL 15:117db924cf7c 159 typedef struct Gmac {
wolfSSL 15:117db924cf7c 160 Aes aes;
wolfSSL 15:117db924cf7c 161 } Gmac;
wolfSSL 15:117db924cf7c 162 #endif /* HAVE_AESGCM */
wolfSSL 15:117db924cf7c 163 #endif /* HAVE_FIPS */
wolfSSL 15:117db924cf7c 164
wolfSSL 15:117db924cf7c 165
wolfSSL 15:117db924cf7c 166 /* Authenticate cipher function prototypes */
wolfSSL 15:117db924cf7c 167 typedef int (*wc_AesAuthEncryptFunc)(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 168 const byte* in, word32 sz,
wolfSSL 15:117db924cf7c 169 const byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 170 byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 171 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 172 typedef int (*wc_AesAuthDecryptFunc)(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 173 const byte* in, word32 sz,
wolfSSL 15:117db924cf7c 174 const byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 175 const byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 176 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 177
wolfSSL 15:117db924cf7c 178 /* AES-CBC */
wolfSSL 15:117db924cf7c 179 WOLFSSL_API int wc_AesSetKey(Aes* aes, const byte* key, word32 len,
wolfSSL 15:117db924cf7c 180 const byte* iv, int dir);
wolfSSL 15:117db924cf7c 181 WOLFSSL_API int wc_AesSetIV(Aes* aes, const byte* iv);
wolfSSL 15:117db924cf7c 182 WOLFSSL_API int wc_AesCbcEncrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 183 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 184 WOLFSSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 185 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 186
wolfSSL 15:117db924cf7c 187 #ifdef WOLFSSL_AES_CFB
wolfSSL 15:117db924cf7c 188 WOLFSSL_API int wc_AesCfbEncrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 189 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 190 #ifdef HAVE_AES_DECRYPT
wolfSSL 15:117db924cf7c 191 WOLFSSL_API int wc_AesCfbDecrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 192 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 193 #endif /* HAVE_AES_DECRYPT */
wolfSSL 15:117db924cf7c 194 #endif /* WOLFSSL_AES_CFB */
wolfSSL 15:117db924cf7c 195
wolfSSL 15:117db924cf7c 196 #ifdef HAVE_AES_ECB
wolfSSL 15:117db924cf7c 197 WOLFSSL_API int wc_AesEcbEncrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 198 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 199 WOLFSSL_API int wc_AesEcbDecrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 200 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 201 #endif
wolfSSL 15:117db924cf7c 202
wolfSSL 15:117db924cf7c 203 /* AES-CTR */
wolfSSL 15:117db924cf7c 204 #ifdef WOLFSSL_AES_COUNTER
wolfSSL 15:117db924cf7c 205 WOLFSSL_API int wc_AesCtrEncrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 206 const byte* in, word32 sz);
wolfSSL 15:117db924cf7c 207 #endif
wolfSSL 15:117db924cf7c 208 /* AES-DIRECT */
wolfSSL 15:117db924cf7c 209 #if defined(WOLFSSL_AES_DIRECT)
wolfSSL 15:117db924cf7c 210 WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
wolfSSL 15:117db924cf7c 211 WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
wolfSSL 15:117db924cf7c 212 WOLFSSL_API int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
wolfSSL 15:117db924cf7c 213 const byte* iv, int dir);
wolfSSL 15:117db924cf7c 214 #endif
wolfSSL 15:117db924cf7c 215
wolfSSL 15:117db924cf7c 216 #ifdef HAVE_AESGCM
wolfSSL 15:117db924cf7c 217 #ifdef WOLFSSL_XILINX_CRYPT
wolfSSL 15:117db924cf7c 218 WOLFSSL_API int wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len,
wolfSSL 15:117db924cf7c 219 word32 kup);
wolfSSL 15:117db924cf7c 220 #endif
wolfSSL 15:117db924cf7c 221 WOLFSSL_API int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
wolfSSL 15:117db924cf7c 222 WOLFSSL_API int wc_AesGcmEncrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 223 const byte* in, word32 sz,
wolfSSL 15:117db924cf7c 224 const byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 225 byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 226 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 227 WOLFSSL_API int wc_AesGcmDecrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 228 const byte* in, word32 sz,
wolfSSL 15:117db924cf7c 229 const byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 230 const byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 231 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 232
wolfSSL 15:117db924cf7c 233 #ifndef WC_NO_RNG
wolfSSL 15:117db924cf7c 234 WOLFSSL_API int wc_AesGcmSetExtIV(Aes* aes, const byte* iv, word32 ivSz);
wolfSSL 15:117db924cf7c 235 WOLFSSL_API int wc_AesGcmSetIV(Aes* aes, word32 ivSz,
wolfSSL 15:117db924cf7c 236 const byte* ivFixed, word32 ivFixedSz,
wolfSSL 15:117db924cf7c 237 WC_RNG* rng);
wolfSSL 15:117db924cf7c 238 WOLFSSL_API int wc_AesGcmEncrypt_ex(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 239 const byte* in, word32 sz,
wolfSSL 15:117db924cf7c 240 byte* ivOut, word32 ivOutSz,
wolfSSL 15:117db924cf7c 241 byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 242 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 243 #endif /* WC_NO_RNG */
wolfSSL 15:117db924cf7c 244
wolfSSL 15:117db924cf7c 245 WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
wolfSSL 15:117db924cf7c 246 WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 247 const byte* authIn, word32 authInSz,
wolfSSL 15:117db924cf7c 248 byte* authTag, word32 authTagSz);
wolfSSL 15:117db924cf7c 249 #ifndef WC_NO_RNG
wolfSSL 15:117db924cf7c 250 WOLFSSL_API int wc_Gmac(const byte* key, word32 keySz, byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 251 const byte* authIn, word32 authInSz,
wolfSSL 15:117db924cf7c 252 byte* authTag, word32 authTagSz, WC_RNG* rng);
wolfSSL 15:117db924cf7c 253 WOLFSSL_API int wc_GmacVerify(const byte* key, word32 keySz,
wolfSSL 15:117db924cf7c 254 const byte* iv, word32 ivSz,
wolfSSL 15:117db924cf7c 255 const byte* authIn, word32 authInSz,
wolfSSL 15:117db924cf7c 256 const byte* authTag, word32 authTagSz);
wolfSSL 15:117db924cf7c 257 #endif /* WC_NO_RNG */
wolfSSL 15:117db924cf7c 258 WOLFSSL_LOCAL void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
wolfSSL 15:117db924cf7c 259 word32 cSz, byte* s, word32 sSz);
wolfSSL 15:117db924cf7c 260 #endif /* HAVE_AESGCM */
wolfSSL 15:117db924cf7c 261 #ifdef HAVE_AESCCM
wolfSSL 15:117db924cf7c 262 WOLFSSL_API int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
wolfSSL 15:117db924cf7c 263 WOLFSSL_API int wc_AesCcmEncrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 264 const byte* in, word32 inSz,
wolfSSL 15:117db924cf7c 265 const byte* nonce, word32 nonceSz,
wolfSSL 15:117db924cf7c 266 byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 267 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 268 WOLFSSL_API int wc_AesCcmDecrypt(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 269 const byte* in, word32 inSz,
wolfSSL 15:117db924cf7c 270 const byte* nonce, word32 nonceSz,
wolfSSL 15:117db924cf7c 271 const byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 272 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 273 WOLFSSL_API int wc_AesCcmSetNonce(Aes* aes,
wolfSSL 15:117db924cf7c 274 const byte* nonce, word32 nonceSz);
wolfSSL 15:117db924cf7c 275 WOLFSSL_API int wc_AesCcmEncrypt_ex(Aes* aes, byte* out,
wolfSSL 15:117db924cf7c 276 const byte* in, word32 sz,
wolfSSL 15:117db924cf7c 277 byte* ivOut, word32 ivOutSz,
wolfSSL 15:117db924cf7c 278 byte* authTag, word32 authTagSz,
wolfSSL 15:117db924cf7c 279 const byte* authIn, word32 authInSz);
wolfSSL 15:117db924cf7c 280 #endif /* HAVE_AESCCM */
wolfSSL 15:117db924cf7c 281 #ifdef HAVE_AES_KEYWRAP
wolfSSL 15:117db924cf7c 282 WOLFSSL_API int wc_AesKeyWrap(const byte* key, word32 keySz,
wolfSSL 15:117db924cf7c 283 const byte* in, word32 inSz,
wolfSSL 15:117db924cf7c 284 byte* out, word32 outSz,
wolfSSL 15:117db924cf7c 285 const byte* iv);
wolfSSL 15:117db924cf7c 286 WOLFSSL_API int wc_AesKeyUnWrap(const byte* key, word32 keySz,
wolfSSL 15:117db924cf7c 287 const byte* in, word32 inSz,
wolfSSL 15:117db924cf7c 288 byte* out, word32 outSz,
wolfSSL 15:117db924cf7c 289 const byte* iv);
wolfSSL 15:117db924cf7c 290 #endif /* HAVE_AES_KEYWRAP */
wolfSSL 15:117db924cf7c 291
wolfSSL 15:117db924cf7c 292 #ifdef WOLFSSL_AES_XTS
wolfSSL 15:117db924cf7c 293
wolfSSL 15:117db924cf7c 294 WOLFSSL_API int wc_AesXtsSetKey(XtsAes* aes, const byte* key,
wolfSSL 15:117db924cf7c 295 word32 len, int dir, void* heap, int devId);
wolfSSL 15:117db924cf7c 296
wolfSSL 15:117db924cf7c 297 WOLFSSL_API int wc_AesXtsEncryptSector(XtsAes* aes, byte* out,
wolfSSL 15:117db924cf7c 298 const byte* in, word32 sz, word64 sector);
wolfSSL 15:117db924cf7c 299
wolfSSL 15:117db924cf7c 300 WOLFSSL_API int wc_AesXtsDecryptSector(XtsAes* aes, byte* out,
wolfSSL 15:117db924cf7c 301 const byte* in, word32 sz, word64 sector);
wolfSSL 15:117db924cf7c 302
wolfSSL 15:117db924cf7c 303 WOLFSSL_API int wc_AesXtsEncrypt(XtsAes* aes, byte* out,
wolfSSL 15:117db924cf7c 304 const byte* in, word32 sz, const byte* i, word32 iSz);
wolfSSL 15:117db924cf7c 305
wolfSSL 15:117db924cf7c 306 WOLFSSL_API int wc_AesXtsDecrypt(XtsAes* aes, byte* out,
wolfSSL 15:117db924cf7c 307 const byte* in, word32 sz, const byte* i, word32 iSz);
wolfSSL 15:117db924cf7c 308
wolfSSL 15:117db924cf7c 309 WOLFSSL_API int wc_AesXtsFree(XtsAes* aes);
wolfSSL 15:117db924cf7c 310 #endif
wolfSSL 15:117db924cf7c 311
wolfSSL 15:117db924cf7c 312 WOLFSSL_API int wc_AesGetKeySize(Aes* aes, word32* keySize);
wolfSSL 15:117db924cf7c 313
wolfSSL 15:117db924cf7c 314 WOLFSSL_API int wc_AesInit(Aes*, void*, int);
wolfSSL 15:117db924cf7c 315 WOLFSSL_API void wc_AesFree(Aes*);
wolfSSL 15:117db924cf7c 316
wolfSSL 15:117db924cf7c 317 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 318 } /* extern "C" */
wolfSSL 15:117db924cf7c 319 #endif
wolfSSL 15:117db924cf7c 320
wolfSSL 15:117db924cf7c 321
wolfSSL 15:117db924cf7c 322 #endif /* NO_AES */
wolfSSL 15:117db924cf7c 323 #endif /* WOLF_CRYPT_AES_H */
wolfSSL 15:117db924cf7c 324