64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
/******************************************************************************
|
|
*
|
|
* Copyright (c) 2017-2019 by Löwenware Ltd
|
|
* Please, refer LICENSE file for legal information
|
|
*
|
|
******************************************************************************/
|
|
|
|
/**
|
|
* @file crypt.h
|
|
* @author Ilja Kartašov <ik@lowenware.com>
|
|
* @brief
|
|
*
|
|
* @see https://lowenware.com/
|
|
*/
|
|
|
|
#ifndef AX_CRYPT_H_F18E0303_66D9_4793_A902_230BA0A0A46F
|
|
#define AX_CRYPT_H_F18E0303_66D9_4793_A902_230BA0A0A46F
|
|
|
|
#include <stdint.h>
|
|
#include <time.h>
|
|
#include <aisl/aisl.h>
|
|
#include <openssl/evp.h>
|
|
|
|
#define AX_CRYPT_KEY_SIZE 32
|
|
#define AX_CRYPT_SALT_SIZE 8
|
|
|
|
struct ax_crypt {
|
|
EVP_CIPHER_CTX *e_ctx;
|
|
EVP_CIPHER_CTX *d_ctx;
|
|
};
|
|
|
|
|
|
typedef struct ax_crypt * AxCrypt;
|
|
|
|
|
|
AislStatus
|
|
ax_crypt_init(AxSession crypt, const char *key_file);
|
|
|
|
|
|
void
|
|
ax_crypt_release(AxSession crypt);
|
|
|
|
|
|
/* encrypt */
|
|
int
|
|
ax_crypt_write(AxSession crypt, char **out, const char *input, int in_len);
|
|
|
|
|
|
/* decrypt */
|
|
int
|
|
ax_crypt_read(AxSession crypt, char **out, const char *input, int in_len);
|
|
|
|
|
|
/* encrypt and convert to BASE64 */
|
|
int
|
|
ax_crypt_encode(AxSession crypt, char **out, const char *input, int in_len);
|
|
|
|
|
|
/* decrypt from BASE64 */
|
|
int
|
|
ax_crypt_decode(AxSession crypt, char **out, const char *input, int in_len);
|
|
|
|
#endif /* !AX_CRYPT_H */
|