versadac  1
versadac - Scalable Recorder Firmware
DISE_encryption_simplewrapper.h
1 // Copyright (c) 2012 Invensys Eurotherm Ltd.
3 //
4 // MODULE : IDMEncryption
5 // FILENAME : DISE_Crypto_simplewrapper.h
6 // AUTHOR : Adrian Oliver
7 // CREATED : November 2012
8 // DESCRIPTION : Header file for IDM Encryption:
10 // These functions will use Instrument database data to automatically generate
11 // Encryption/Decryption keys.
12 //
13 // Once the key has been generated, it uses the Authenticated Encryption/Decryption
14 // functions
15 
16 // The Key generation is automatic - however on initialisation, the device/IDM
17 // needs to register here which instrument database parameters are to be used
18 // during the key generation. This is done by the host providing the
19 // structure - if this is not provided, this module will fail to link
21 
22 #ifndef DeviceIDMSymmetricEncryption_SIMPLEWRAPPER_H
23 #define DeviceIDMSymmetricEncryption_SIMPLEWRAPPER_H
24 
25 #include "stdtypes.h"
26 
29 // Wrapper function to allow drop-in-replacement of existing
30 // SimpleEncryptionEncryption and SimpleEncryptionDecryption functions
31 
32 /*----------------------------------------------------------------------
33 FUNCTION : DeviceIDMSymmetricEncryption_Encrypt*
34 DESCRIPTION : Encrypts the given String to a string with the provided key.
35 ARGUMENTS : z_data string to be encrypted
36  z_key string to use as the encrypting key.
37  z_encBuf - buffer to store encrypted result.
38 RETURN : pointer to encrypted string
39 NOTES : NB Encrypted string is 32-48 bytes longer than the plain text
40  This is because of the addition of 32 bytes of hash and
41  because of padding to 16 byte AES block size...
42 ----------------------------------------------------------------------*/
43 unsigned char* DeviceIDMSymmetricEncryption_Encrypt_For_Writing_To_Device(char* pszdatain,
44  unsigned int datain_buffer_length,
45  unsigned char* pszencBuf,
46  unsigned int encBuf_buffer_length);
47 
48 unsigned char* DeviceIDMSymmetricEncryption_Encrypt_For_Reading_From_Device(char* pszdatain,
49  unsigned int datain_buffer_length,
50  unsigned char* pszencBuf,
51  unsigned int encBuf_buffer_length);
52 
54 /*----------------------------------------------------------------------
55 FUNCTION : DeviceIDMSymmetricEncryption_Decrypt_*
56 DESCRIPTION : Decrypts the given String to a string with the provided key.
57 ARGUMENTS : z_data string to be decrypted
58  z_key string to use as the decrypting key.
59 RETURN : pointer to decrypted string
60 NOTES :
61 ----------------------------------------------------------------------*/
62 char* DeviceIDMSymmetricEncryption_Decrypt_For_Writing_To_Device(unsigned char* pszdatain,
63  unsigned int datain_buffer_length,
64  char* pszencBuf,
65  unsigned int encBuf_buffer_length);
66 
67 char* DeviceIDMSymmetricEncryption_Decrypt_For_Reading_From_Device(unsigned char* pszdatain,
68  unsigned int datain_buffer_length,
69  char* pszencBuf,
70  unsigned int encBuf_buffer_length);
71 
73 #endif