SlunkCrypt/libslunkcrypt/include/slunkcrypt.h

67 lines
1.9 KiB
C
Raw Normal View History

/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_SLUNKCRYPT_H
#define INC_SLUNKCRYPT_H
#include <stdlib.h>
#include <stdint.h>
/*
* Version info
*/
extern const char *const SLUNKCRYPT_VERSION;
extern const char* const SLUNKCRYPT_BUILD;
/*
* Abort flag
*/
extern volatile int g_slunkcrypt_abort_flag;
/*
* Opaque handle to internal state
*/
typedef uintptr_t slunkcrypt_t;
/*
* Constants
*/
#define SLUNKCRYPT_NULL ((slunkcrypt_t)NULL)
#define SLUNKCRYPT_SUCCESS 0
#define SLUNKCRYPT_FAILURE (-1)
#define SLUNKCRYPT_ABORTED (-2)
/*
* Seed generator
*/
int slunkcrypt_generate_seed(uint64_t* const seed);
/*
* Allocate, reset or free state
*/
slunkcrypt_t slunkcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
void slunkcrypt_free(const slunkcrypt_t context);
/*
* Encryption routines
*/
int slunkcrypt_encrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t* const output, size_t length);
int slunkcrypt_encrypt_inplace(const slunkcrypt_t context, uint8_t *const buffer, size_t length);
/*
* Decryption routines
*/
int slunkcrypt_decrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length);
int slunkcrypt_decrypt_inplace(const slunkcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Auxiliary functions
*/
int slunkcrypt_random_bytes(uint8_t* const buffer, const size_t length);
void slunkcrypt_bzero(void* const ptr, const size_t length);
#endif