1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /************************************************************************/
- /* Copyright (C), 2016-2020, [ItCivilian], 保留所有权利;
- /* 模 块 名:;
- /* 描 述:;
- /*
- /* 版 本:[V];
- /* 作 者:[Home];
- /* 日 期:[6/5/2016];
- /*
- /*
- /* 注 意:;
- /*
- /* 修改记录:[ItCivilian];
- /* 修改日期:;
- /* 修改版本:;
- /* 修改内容:;
- /************************************************************************/
- #ifndef __SSL_DES_20160606__
- #define __SSL_DES_20160606__
- #define DES_ENCRYPT 1
- #define DES_DECRYPT 0
- #define DES_KEY_SIZE 8
- #define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0C00
- // DES结构体;
- typedef struct
- {
- unsigned long sk[32]; // DES 子密钥(由用户输入的密钥生成);
- }des_context;
- // 设置密钥校验位为偶校验;
- void des_key_set_parity( unsigned char key[8] );
- // 判断密钥校验位是否为偶校验;
- int des_key_check_key_parity( const unsigned char key[8] );
- // 判断密钥是否为弱密钥;
- int des_key_check_weak( const unsigned char key[8] );
- // 返回加密时填充后的明文长度;
- unsigned __int64 des_enc_len(const unsigned __int64& nlen);
- // 返回解密后,去除填充的长度;
- unsigned __int64 des_dec_len(const unsigned char* input, unsigned __int64 nlen);
- // DES-ECB模式加解密;
- int des_crypt_ecb( IN des_context *ctx, IN const unsigned char input[8], IN unsigned char output[8] );
- // DES-CBC模式加解密;
- int des_crypt_cbc( IN des_context *ctx, IN int mode, IN int length, IN unsigned char iv[8], IN const unsigned char *input, IN unsigned char *output );
- // DES-CBC模式加解密;
- int des_crypt_cbc(IN int mode, IN int length, IN const unsigned char *input, IN unsigned char *output, IN const int& outMaxlen );
- int des_crypt(IN CString strInput, IN CString& strOutput, IN const int &mode = DES_ENCRYPT);
- // 加密文件;
- void DES_EncryptFile(IN LPCTSTR lpFile, IN LPBYTE lpKey, IN LPBYTE lpVI, IN LPCTSTR lpEncryFile);
- // 解密文件;
- void DES_DecryptFile(IN LPCTSTR lpFile, IN LPBYTE lpKey, IN LPBYTE lpVI, IN LPCTSTR lpDecryFile);
- #endif // __SSL_DES_20160606__
|