3 * Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
5 * This file is part of CyaSSL.
7 * CyaSSL 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.
12 * CyaSSL 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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25 #ifndef CTAO_CRYPT_AES_H
26 #define CTAO_CRYPT_AES_H
29 #include <cyassl/ctaocrypt/types.h>
33 #include <wmmintrin.h>
35 #if !defined (ALIGN16)
36 #if defined (__GNUC__)
37 #define ALIGN16 __attribute__ ( (aligned (16)))
38 #elif defined(_MSC_VER)
39 #define ALIGN16 __declspec (align (16))
45 #endif /* CYASSL_AESNI */
47 #if !defined (ALIGN16)
57 AES_ENC_TYPE = 1, /* cipher unique type */
65 /* AESNI needs key first, rounds 2nd, not sure why yet */
66 ALIGN16 word32 key[60];
69 ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
70 ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
74 CYASSL_API int AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
76 CYASSL_API int AesSetIV(Aes* aes, const byte* iv);
77 CYASSL_API void AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
78 CYASSL_API void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
79 CYASSL_API void AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
80 CYASSL_API void AesEncryptDirect(Aes* aes, byte* out, const byte* in);
81 CYASSL_API void AesDecryptDirect(Aes* aes, byte* out, const byte* in);
89 #endif /* CTAO_CRYPT_AES_H */