2020-10-12 19:10:19 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
/* 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>
|
|
|
|
|
2020-10-16 19:33:12 +02:00
|
|
|
/*
|
|
|
|
* Version info
|
|
|
|
*/
|
2020-10-12 19:10:19 +02:00
|
|
|
extern const char *const LIBMCRYPT_VERSION;
|
2020-10-12 23:10:47 +02:00
|
|
|
extern const char* const LIBMCRYPT_BUILDNO;
|
2020-10-12 19:10:19 +02:00
|
|
|
|
2020-10-13 19:33:01 +02:00
|
|
|
/*
|
|
|
|
* Opaque handle to internal state
|
|
|
|
*/
|
2020-10-14 13:39:12 +02:00
|
|
|
typedef uintptr_t mcrypt_t;
|
2020-10-16 17:37:04 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Constants
|
|
|
|
*/
|
2020-10-14 13:39:12 +02:00
|
|
|
#define MCRYPT_NULL ((mcrypt_t)NULL)
|
2020-10-16 17:37:04 +02:00
|
|
|
#define MCRYPT_SUCCESS 0
|
|
|
|
#define MCRYPT_FAILURE (-1)
|
2020-10-12 19:10:19 +02:00
|
|
|
|
2020-10-13 19:33:01 +02:00
|
|
|
/*
|
|
|
|
* Seed generator
|
|
|
|
*/
|
2020-10-12 19:10:19 +02:00
|
|
|
int mcrypt_generate_seed(uint64_t* const seed);
|
|
|
|
|
2020-10-13 19:33:01 +02:00
|
|
|
/*
|
2020-10-14 13:39:12 +02:00
|
|
|
* Allocate, reset or free state
|
2020-10-13 19:33:01 +02:00
|
|
|
*/
|
2020-10-16 17:37:04 +02:00
|
|
|
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);
|
2020-10-12 19:10:19 +02:00
|
|
|
void mcrypt_free(const mcrypt_t context);
|
|
|
|
|
2020-10-13 19:33:01 +02:00
|
|
|
/*
|
|
|
|
* Encryption routines
|
|
|
|
*/
|
2020-10-16 17:37:04 +02:00
|
|
|
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);
|
2020-10-12 19:10:19 +02:00
|
|
|
|
2020-10-13 19:33:01 +02:00
|
|
|
/*
|
|
|
|
* Decryption routines
|
|
|
|
*/
|
2020-10-16 17:37:04 +02:00
|
|
|
int mcrypt_decrypt(const mcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length);
|
2020-10-14 17:57:40 +02:00
|
|
|
int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
|
2020-10-12 19:10:19 +02:00
|
|
|
|
2020-10-13 19:33:01 +02:00
|
|
|
/*
|
|
|
|
* Auxiliary functions
|
|
|
|
*/
|
|
|
|
int mcrypt_random_bytes(uint8_t* const buffer, const size_t length);
|
|
|
|
void mcrypt_bzero(void* const ptr, const size_t length);
|
2020-10-12 19:10:19 +02:00
|
|
|
|
|
|
|
#endif
|