CryptoPP Files: File-Based I/O for Cryptographic Operations
#ifndef CRYPTOPP_FILES_H
#define CRYPTOPP_FILES_H
#include "cryptlib.h"
#include "filters.h"
#include "argnames.h"
#include "smartptr.h"
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char* buffer;
size_t len;
size_t pos;
size_t waiting;
} FileStore;
typedef struct {
FileStore* store;
char* buffer;
size_t len;
size_t pos;
} FileSource;
typedef struct {
FILE* file;
char* buffer;
size_t len;
} FileSink;
typedef struct {
int type;
char* message;
} Exception;
typedef struct {
char* filename;
char* mode;
FILE* file;
} FileStream;
#define NAMESPACE_BEGIN(x)
#define NAMESPACE_END
#define CRYPTOPP_DLL
#define DEFAULT_CHANNEL ""
#define NameValuePair(x, y) {x, y}
#define MakeParameters(...) 1
#define member_ptr(x) x*
#define ULONG_MAX 0xFFFFFFFF
#define CRYPTOPP_UNIX_AVAILABLE 1
typedef unsigned char byte;
typedef unsigned int lword;
#define IO_ERROR 1
void FileStore_Initialize(FileStore* store, const char* filename);
void FileStore_Finalize(FileStore* store);
lword FileStore_MaxRetrievable(const FileStore* store);
size_t FileStore_TransferTo2(FileStore* store, byte* target, lword* transferBytes, const char* channel, int blocking);
size_t FileStore_CopyRangeTo2(const FileStore* store, byte* target, lword* begin, lword end, const char* channel, int blocking);
lword FileStore_Skip(FileStore* store, lword skipMax);
void FileSource_Initialize(FileSource* source, FileStore* store, int pumpAll);
void FileSource_Finalize(FileSource* source);
size_t FileSource_GetStream(FileSource* source, FILE** stream);
size_t FileSource_PumpAll(FileSource* source, byte* target, size_t length, int messageEnd, int blocking);
void FileSink_Initialize(FileSink* sink, const char* filename, int binary);
void FileSink_Finalize(FileSink* sink);
size_t FileSink_GetStream(FileSink* sink, FILE** stream);
size_t FileSink_Put2(FileSink* sink, const byte* inString, size_t length, int messageEnd, int blocking);
int FileSink_Flush(FileSink* sink, int hardFlush, int blocking);
#endif
This header file provides the C-style definitions for the Crypto++ library's file-based I/O classes: FileStore, FileSource, and FileSink. These classes allow you to interact with files as data sources or sinks for cryptographic operations. The functions defined here allow you to initialize, finalize, read, write, and manipulate these file-based objects within your C programs. Note that this is a simplified conversion to C and doesn't fully encapsulate the functionality of the original C++ classes. For a complete and accurate implementation, refer to the original Crypto++ library code.
原文地址: https://www.cveoy.top/t/topic/qxdB 著作权归作者所有。请勿转载和采集!