SlunkCrypt/libMCrypt/include/mcrypt.h

67 lines
1.8 KiB
C

/******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_MCYRPT_H
#define INC_MCYRPT_H
#include <stdlib.h>
#include <stdint.h>
/*
* Version info
*/
extern const char *const LIBMCRYPT_VERSION;
extern const char* const LIBMCRYPT_BUILDNO;
/*
* Abort flag
*/
extern volatile int g_macrypt_abort_flag;
/*
* Opaque handle to internal state
*/
typedef uintptr_t mcrypt_t;
/*
* Constants
*/
#define MCRYPT_NULL ((mcrypt_t)NULL)
#define MCRYPT_SUCCESS 0
#define MCRYPT_FAILURE (-1)
#define MCRYPT_ABORTED (-2)
/*
* Seed generator
*/
int mcrypt_generate_seed(uint64_t* const seed);
/*
* Allocate, reset or free state
*/
mcrypt_t mcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
int mcrypt_reset(const mcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
void mcrypt_free(const mcrypt_t context);
/*
* Encryption routines
*/
int mcrypt_encrypt(const mcrypt_t context, const uint8_t *const input, uint8_t* const output, size_t length);
int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t *const buffer, size_t length);
/*
* Decryption routines
*/
int mcrypt_decrypt(const mcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length);
int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Auxiliary functions
*/
int mcrypt_random_bytes(uint8_t* const buffer, const size_t length);
void mcrypt_bzero(void* const ptr, const size_t length);
#endif