Shows the basic framework for building an encryptor as a plug in library.
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <wiredtiger.h>
#include <wiredtiger_ext.h>
typedef struct {
unsigned long nop_calls;
} NOP_ENCRYPTOR;
static int
uint8_t *src, size_t src_len,
uint8_t *dst, size_t dst_len,
size_t *result_lenp)
{
NOP_ENCRYPTOR *nop_encryptor = (NOP_ENCRYPTOR *)encryptor;
(void)session;
++nop_encryptor->nop_calls;
if (dst_len < src_len)
return (ENOMEM);
memcpy(dst, src, src_len);
*result_lenp = src_len;
return (0);
}
static int
uint8_t *src, size_t src_len,
uint8_t *dst, size_t dst_len,
size_t *result_lenp)
{
NOP_ENCRYPTOR *nop_encryptor = (NOP_ENCRYPTOR *)encryptor;
(void)session;
(void)src_len;
++nop_encryptor->nop_calls;
memcpy(dst, src, dst_len);
*result_lenp = dst_len;
return (0);
}
static int
size_t *expansion_constantp)
{
NOP_ENCRYPTOR *nop_encryptor = (NOP_ENCRYPTOR *)encryptor;
(void)session;
++nop_encryptor->nop_calls;
*expansion_constantp = 0;
return (0);
}
static int
{
NOP_ENCRYPTOR *nop_encryptor = (NOP_ENCRYPTOR *)encryptor;
(void)session;
++nop_encryptor->nop_calls;
free(encryptor);
return (0);
}
int
{
NOP_ENCRYPTOR *nop_encryptor;
(void)config;
if ((nop_encryptor = calloc(1, sizeof(NOP_ENCRYPTOR))) == NULL)
return (errno);
nop_encryptor->encryptor.encrypt = nop_encrypt;
nop_encryptor->encryptor.decrypt = nop_decrypt;
nop_encryptor->encryptor.sizing = nop_sizing;
nop_encryptor->encryptor.terminate = nop_terminate;
}