[457] | 1 | /* aes.h
|
---|
| 2 | *
|
---|
| 3 | * Copyright (C) 2006-2020 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 |
|
---|
| 24 | /* aes.h defines mini des openssl compatibility layer
|
---|
| 25 | *
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | #ifndef WOLFSSL_AES_H_
|
---|
| 30 | #define WOLFSSL_AES_H_
|
---|
| 31 |
|
---|
| 32 | #include <wolfssl/wolfcrypt/settings.h>
|
---|
| 33 |
|
---|
| 34 | #ifndef NO_AES
|
---|
| 35 | #include <wolfssl/openssl/ssl.h> /* for size_t */
|
---|
| 36 |
|
---|
| 37 | #ifdef __cplusplus
|
---|
| 38 | extern "C" {
|
---|
| 39 | #endif
|
---|
| 40 |
|
---|
| 41 | /* This structure wrapper is done because there is no aes_new function with
|
---|
| 42 | * OpenSSL compatibility layer. This makes code working with an AES structure
|
---|
| 43 | * to need the size of the structure. */
|
---|
| 44 | typedef struct WOLFSSL_AES_KEY {
|
---|
[464] | 45 | ALIGN16 void *buf[(sizeof(Aes) / sizeof(void *)) + 1];
|
---|
[457] | 46 | } WOLFSSL_AES_KEY;
|
---|
| 47 | typedef WOLFSSL_AES_KEY AES_KEY;
|
---|
| 48 |
|
---|
| 49 | WOLFSSL_API int wolfSSL_AES_set_encrypt_key
|
---|
| 50 | (const unsigned char *, const int bits, AES_KEY *);
|
---|
| 51 | WOLFSSL_API int wolfSSL_AES_set_decrypt_key
|
---|
| 52 | (const unsigned char *, const int bits, AES_KEY *);
|
---|
| 53 | WOLFSSL_API void wolfSSL_AES_cbc_encrypt
|
---|
| 54 | (const unsigned char *in, unsigned char* out, size_t len,
|
---|
| 55 | AES_KEY *key, unsigned char* iv, const int enc);
|
---|
| 56 | WOLFSSL_API void wolfSSL_AES_ecb_encrypt
|
---|
| 57 | (const unsigned char *in, unsigned char* out,
|
---|
| 58 | AES_KEY *key, const int enc);
|
---|
| 59 | WOLFSSL_API void wolfSSL_AES_cfb128_encrypt
|
---|
| 60 | (const unsigned char *in, unsigned char* out, size_t len,
|
---|
| 61 | AES_KEY *key, unsigned char* iv, int* num, const int enc);
|
---|
| 62 |
|
---|
| 63 | #define AES_cbc_encrypt wolfSSL_AES_cbc_encrypt
|
---|
| 64 | #define AES_ecb_encrypt wolfSSL_AES_ecb_encrypt
|
---|
| 65 | #define AES_cfb128_encrypt wolfSSL_AES_cfb128_encrypt
|
---|
| 66 | #define AES_set_encrypt_key wolfSSL_AES_set_encrypt_key
|
---|
| 67 | #define AES_set_decrypt_key wolfSSL_AES_set_decrypt_key
|
---|
| 68 |
|
---|
| 69 | #ifdef WOLFSSL_AES_DIRECT
|
---|
| 70 | WOLFSSL_API void wolfSSL_AES_encrypt
|
---|
| 71 | (const unsigned char* input, unsigned char* output, AES_KEY *);
|
---|
| 72 | WOLFSSL_API void wolfSSL_AES_decrypt
|
---|
| 73 | (const unsigned char* input, unsigned char* output, AES_KEY *);
|
---|
| 74 |
|
---|
| 75 | #define AES_encrypt wolfSSL_AES_encrypt
|
---|
| 76 | #define AES_decrypt wolfSSL_AES_decrypt
|
---|
| 77 | #endif /* HAVE_AES_DIRECT */
|
---|
| 78 |
|
---|
| 79 | #ifndef AES_ENCRYPT
|
---|
| 80 | #define AES_ENCRYPT AES_ENCRYPTION
|
---|
| 81 | #endif
|
---|
| 82 | #ifndef AES_DECRYPT
|
---|
| 83 | #define AES_DECRYPT AES_DECRYPTION
|
---|
| 84 | #endif
|
---|
| 85 |
|
---|
| 86 | #ifdef __cplusplus
|
---|
| 87 | } /* extern "C" */
|
---|
| 88 | #endif
|
---|
| 89 |
|
---|
| 90 | #endif /* NO_AES */
|
---|
| 91 |
|
---|
| 92 | #endif /* WOLFSSL_AES_H_ */
|
---|