Buffers
This page contains the primitives and their associated functions for buffer primitves within blib.
MeasuredBuffer
A general-purpose buffer with an assigned length up to DWORD
bytes.
typedef struct _MeasuredBuffer {
DWORD length;
char* buffer;
} MeasuredBuffer;
Initialisers
MeasuredBuffer* vallocMeasuredBuffer(DWORD bytes)
Allocated a measured buffer DWORD
bytes using valloc
.
MeasuredBuffer* hallocMeasuredBuffer(DWORD bytes)
Allocated a measured buffer DWORD
bytes using halloc
.
Methods
BOOL bEncryptMeasuredBufferEx(void* algorithm, long* key, unsigned int keyLength, MeasuredBuffer* buffer)
Symmetrically encrypts or decrypts a MeasuredBuffer
using the user supplied void algorithm
.
CryptoBuffer
A 'cryptographic' primitive composed of two MeasuredBuffer
s and a metadata element for an encryption type.
typedef enum _BLIB_ENCRYPTION_METHOD {
BLIB_ENCRYPTION_NONE,
BLIB_ENCRYPTION_UNDEFINED,
BLIB_ENCRYPTION_STATIC_XOR,
} BLIB_ENCRYPTION_METHOD;
typedef struct _EncryptedBuffer{
BLIB_ENCRYPTION_METHOD encryptionMethod;
MeasuredBuffer keyBuffer;
MeasuredBuffer dataBuffer;
} CryptoBuffer;
Methods
BOOL bEncryptBuffer(CryptoBuffer* buffer)
Symmetrically encrypts or decrypts a CryptoBuffer
using the accompanying method defined in the encryptionMethod field of the CryptoBuffer
.
BOOL bEncryptBufferEx(void* algorithm, CryptoBuffer* buffer)
Symmetrically encrypts or decrypts a CryptoBuffer
using the user supplied void algorithm
.