12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #pragma once
- #include <stddef.h>
- #include <stdint.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef _MSC_VER
- #ifdef LIBFILECRYPTION_EXPORTS
- #define FILECRYPTION_API(type) _declspec(dllexport) type
- #else
- #define FILECRYPTION_API(type) _declspec(dllimport) type
- #endif
- # elif ( defined(__GNUC__) && __GNUC__ >= 4 )
- #define FILECRYPTION_API(type) __attribute__((visibility("default"))) type
- #else
- #define FILECRYPTION_API(type)
- #endif
- #ifndef RVC_FILEENC_STR
- #define RVC_FILEENC_STR "enc_"
- #endif
- #ifndef RVC_FILEDEC_STR
- #define RVC_FILEDEC_STR "dec_"
- #endif
- //加密算法版本
- enum eRvcCryptionVersion{
- eVerA,
- eVerB,
- eVerC,
- eVerD
- };
- enum filecrypt_loglevel {
- FILECRYPT_LEVEL_DEBUG,
- FILECRYPT_LEVEL_INFO,
- FILECRYPT_LEVEL_WARN,
- FILECRYPT_LEVEL_ERROR,
- FILECRYPT_LEVEL_FATAL
- };
- typedef struct filecryption_callback_s {
- void (*oncryptionexception)(void *user_data);
- void (*oncryptionfinished)(void *user_data);
- void (*dbg)(filecrypt_loglevel elevel, const char* fmt, ...);
- }filecryption_callback_t;
- #ifndef safe_log
- #define safe_log(x, elevel, strformat, ...) \
- do{\
- if (x && x->dbg){ x->dbg(elevel, strformat, ##__VA_ARGS__);}\
- }while(0)
- #endif
- FILECRYPTION_API(int) encryption_file(char* poutfile, uint32_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion);
- FILECRYPTION_API(int) decryption_file(char* poutfile, uint32_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback = NULL, eRvcCryptionVersion eversion = eVerA);
- FILECRYPTION_API(bool) is_file_encrypted(const char* pfilename, const filecryption_callback_t* pcallback);
- FILECRYPTION_API(int) rvc_file_decrypt(unsigned char** pdechead, uint32_t* udecheadlen, int* ioffset, char** pstrjson, uint32_t* ujsonlen,const char* pfilename, const filecryption_callback_t* pcallback = NULL, eRvcCryptionVersion eversion = eVerA);
- FILECRYPTION_API(int) rvc_free_data(void** pdechead);
- FILECRYPTION_API(bool) is_file_completed(const char* pfilename, const filecryption_callback_t* pcallback);
- FILECRYPTION_API(int) get_file_sm3digest(char* strbuf, uint32_t ubuflen, const char* pfilename);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
|