1 | /* wc_encrypt.h
|
---|
2 | *
|
---|
3 | * Copyright (C) 2006-2017 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 | \file wolfssl/wolfcrypt/wc_encrypt.h
|
---|
24 | */
|
---|
25 |
|
---|
26 |
|
---|
27 | #ifndef WOLF_CRYPT_ENCRYPT_H
|
---|
28 | #define WOLF_CRYPT_ENCRYPT_H
|
---|
29 |
|
---|
30 | #include <wolfssl/wolfcrypt/types.h>
|
---|
31 | #include <wolfssl/wolfcrypt/aes.h>
|
---|
32 | #include <wolfssl/wolfcrypt/chacha.h>
|
---|
33 | #include <wolfssl/wolfcrypt/des3.h>
|
---|
34 | #include <wolfssl/wolfcrypt/arc4.h>
|
---|
35 |
|
---|
36 | #ifdef __cplusplus
|
---|
37 | extern "C" {
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | /* determine max cipher key size */
|
---|
41 | #ifndef NO_AES
|
---|
42 | #define WC_MAX_SYM_KEY_SIZE (AES_MAX_KEY_SIZE/8)
|
---|
43 | #elif defined(HAVE_CHACHA)
|
---|
44 | #define WC_MAX_SYM_KEY_SIZE CHACHA_MAX_KEY_SZ
|
---|
45 | #elif !defined(NO_DES3)
|
---|
46 | #define WC_MAX_SYM_KEY_SIZE DES3_KEY_SIZE
|
---|
47 | #elif !defined(NO_RC4)
|
---|
48 | #define WC_MAX_SYM_KEY_SIZE RC4_KEY_SIZE
|
---|
49 | #else
|
---|
50 | #define WC_MAX_SYM_KEY_SIZE 32
|
---|
51 | #endif
|
---|
52 |
|
---|
53 |
|
---|
54 | #if !defined(NO_AES) && defined(HAVE_AES_CBC)
|
---|
55 | WOLFSSL_API int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
|
---|
56 | const byte* key, word32 keySz,
|
---|
57 | const byte* iv);
|
---|
58 | WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
---|
59 | const byte* key, word32 keySz,
|
---|
60 | const byte* iv);
|
---|
61 | #endif /* !NO_AES */
|
---|
62 |
|
---|
63 |
|
---|
64 | #ifndef NO_DES3
|
---|
65 | WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out,
|
---|
66 | const byte* in, word32 sz,
|
---|
67 | const byte* key, const byte* iv);
|
---|
68 | WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out,
|
---|
69 | const byte* in, word32 sz,
|
---|
70 | const byte* key, const byte* iv);
|
---|
71 | WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out,
|
---|
72 | const byte* in, word32 sz,
|
---|
73 | const byte* key, const byte* iv);
|
---|
74 | WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out,
|
---|
75 | const byte* in, word32 sz,
|
---|
76 | const byte* key, const byte* iv);
|
---|
77 | #endif /* !NO_DES3 */
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 | #ifdef WOLFSSL_ENCRYPTED_KEYS
|
---|
83 | struct EncryptedInfo;
|
---|
84 | WOLFSSL_API int wc_BufferKeyDecrypt(struct EncryptedInfo* info, byte* der, word32 derSz,
|
---|
85 | const byte* password, int passwordSz, int hashType);
|
---|
86 | WOLFSSL_API int wc_BufferKeyEncrypt(struct EncryptedInfo* info, byte* der, word32 derSz,
|
---|
87 | const byte* password, int passwordSz, int hashType);
|
---|
88 | #endif /* WOLFSSL_ENCRYPTED_KEYS */
|
---|
89 |
|
---|
90 | #ifndef NO_PWDBASED
|
---|
91 | WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz,
|
---|
92 | byte* salt, int saltSz, int iterations, int id, byte* input, int length,
|
---|
93 | int version, byte* cbcIv, int enc);
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | #ifdef __cplusplus
|
---|
97 | } /* extern "C" */
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | #endif /* WOLF_CRYPT_ENCRYPT_H */
|
---|
101 |
|
---|