diff options
Diffstat (limited to 'source/LCM/Hash.h')
-rw-r--r-- | source/LCM/Hash.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source/LCM/Hash.h b/source/LCM/Hash.h new file mode 100644 index 0000000..e5e5343 --- /dev/null +++ b/source/LCM/Hash.h @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ + +#ifndef _HASH_H_ +#define _HASH_H_ + +#include "t_communication_service.h" +#ifdef _WIN32 +#include "WinApiWrappers.h" +#else +#include "LinuxApiWrappers.h" +#endif + +struct HashRequest { + HashType_e Type; + uint8 *Data_p; + uint32 Length; + uint8 *Hash_p; + HashCallback_fn Callback; + void *Param_p; +}; + +class Hash +{ +public: + Hash(); + ~Hash(); + void Cancel(HashDevice_t **HashDevice_pp); + void Calculate(HashType_e Type, void *Data_p, const uint32 Length, uint8 *Hash_p, HashCallback_fn Callback, void *Param_p); + uint32 GetLength(HashType_e Type); +private: + CThreadWrapper *m_Thread; + CSemaphoreQueue *m_RequestQueue; + +#ifdef _WIN32 + static unsigned int WINAPI WorkerThread(void *arg); +#else + static void *WorkerThread(void *arg); +#endif + + static uint8 hashxor(const uint8 *Buf_p, uint32 Length); + static uint16 crc16(const uint8 *p, int count, uint16 crc_in); +}; + +#endif // _HASH_H_ |