-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCSecureFileIO.h
43 lines (34 loc) · 1.04 KB
/
CSecureFileIO.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
32
33
34
35
36
37
38
39
40
41
42
/*
* File: CSecureFileIO.h
* Author: rbross
*
* Created on October 14, 2010, 2:56 PM
*/
#ifndef CSECUREFILEIO_H
#define CSECUREFILEIO_H
#include <errno.h>
#include <string.h>
#include <dlfcn.h>
#include <string>
#include <vector>
using namespace std;
//! Class to read and write a file using openssl encryption
class CSecureFileIO
{
public:
CSecureFileIO();
virtual ~CSecureFileIO();
//! Retrieve an encrypted file. Returns bytes read or -1
int ReadEncyptedFile(const char *pFilePath, string &sBuffer);
//! Write an encrypted file. Returns bytes written or -1
int WriteEncyptedFile(const char *pFilePath, const char *pBuffer);
//! Encrypt buffer
void BF_encrypt(const unsigned char *keydata, int keydatalen, unsigned char *in, unsigned char *out, unsigned int inlen);
//! Decrypt buffer
void BF_decrypt(const unsigned char *keydata, int keydatalen, unsigned char *in, unsigned char *out, unsigned int inlen);
protected:
public:
unsigned char *ucKey;
int iKeySize;
};
#endif /* CSECUREFILEIO_H */