src.dualinventive.com/dinet/sec-multi-proxy/libdi/include/di/device/uid.h

58 lines
1.5 KiB
C

/**
* Device unique id (uid) is a hex-encoded 128-bit string (32 characters)
* The reset/invalid value of the uid is "00000000000000000000000000000000"
*/
#ifndef LIBDI_INCLUDE_DI_DEVICE_UID_H_
#define LIBDI_INCLUDE_DI_DEVICE_UID_H_
#include <stdlib.h>
#include <stdbool.h>
#include <di/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DI_DEVICE_UID_LEN 33U /**< Length of device:uid including null character */
#define DI_DEVICE_UID_STR_LEN (DI_DEVICE_UID_LEN - 1) /**< Length of device:uid without null character */
#define DI_DEVICE_UID_HASH_INIT 0U /**< Invalid/unset device:uid Murmur2 hash */
#define DI_DEVICE_UID_DEFAULT_VALUE "00000000000000000000000000000000" /**< Invalid/unset device:uid string */
/**
* Hash given device:uid with Murmur2
*/
uint32_t di_device_uid_hash(const char uid[DI_DEVICE_UID_LEN]);
/**
* Verify if device:uid is valid according to specification
*/
bool di_device_uid_isvalid(const char uid[DI_DEVICE_UID_LEN]);
/**
* Set local device:uid
*/
di_errno_t di_device_uid_set(const char uid[DI_DEVICE_UID_LEN]);
/**
* Check if local device:uid is set (!DI_DEVICE_UID_STR_INIT)
*/
bool di_device_uid_isset(void);
/**
* Get local device:uid
* @retval DI_DEVICE_UID_STR_INIT when unset !DI_DEVICE_UID_STR_INIT otherwise
*/
const char *di_device_uid_get(void);
/**
* Get local device:uid Murmur2 hash
* @retval DI_DEVICE_UID_HASH_INIT when unset !DI_DEVICE_UID_HASH_INIT otherwise
*/
uint32_t di_device_uid_get_hash(void);
#ifdef __cplusplus
}
#endif
#endif /* LIBDI_INCLUDE_DI_DEVICE_UID_H_ */