12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #pragma once
- #include <stdio.h>
- #include "filecryption.h"
- #include <stdint.h>
- #ifndef RVC_FILE_HEADER_FLAG_LEN
- #define RVC_FILE_HEADER_FLAG_LEN 16
- #endif
- #ifndef RVC_FILE_HASH_LEN
- #define RVC_FILE_HASH_LEN 32
- #endif
- #ifndef RVC_CRYPTION_VER_FLAG_LEN
- #define RVC_CRYPTION_VER_FLAG_LEN 8
- #endif
- #ifndef MAX_PATH
- #define MAX_PATH 260
- #endif // !MAX_PATH
- // {5565B9BA-2953-4F19-B05A-0F179287DB2D}
- static const char rvc_header[] = {0x55, 0x65, 0xb9, 0xba, 0x29, 0x53, 0x4f, 0x19, 0xb0, 0x5a, 0x0f, 0x17, 0x92, 0x87, 0xdb, 0x2d, 0x0};
- static const char* cryption_ver_flag_table[] = {
- "rvcfilea",
- "rvcfileb",
- "rvcfilec",
- "rvcfiled"
- };
- /*添加的自定义文件头信息
- 1. 自定义文件头标识16位
- 2. 自定义文件头长度4位
- 3. 文件加密版本标识
- 4. 源文件hash值
- 5. 源文件文件大小
- 6. 源文件文件名
- 7. 真实文件格式,后缀名
- */
- typedef struct rvc_fileheader_s{
- unsigned char strhead[RVC_FILE_HEADER_FLAG_LEN];
- size_t uheadlen;
- char strcryptver[RVC_CRYPTION_VER_FLAG_LEN];
- unsigned char strhash[RVC_FILE_HASH_LEN];
- uint32_t usrcfilelen;
- char strsrcfilename[MAX_PATH];
- char strsrcfileformat[MAX_PATH];
- }rvc_fileheader_t;
- int constrcut_rvc_file_header(char* pbuffer, uint32_t* ulen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion);
- // pheadbuffer从自定义的文件头的字段3,文件加密版本标识初开始
- int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, uint32_t ulen, const filecryption_callback_t* pcallback);
- int fill_tag_buffer(char* pbuffer, uint32_t ubuffersize, const char* pdata, uint32_t udatalen);
- int get_tag_value_from_buffer(char* pbuffer, uint32_t ubuffersize, const char* pdata, uint32_t udatalen);
- int get_key_from_header_info(unsigned char* pkey, uint32_t ukeysize, char* pheader, uint32_t udatalen, const filecryption_callback_t* pcallback);
|