ssh lib
wolfcrypt/wc_encrypt.h@1:e4ea39eba2fb, 2019-11-25 (annotated)
- Committer:
- sPymbed
- Date:
- Mon Nov 25 14:23:49 2019 +0000
- Revision:
- 1:e4ea39eba2fb
- Parent:
- 0:1387ff3eed4a
improved
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sPymbed | 0:1387ff3eed4a | 1 | /* wc_encrypt.h |
sPymbed | 0:1387ff3eed4a | 2 | * |
sPymbed | 0:1387ff3eed4a | 3 | * Copyright (C) 2006-2017 wolfSSL Inc. |
sPymbed | 0:1387ff3eed4a | 4 | * |
sPymbed | 0:1387ff3eed4a | 5 | * This file is part of wolfSSL. |
sPymbed | 0:1387ff3eed4a | 6 | * |
sPymbed | 0:1387ff3eed4a | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
sPymbed | 0:1387ff3eed4a | 8 | * it under the terms of the GNU General Public License as published by |
sPymbed | 0:1387ff3eed4a | 9 | * the Free Software Foundation; either version 2 of the License, or |
sPymbed | 0:1387ff3eed4a | 10 | * (at your option) any later version. |
sPymbed | 0:1387ff3eed4a | 11 | * |
sPymbed | 0:1387ff3eed4a | 12 | * wolfSSL is distributed in the hope that it will be useful, |
sPymbed | 0:1387ff3eed4a | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
sPymbed | 0:1387ff3eed4a | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
sPymbed | 0:1387ff3eed4a | 15 | * GNU General Public License for more details. |
sPymbed | 0:1387ff3eed4a | 16 | * |
sPymbed | 0:1387ff3eed4a | 17 | * You should have received a copy of the GNU General Public License |
sPymbed | 0:1387ff3eed4a | 18 | * along with this program; if not, write to the Free Software |
sPymbed | 0:1387ff3eed4a | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
sPymbed | 0:1387ff3eed4a | 20 | */ |
sPymbed | 0:1387ff3eed4a | 21 | |
sPymbed | 0:1387ff3eed4a | 22 | /*! |
sPymbed | 0:1387ff3eed4a | 23 | \file wolfssl/wolfcrypt/wc_encrypt.h |
sPymbed | 0:1387ff3eed4a | 24 | */ |
sPymbed | 0:1387ff3eed4a | 25 | |
sPymbed | 0:1387ff3eed4a | 26 | |
sPymbed | 0:1387ff3eed4a | 27 | #ifndef WOLF_CRYPT_ENCRYPT_H |
sPymbed | 0:1387ff3eed4a | 28 | #define WOLF_CRYPT_ENCRYPT_H |
sPymbed | 0:1387ff3eed4a | 29 | |
sPymbed | 0:1387ff3eed4a | 30 | #include <wolfcrypt/types.h> |
sPymbed | 0:1387ff3eed4a | 31 | #include <wolfcrypt/aes.h> |
sPymbed | 0:1387ff3eed4a | 32 | #include <wolfcrypt/chacha.h> |
sPymbed | 0:1387ff3eed4a | 33 | #include <wolfcrypt/des3.h> |
sPymbed | 0:1387ff3eed4a | 34 | #include <wolfcrypt/arc4.h> |
sPymbed | 0:1387ff3eed4a | 35 | |
sPymbed | 0:1387ff3eed4a | 36 | #ifdef __cplusplus |
sPymbed | 0:1387ff3eed4a | 37 | extern "C" { |
sPymbed | 0:1387ff3eed4a | 38 | #endif |
sPymbed | 0:1387ff3eed4a | 39 | |
sPymbed | 0:1387ff3eed4a | 40 | /* determine max cipher key size */ |
sPymbed | 0:1387ff3eed4a | 41 | #ifndef NO_AES |
sPymbed | 0:1387ff3eed4a | 42 | #define WC_MAX_SYM_KEY_SIZE (AES_MAX_KEY_SIZE/8) |
sPymbed | 0:1387ff3eed4a | 43 | #elif defined(HAVE_CHACHA) |
sPymbed | 0:1387ff3eed4a | 44 | #define WC_MAX_SYM_KEY_SIZE CHACHA_MAX_KEY_SZ |
sPymbed | 0:1387ff3eed4a | 45 | #elif !defined(NO_DES3) |
sPymbed | 0:1387ff3eed4a | 46 | #define WC_MAX_SYM_KEY_SIZE DES3_KEY_SIZE |
sPymbed | 0:1387ff3eed4a | 47 | #elif !defined(NO_RC4) |
sPymbed | 0:1387ff3eed4a | 48 | #define WC_MAX_SYM_KEY_SIZE RC4_KEY_SIZE |
sPymbed | 0:1387ff3eed4a | 49 | #else |
sPymbed | 0:1387ff3eed4a | 50 | #define WC_MAX_SYM_KEY_SIZE 32 |
sPymbed | 0:1387ff3eed4a | 51 | #endif |
sPymbed | 0:1387ff3eed4a | 52 | |
sPymbed | 0:1387ff3eed4a | 53 | |
sPymbed | 0:1387ff3eed4a | 54 | #ifndef NO_AES |
sPymbed | 0:1387ff3eed4a | 55 | WOLFSSL_API int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz, |
sPymbed | 0:1387ff3eed4a | 56 | const byte* key, word32 keySz, |
sPymbed | 0:1387ff3eed4a | 57 | const byte* iv); |
sPymbed | 0:1387ff3eed4a | 58 | WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, |
sPymbed | 0:1387ff3eed4a | 59 | const byte* key, word32 keySz, |
sPymbed | 0:1387ff3eed4a | 60 | const byte* iv); |
sPymbed | 0:1387ff3eed4a | 61 | #endif /* !NO_AES */ |
sPymbed | 0:1387ff3eed4a | 62 | |
sPymbed | 0:1387ff3eed4a | 63 | |
sPymbed | 0:1387ff3eed4a | 64 | #ifndef NO_DES3 |
sPymbed | 0:1387ff3eed4a | 65 | WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out, |
sPymbed | 0:1387ff3eed4a | 66 | const byte* in, word32 sz, |
sPymbed | 0:1387ff3eed4a | 67 | const byte* key, const byte* iv); |
sPymbed | 0:1387ff3eed4a | 68 | WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out, |
sPymbed | 0:1387ff3eed4a | 69 | const byte* in, word32 sz, |
sPymbed | 0:1387ff3eed4a | 70 | const byte* key, const byte* iv); |
sPymbed | 0:1387ff3eed4a | 71 | WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out, |
sPymbed | 0:1387ff3eed4a | 72 | const byte* in, word32 sz, |
sPymbed | 0:1387ff3eed4a | 73 | const byte* key, const byte* iv); |
sPymbed | 0:1387ff3eed4a | 74 | WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out, |
sPymbed | 0:1387ff3eed4a | 75 | const byte* in, word32 sz, |
sPymbed | 0:1387ff3eed4a | 76 | const byte* key, const byte* iv); |
sPymbed | 0:1387ff3eed4a | 77 | #endif /* !NO_DES3 */ |
sPymbed | 0:1387ff3eed4a | 78 | |
sPymbed | 0:1387ff3eed4a | 79 | |
sPymbed | 0:1387ff3eed4a | 80 | |
sPymbed | 0:1387ff3eed4a | 81 | |
sPymbed | 0:1387ff3eed4a | 82 | #ifdef WOLFSSL_ENCRYPTED_KEYS |
sPymbed | 0:1387ff3eed4a | 83 | struct EncryptedInfo; |
sPymbed | 0:1387ff3eed4a | 84 | WOLFSSL_API int wc_BufferKeyDecrypt(struct EncryptedInfo* info, byte* der, word32 derSz, |
sPymbed | 0:1387ff3eed4a | 85 | const byte* password, int passwordSz, int hashType); |
sPymbed | 0:1387ff3eed4a | 86 | WOLFSSL_API int wc_BufferKeyEncrypt(struct EncryptedInfo* info, byte* der, word32 derSz, |
sPymbed | 0:1387ff3eed4a | 87 | const byte* password, int passwordSz, int hashType); |
sPymbed | 0:1387ff3eed4a | 88 | #endif /* WOLFSSL_ENCRYPTED_KEYS */ |
sPymbed | 0:1387ff3eed4a | 89 | |
sPymbed | 0:1387ff3eed4a | 90 | #ifndef NO_PWDBASED |
sPymbed | 0:1387ff3eed4a | 91 | WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz, |
sPymbed | 0:1387ff3eed4a | 92 | byte* salt, int saltSz, int iterations, int id, byte* input, int length, |
sPymbed | 0:1387ff3eed4a | 93 | int version, byte* cbcIv, int enc); |
sPymbed | 0:1387ff3eed4a | 94 | #endif |
sPymbed | 0:1387ff3eed4a | 95 | |
sPymbed | 0:1387ff3eed4a | 96 | #ifdef __cplusplus |
sPymbed | 0:1387ff3eed4a | 97 | } /* extern "C" */ |
sPymbed | 0:1387ff3eed4a | 98 | #endif |
sPymbed | 0:1387ff3eed4a | 99 | |
sPymbed | 0:1387ff3eed4a | 100 | #endif /* WOLF_CRYPT_ENCRYPT_H */ |
sPymbed | 0:1387ff3eed4a | 101 | |
sPymbed | 0:1387ff3eed4a | 102 |