Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wolfssl/wolfcrypt/wc_encrypt.h@15:117db924cf7c, 2018-08-18 (annotated)
- Committer:
- wolfSSL
- Date:
- Sat Aug 18 22:20:43 2018 +0000
- Revision:
- 15:117db924cf7c
wolfSSL 3.15.3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 15:117db924cf7c | 1 | /* wc_encrypt.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/wc_encrypt.h |
wolfSSL | 15:117db924cf7c | 24 | */ |
wolfSSL | 15:117db924cf7c | 25 | |
wolfSSL | 15:117db924cf7c | 26 | |
wolfSSL | 15:117db924cf7c | 27 | #ifndef WOLF_CRYPT_ENCRYPT_H |
wolfSSL | 15:117db924cf7c | 28 | #define WOLF_CRYPT_ENCRYPT_H |
wolfSSL | 15:117db924cf7c | 29 | |
wolfSSL | 15:117db924cf7c | 30 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 15:117db924cf7c | 31 | #include <wolfssl/wolfcrypt/aes.h> |
wolfSSL | 15:117db924cf7c | 32 | #include <wolfssl/wolfcrypt/chacha.h> |
wolfSSL | 15:117db924cf7c | 33 | #include <wolfssl/wolfcrypt/des3.h> |
wolfSSL | 15:117db924cf7c | 34 | #include <wolfssl/wolfcrypt/arc4.h> |
wolfSSL | 15:117db924cf7c | 35 | |
wolfSSL | 15:117db924cf7c | 36 | #ifdef __cplusplus |
wolfSSL | 15:117db924cf7c | 37 | extern "C" { |
wolfSSL | 15:117db924cf7c | 38 | #endif |
wolfSSL | 15:117db924cf7c | 39 | |
wolfSSL | 15:117db924cf7c | 40 | /* determine max cipher key size */ |
wolfSSL | 15:117db924cf7c | 41 | #ifndef NO_AES |
wolfSSL | 15:117db924cf7c | 42 | #define WC_MAX_SYM_KEY_SIZE (AES_MAX_KEY_SIZE/8) |
wolfSSL | 15:117db924cf7c | 43 | #elif defined(HAVE_CHACHA) |
wolfSSL | 15:117db924cf7c | 44 | #define WC_MAX_SYM_KEY_SIZE CHACHA_MAX_KEY_SZ |
wolfSSL | 15:117db924cf7c | 45 | #elif !defined(NO_DES3) |
wolfSSL | 15:117db924cf7c | 46 | #define WC_MAX_SYM_KEY_SIZE DES3_KEY_SIZE |
wolfSSL | 15:117db924cf7c | 47 | #elif !defined(NO_RC4) |
wolfSSL | 15:117db924cf7c | 48 | #define WC_MAX_SYM_KEY_SIZE RC4_KEY_SIZE |
wolfSSL | 15:117db924cf7c | 49 | #else |
wolfSSL | 15:117db924cf7c | 50 | #define WC_MAX_SYM_KEY_SIZE 32 |
wolfSSL | 15:117db924cf7c | 51 | #endif |
wolfSSL | 15:117db924cf7c | 52 | |
wolfSSL | 15:117db924cf7c | 53 | |
wolfSSL | 15:117db924cf7c | 54 | #ifndef NO_AES |
wolfSSL | 15:117db924cf7c | 55 | WOLFSSL_API int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz, |
wolfSSL | 15:117db924cf7c | 56 | const byte* key, word32 keySz, |
wolfSSL | 15:117db924cf7c | 57 | const byte* iv); |
wolfSSL | 15:117db924cf7c | 58 | WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, |
wolfSSL | 15:117db924cf7c | 59 | const byte* key, word32 keySz, |
wolfSSL | 15:117db924cf7c | 60 | const byte* iv); |
wolfSSL | 15:117db924cf7c | 61 | #endif /* !NO_AES */ |
wolfSSL | 15:117db924cf7c | 62 | |
wolfSSL | 15:117db924cf7c | 63 | |
wolfSSL | 15:117db924cf7c | 64 | #ifndef NO_DES3 |
wolfSSL | 15:117db924cf7c | 65 | WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out, |
wolfSSL | 15:117db924cf7c | 66 | const byte* in, word32 sz, |
wolfSSL | 15:117db924cf7c | 67 | const byte* key, const byte* iv); |
wolfSSL | 15:117db924cf7c | 68 | WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out, |
wolfSSL | 15:117db924cf7c | 69 | const byte* in, word32 sz, |
wolfSSL | 15:117db924cf7c | 70 | const byte* key, const byte* iv); |
wolfSSL | 15:117db924cf7c | 71 | WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out, |
wolfSSL | 15:117db924cf7c | 72 | const byte* in, word32 sz, |
wolfSSL | 15:117db924cf7c | 73 | const byte* key, const byte* iv); |
wolfSSL | 15:117db924cf7c | 74 | WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out, |
wolfSSL | 15:117db924cf7c | 75 | const byte* in, word32 sz, |
wolfSSL | 15:117db924cf7c | 76 | const byte* key, const byte* iv); |
wolfSSL | 15:117db924cf7c | 77 | #endif /* !NO_DES3 */ |
wolfSSL | 15:117db924cf7c | 78 | |
wolfSSL | 15:117db924cf7c | 79 | |
wolfSSL | 15:117db924cf7c | 80 | |
wolfSSL | 15:117db924cf7c | 81 | |
wolfSSL | 15:117db924cf7c | 82 | #ifdef WOLFSSL_ENCRYPTED_KEYS |
wolfSSL | 15:117db924cf7c | 83 | struct EncryptedInfo; |
wolfSSL | 15:117db924cf7c | 84 | WOLFSSL_API int wc_BufferKeyDecrypt(struct EncryptedInfo* info, byte* der, word32 derSz, |
wolfSSL | 15:117db924cf7c | 85 | const byte* password, int passwordSz, int hashType); |
wolfSSL | 15:117db924cf7c | 86 | WOLFSSL_API int wc_BufferKeyEncrypt(struct EncryptedInfo* info, byte* der, word32 derSz, |
wolfSSL | 15:117db924cf7c | 87 | const byte* password, int passwordSz, int hashType); |
wolfSSL | 15:117db924cf7c | 88 | #endif /* WOLFSSL_ENCRYPTED_KEYS */ |
wolfSSL | 15:117db924cf7c | 89 | |
wolfSSL | 15:117db924cf7c | 90 | #ifndef NO_PWDBASED |
wolfSSL | 15:117db924cf7c | 91 | WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz, |
wolfSSL | 15:117db924cf7c | 92 | byte* salt, int saltSz, int iterations, int id, byte* input, int length, |
wolfSSL | 15:117db924cf7c | 93 | int version, byte* cbcIv, int enc); |
wolfSSL | 15:117db924cf7c | 94 | #endif |
wolfSSL | 15:117db924cf7c | 95 | |
wolfSSL | 15:117db924cf7c | 96 | #ifdef __cplusplus |
wolfSSL | 15:117db924cf7c | 97 | } /* extern "C" */ |
wolfSSL | 15:117db924cf7c | 98 | #endif |
wolfSSL | 15:117db924cf7c | 99 | |
wolfSSL | 15:117db924cf7c | 100 | #endif /* WOLF_CRYPT_ENCRYPT_H */ |
wolfSSL | 15:117db924cf7c | 101 | |
wolfSSL | 15:117db924cf7c | 102 |