versadac
1
versadac - Scalable Recorder Firmware
Main Page
Classes
Files
File List
File Members
core
encryption
AuthenticatedEncryption.h
1
// Copyright (c) 2012 Invensys Eurotherm Ltd.
3
//
4
// MODULE : IDMEncryption
5
// FILENAME : AE.cpp
6
// AUTHOR : Adrian Oliver
7
// CREATED : November 2012
8
// DESCRIPTION : Header file for IDM Encryption: AE
10
11
12
#ifndef AUTHENTICATED_ENCRYPTION_H
13
#define AUTHENTICATED_ENCRYPTION_H
14
17
// We store a context - this allows is to keep the AES key context, which means
18
// if we are repeatedly encrypting/decrypting messages with the same key,
19
// we save the key setup time...
20
21
class
AuthenticatedEncryption_Context
22
{
23
public
:
24
AuthenticatedEncryption_Context
();
25
~
AuthenticatedEncryption_Context
();
26
void
SetEncryptionKey(
const
unsigned
char
* key);
27
void
SetDecryptionKey(
const
unsigned
char
* key);
28
29
//AES AESEncryptor;
30
//AES AESDecryptor;
31
32
void
AES_cbc_encrypt(
const
unsigned
char
*in,
33
unsigned
char
*out,
34
size_t
length);
35
36
void
AES_cbc_decrypt(
const
unsigned
char
*in,
37
unsigned
char
*out,
38
size_t
length);
39
40
unsigned
char
szAESEncryptionKey[AES_BLOCK_SIZE + 1];
41
unsigned
char
szAESDecryptionKey[AES_BLOCK_SIZE + 1];
42
43
AES_KEY
AESEncryptionKey;
44
AES_KEY
AESDecryptionKey;
45
46
unsigned
char
szDummyIV[AES_BLOCK_SIZE + 1];
47
};
48
50
bool
AE_Encrypt(
AuthenticatedEncryption_Context
* pAE_CTX,
51
const
unsigned
char
* keyin,
52
const
int
keyinlength,
53
const
char
* pszIVdata,
// Has to be null terminated 16 bytes - if NULL, then IV is disabled...
54
const
unsigned
char
* datain,
55
const
int
datainlength,
56
const
unsigned
char
* hashkeyin,
57
const
int
hashkeyinlengthinbytes,
58
unsigned
char
* pcipherdatabuffer,
// caller MUST provide this - and it must be long enough...
59
unsigned
int
cipherdatabufferlength,
60
unsigned
int
* pcipherdatalength);
61
63
bool
AE_Decrypt(
AuthenticatedEncryption_Context
* pAE_CTX,
64
const
unsigned
char
* keyin,
65
const
int
keyinlength,
66
bool
cipherdatainincludesIV,
// ONLY set this to FALSE if IVData was NULL in Encrypt
67
const
unsigned
char
* cipherdatain,
68
const
int
cipherdatainlength,
69
const
unsigned
char
* hashkeyin,
70
const
int
hashkeyinlengthinbytes,
71
unsigned
char
* pdataoutbuffer,
// caller MUST provide this - and it must be long enough...
72
unsigned
int
dataoutbufferlength);
73
75
76
77
#endif
aes_key_st
Definition:
aes.h:76
AuthenticatedEncryption_Context
Definition:
AuthenticatedEncryption.h:21
Generated on Wed Aug 19 2020 10:33:39 for versadac by
1.8.9.1