145 lines
5.3 KiB
C
145 lines
5.3 KiB
C
#if defined(_MSC_VER) && (_MSC_VER >= 1000)
|
||
#pragma once
|
||
#endif
|
||
#ifndef _INC_FINCHAT_SDKCORE_INCLUDED
|
||
#define _INC_FINCHAT_SDKCORE_INCLUDED
|
||
#define _ENCODE_
|
||
#define _DECODE_
|
||
// #define _ENCODE_LICENSE_
|
||
#ifdef __cplusplus
|
||
extern "C"
|
||
{
|
||
#endif
|
||
#ifdef _ENCODE_
|
||
/**
|
||
* @brief 加密license
|
||
*
|
||
* @param plainText license缓冲区
|
||
* @param textLen license长度
|
||
* @param lpBuffer 解密缓冲区(需先分配长度)
|
||
* @param lpSize 解密长度
|
||
*/
|
||
void encode(const unsigned char *plainText, unsigned int textLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
/**
|
||
* @brief 加密license
|
||
*
|
||
* @param plainText license缓冲区
|
||
* @param textLen license长度
|
||
* @param lpBuffer 解密缓冲区(需先分配长度)
|
||
* @param lpSize 解密长度
|
||
*/
|
||
void encodeBySM4(const unsigned char *plainText, unsigned int textLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
#endif
|
||
#ifdef _DECODE_
|
||
/**
|
||
* @brief 解密license
|
||
*
|
||
* @param base64Text license缓冲区
|
||
* @param base64TextLen license长度
|
||
* @param lpBuffer 解密缓冲区(需先分配长度)
|
||
* @param lpSize 解密长度
|
||
*/
|
||
void decode(const unsigned char *base64Text, unsigned int base64TextLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
/**
|
||
* @brief 解密license
|
||
*
|
||
* @param base64Text license缓冲区
|
||
* @param base64TextLen license长度
|
||
* @param lpBuffer 解密缓冲区(需先分配长度)
|
||
* @param lpSize 解密长度
|
||
*/
|
||
void decodeBySM4(const unsigned char *base64Text, unsigned int base64TextLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
#endif
|
||
|
||
/**
|
||
* @brief 指定key解密
|
||
*
|
||
* @param base64Text 加密串
|
||
* @param base64TextLen 加密串长度
|
||
* @param key 加密key(长度需为16)
|
||
* @param keyLen key长度
|
||
* @param lpBuffer 解密缓冲区(需先分配长度)
|
||
* @param lpSize 解密长度
|
||
*/
|
||
void decodeByKey(const unsigned char *base64Text, unsigned int base64TextLen, const unsigned char *key, unsigned int keyLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
/**
|
||
* @brief 指定key加密
|
||
*
|
||
* @param plainText 待加密内容
|
||
* @param plainTextLen 待加密长度
|
||
* @param key 加密key(长度需为16)
|
||
* @param keyLen key长度
|
||
* @param lpBuffer 加缓冲区(需先分配长度)
|
||
* @param lpSize 加密长度
|
||
*/
|
||
void encodeByKey(const unsigned char *plainText, unsigned int plainTextLen, const unsigned char *key, unsigned int keyLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
|
||
|
||
/**
|
||
* @brief 指定key解密
|
||
*
|
||
* @param base64Text 加密串
|
||
* @param base64TextLen 加密串长度
|
||
* @param key 加密key(长度需为16)
|
||
* @param keyLen key长度
|
||
* @param lpBuffer 解密缓冲区(需先分配长度)
|
||
* @param lpSize 解密长度
|
||
*/
|
||
void decodeBySM4Key(const unsigned char *base64Text, unsigned int base64TextLen, const unsigned char *key, unsigned int keyLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
/**
|
||
* @brief 指定key加密
|
||
*
|
||
* @param plainText 待加密内容
|
||
* @param plainTextLen 待加密长度
|
||
* @param key 加密key(长度需为16)
|
||
* @param keyLen key长度
|
||
* @param lpBuffer 加缓冲区(需先分配长度)
|
||
* @param lpSize 加密长度
|
||
*/
|
||
void encodeBySM4Key(const unsigned char *plainText, unsigned int textLen, const unsigned char *key, unsigned int keyLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
|
||
#ifdef _ENCODE_LICENSE_
|
||
void encodeLicense(const unsigned char *plainText, unsigned int textLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
void encodeLicenseBySM4(const unsigned char *plainText, unsigned int textLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
#endif
|
||
void decodeLicense(const unsigned char *base64Text, unsigned int base64TextLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
void decodeLicenseBySM4(const unsigned char *base64Text, unsigned int base64TextLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
|
||
/**
|
||
* @brief 取私有sdkkey
|
||
*
|
||
* @param sdkkey sdkkey
|
||
* @param secret secret缓冲区(需先分配长度)
|
||
* @param secretLen 长度
|
||
*/
|
||
void getSecretBySDKKey(const unsigned char *sdkkey,unsigned char *secret, unsigned int *secretLen);
|
||
|
||
/**
|
||
* @brief 取私有sdkkey
|
||
*
|
||
* @param sdkkey sdkkey
|
||
* @param secret secret缓冲区(需先分配长度)
|
||
* @param secretLen 长度
|
||
*/
|
||
void getSecretBySM3SDKKey(const unsigned char *sdkkey,unsigned char *secret, unsigned int *secretLen);
|
||
|
||
/**
|
||
* @brief 消息摘要
|
||
*
|
||
* @param sdkkey sdkkey
|
||
* @param secret secret缓冲区(需先分配长度)
|
||
* @param secretLen 长度
|
||
*/
|
||
void messageDigest(const unsigned char *message,unsigned int iLen, unsigned char *lpBuffer,unsigned int *lpSize);
|
||
|
||
|
||
void encodeAESContent(const unsigned char *plainText, unsigned int textLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
void encodeSMContent(const unsigned char *plainText, unsigned int textLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
void decodeAESContent(const unsigned char *base64Text, unsigned int base64TextLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
void decodeSMContent(const unsigned char *base64Text, unsigned int base64TextLen, unsigned char *lpBuffer, unsigned int *lpSize);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
#endif /* _INC_FINCHAT_SDKCORE_INCLUDED */
|