-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAESCipherOpenSSL.cpp
More file actions
35 lines (27 loc) · 880 Bytes
/
AESCipherOpenSSL.cpp
File metadata and controls
35 lines (27 loc) · 880 Bytes
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
/*
* File: AESCipherOpenSSL.cpp
* Author: ph4r05
*
* Created on May 27, 2014, 10:53 AM
*/
#include "AESCipherOpenSSL.h"
#include <string.h>
AESCipherOpenSSL::AESCipherOpenSSL() {
}
AESCipherOpenSSL::AESCipherOpenSSL(const AESCipherOpenSSL& orig) {
}
AESCipherOpenSSL::~AESCipherOpenSSL() {
}
int AESCipherOpenSSL::evaluate(const unsigned char* input, unsigned char* output) {
unsigned char inp[AES_BLOCK_SIZE];
unsigned char key[AES_BLOCK_SIZE];
memcpy(inp, input, AES_BLOCK_SIZE);
memcpy(key, input + AES_BLOCK_SIZE, AES_BLOCK_SIZE);
return evaluate(inp, key, output);
}
int AESCipherOpenSSL::evaluate(const unsigned char* input, const unsigned char* key, unsigned char* output) {
AES_KEY enc_key;
AES_set_encrypt_key(key, getKeyBlockSize()*8, &enc_key);
AES_encrypt(input, output, &enc_key);
return 1;
}