Xuyi Wang / wolfcrypt

Dependents:   OS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wc_encrypt.h Source File

wc_encrypt.h

00001 /* wc_encrypt.h
00002  *
00003  * Copyright (C) 2006-2017 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSL.
00006  *
00007  * wolfSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
00020  */
00021 
00022 /*!
00023     \file wolfssl/wolfcrypt/wc_encrypt.h
00024 */
00025 
00026 
00027 #ifndef WOLF_CRYPT_ENCRYPT_H
00028 #define WOLF_CRYPT_ENCRYPT_H
00029 
00030 #include <wolfcrypt/types.h>
00031 #include <wolfcrypt/aes.h>
00032 #include <wolfcrypt/chacha.h>
00033 #include <wolfcrypt/des3.h>
00034 #include <wolfcrypt/arc4.h>
00035 
00036 #ifdef __cplusplus
00037     extern "C" {
00038 #endif
00039 
00040 /* determine max cipher key size */
00041 #ifndef NO_AES
00042     #define WC_MAX_SYM_KEY_SIZE     (AES_MAX_KEY_SIZE/8)
00043 #elif defined(HAVE_CHACHA)
00044     #define WC_MAX_SYM_KEY_SIZE     CHACHA_MAX_KEY_SZ
00045 #elif !defined(NO_DES3)
00046     #define WC_MAX_SYM_KEY_SIZE     DES3_KEY_SIZE
00047 #elif !defined(NO_RC4)
00048     #define WC_MAX_SYM_KEY_SIZE     RC4_KEY_SIZE
00049 #else
00050     #define WC_MAX_SYM_KEY_SIZE     32
00051 #endif
00052 
00053 
00054 #ifndef NO_AES
00055 WOLFSSL_API int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
00056                                         const byte* key, word32 keySz,
00057                                         const byte* iv);
00058 WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
00059                                         const byte* key, word32 keySz,
00060                                         const byte* iv);
00061 #endif /* !NO_AES */
00062 
00063 
00064 #ifndef NO_DES3
00065 WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out,
00066                                          const byte* in, word32 sz,
00067                                          const byte* key, const byte* iv);
00068 WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out,
00069                                          const byte* in, word32 sz,
00070                                          const byte* key, const byte* iv);
00071 WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out,
00072                                           const byte* in, word32 sz,
00073                                           const byte* key, const byte* iv);
00074 WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out,
00075                                           const byte* in, word32 sz,
00076                                           const byte* key, const byte* iv);
00077 #endif /* !NO_DES3 */
00078 
00079 
00080 
00081 
00082 #ifdef WOLFSSL_ENCRYPTED_KEYS
00083     struct EncryptedInfo;
00084     WOLFSSL_API int wc_BufferKeyDecrypt(struct EncryptedInfo* info, byte* der, word32 derSz,
00085         const byte* password, int passwordSz, int hashType);
00086     WOLFSSL_API int wc_BufferKeyEncrypt(struct EncryptedInfo* info, byte* der, word32 derSz,
00087         const byte* password, int passwordSz, int hashType);
00088 #endif /* WOLFSSL_ENCRYPTED_KEYS */
00089 
00090 #ifndef NO_PWDBASED
00091     WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz, 
00092         byte* salt, int saltSz, int iterations, int id, byte* input, int length,
00093         int version, byte* cbcIv, int enc);
00094 #endif
00095 
00096 #ifdef __cplusplus
00097     }  /* extern "C" */
00098 #endif
00099 
00100 #endif /* WOLF_CRYPT_ENCRYPT_H */
00101 
00102