30 #ifndef DeviceIDMSymmetricEncryption_H
31 #define DeviceIDMSymmetricEncryption_H
34 #include "openssl/aes.h"
35 #include "AuthenticatedEncryption.h"
42 #define DeviceIDMSymmetricEncryption_IV_HMAC_KEY "uWZ2TUO_4ck=IRfL(K^mf6>f5pPT5Qkg"
48 #define DeviceIDMSymmetricEncryption_Nonce_HMAC_KEY "WdnMX2EoPCCWSDYWQ6iFc6Rh67WjsD1s"
77 extern const char* DeviceIDMSymmetricEncryption_KDF_Salt_For_Writing_To_Device;
78 extern const char* DeviceIDMSymmetricEncryption_KDF_Salt_For_Reading_From_Device;
86 extern const char* DeviceIDMSymmetricEncryption_KDF_FixedSourceKey_For_Writing_To_Device;
87 extern const char* DeviceIDMSymmetricEncryption_KDF_FixedSourceKey_For_Reading_From_Device;
96 bool DeviceIDMSymmetricEncryption_ReadDeviceData(
unsigned long CISP,
97 unsigned char* pDataBuffer,
98 unsigned int DataBufferLengthMaximum,
99 unsigned int* pIDMFlashMemoryAddress,
100 unsigned int* pRequiredDataBufferLength
114 const char* pszKDF_Salt,
115 const char* pszKDF_FixedSourceKey,
119 void InitialiseDeviceDataInformation(
void);
122 void InitialiseNounce(
unsigned long Seed);
123 void IncrementNounce();
124 unsigned long GetNounce();
128 virtual void ParameterHasBeenUpdatedFromDevice(
unsigned long CISP) {}
130 virtual bool HaveAllParametersRequiredForKDFBeenUpdated(
void){
return false;}
132 virtual bool IsThisParameterRequiredForKDF(
unsigned long CISP) {
return false;}
135 bool GetDeviceData(
unsigned char* pDeviceDataBuffer,
136 unsigned int DeviceDataBufferLength);
138 bool GenerateKey(
unsigned char* pKeyBuffer,
139 unsigned int KeyBufferLength,
140 bool IncludeNonce =
true);
142 int GetTotalNumberOfParameters(
void) {
return m_KDF_DeviceData_TotalNumberOfParameters;}
144 bool GenerateIV(
char* pIVData);
147 bool Encrypt(
const unsigned char* DataIn,
148 const int DataInLength,
149 unsigned char* pCipherDataBuffer,
150 unsigned int CipherDataBufferLength,
151 unsigned int* pCipherDataLength = NULL);
153 bool Decrypt(
const unsigned char* CipherDataIn,
154 const int CipherDataInLength,
155 unsigned char* pDataOutBuffer,
156 unsigned int DataOutBuffertLength);
159 bool Encrypt(
const unsigned char* DataIn,
160 const int DataInLength,
161 const unsigned char* KeyIn,
162 const int KeyInLength,
163 unsigned char* pCipherDataBuffer,
164 unsigned int CipherDataBufferLength,
165 unsigned int* pCipherDataLength = NULL);
167 bool Decrypt(
const unsigned char* CipherDataIn,
168 const int CipherDataInLength,
169 const unsigned char* KeyIn,
170 const int KeyInLength,
171 unsigned char* pDataOutBuffer,
172 unsigned int DataOutBuffertLength);
178 unsigned int m_KDF_DeviceData_TotalNumberOfParameters;
179 unsigned int m_KDF_DeviceData_RequiredBufferLength;
181 char m_KDF_Salt[AES_BLOCK_SIZE + 1];
182 char m_KDF_FixedSourceKey[AES_BLOCK_SIZE + 1];
184 unsigned long m_Nonce;
Definition: DISE_encryption.h:105
Definition: DISE_encryption.h:55
Definition: AuthenticatedEncryption.h:21