-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrypto.h
31 lines (22 loc) · 1007 Bytes
/
crypto.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef CRYPTO_H
#define CRYPTO_H
#define AES_BLOCK_SIZE 16//TODO: replace with the openssl block size define
typedef struct {
long startBytePos;
long endBytePos;
unsigned char key[32];
unsigned char iv[16];
unsigned char salt[8];
EVP_CIPHER_CTX *ctx;
} CryptoState_t;
int startEncryption(CryptoState_t *state, const char *password);
int updateEncryption(CryptoState_t *state, const char *inputBuffer,
const int inputBufferSize, char *outputBuffer, int *outputDataSize);
int finishEncryption(CryptoState_t *state, const char *inputBuffer,
const int inputBufferSize, char *outputBuffer, int *outputDataSize);
int startDecryption(CryptoState_t *state, const char *password, const char *iv);
int updateDecryption(CryptoState_t *state, const char *inputBuffer,
const int inputBufferSize, char *outputBuffer, int *outputDataSize);
int finishDecryption(CryptoState_t *state, const char *inputBuffer,
const int inputBufferSize, char *outputBuffer, int *outputDataSize);
#endif /* CRYPTO_H */