diff --git a/OxySec/Include/xlt.h b/OxySec/Include/xlt.h
index 26d8367..b78772e 100644
--- a/OxySec/Include/xlt.h
+++ b/OxySec/Include/xlt.h
@@ -1,18 +1,27 @@
-/** \file
- * XLight Library.
- * \mainpage XLight Library Documentation
+/**
+\file
+\page xlt_library XLight Library Documentation
+ *
+ *
+
+// \note
+> This is the reference manual for the XLight APIs.
+> Before reading this document it is strongly recommended to see the following documentation:
+>
-This is the documentation of the \ref xltapi "APIs" for the communication between the host computer and the XLight device. +This is the documentation of the \ref xltapi_old "APIs" for the communication between the host computer and the XLight device. -At present XLight offers API only for Windows operating system. -No driver installation is needed. +This documentation is extracted from the original XLight documentation, now it is part of the \ref xnd_mainpage "xNodus project". -
The libraries are supplied in dll and obj format. -- Dlls (oxyxlt.dll, 32 and 64 bit) are usable by any application which can be interfaced with DLLs. -- OBJs (oxyxlt.obj, 32 and 64 bit) can be integrated into "Microsoft Visual Studio 2008" C, C++ projects. -
-The interfaces supplied by the libraries (both dll and obj) are declered inside the file xlt.h and this documentation describes such interfaces.
@@ -22,16 +31,93 @@ Read the following topics on Advanced XLight protection
Warning! This function can be executed only once! All the subsequent calls will fail. \note this function produces an irreversible setting onto the XLight device, hence use it very carefully.
- \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] label points to a buffer of length ::XLT_LABEL_SIZE. It contains the label, that is the identification name to be assigned to the device. \param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE. It contains the password to be assigned to the device. \param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains Dongle Key: the AES-256 key that will be used, for instance, by the functions xlt_encrypt() and xlt_decrypt(). \param[in] cr_key points to a buffer of length ::XLT_KEY_SIZE. It contains an AES-256 key (Challenge Key) that will be used by the functions xlt_challenge(). - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark password, dongle_key (the Dongle Key) and cr_key (the Challenge Response Key or shortly Challenge Key) are optional arguments and they can be set to 0 (NULL). Whenever one of these entry is null it is considered as if it was an array of bytes filled with the value 0xFF (255 decimal). In other word, passing NULL is equivalent of passing a 0xFF bytes array. \note though password, Dongle Key and Challenge Key are optional, it is strongly recommended to set them with non trivial values to forbid memory access (using password) to unauthorized application, and to allow the protected application to make sure of the presence of the XLight device (using Challenge Key) which constitutes the key point of the software protection. - \note before calling xlt_setup() a device is in a non initialized state. In this context only the functions xlt_getinfo() and xlt_close() work. + \note before calling xlt_setup() a device is in a non initialized state. In this context only the functions xlt_getinfo() and xlt_close() works. \note Never put Dongle Key inside the protected application. This is a key on which many security features are based on, inserting it inside the protected application may yield fundamental information to hackers for emulating the XLight device also in its more advanced feaures. @@ -826,41 +1013,13 @@ XLT_LINK int XLT_API xlt_setup(unsigned int device, const unsigned char* label, /** - * Find a device with the specified label. - * \param[in] label buffer of length ::XLT_LABEL_SIZE. Note that the comparison uses the whole size of the label, so the Label must not be - * considered as a string but as an array of characters of length ::XLT_LABEL_SIZE. - * \return returns a value less than 0 if the label is not found, otherwise its index is returned. This index number must be used by any other function to access the device. - * This index is passed as the argument named device. - * \remark xlt_locate() is useful for easy access to a device, but if more than one device sharing the same label are plugged into the computer it's impossible - * to use this function for accessing all devices. Consider using a different way as shown in the example of xlt_getinfo(), where all the plugged devices are enumerated. - - \par Example - \code - int device; - unsigned char label[XLT_LABEL_SIZE]; - - strcpy((char*)label, "My XLight label"); - memset(label + strlen("My XLight label"), 0x00, sizeof(label) - strlen("My XLight label")); - - device = xlt_locate(label); - if (device >= 0) - printf("XLight device found at index %d\n", device); - else - printf("XLight device NOT found\n"); - ... - \endcode - - */ -XLT_LINK int XLT_API xlt_locate(const unsigned char* label); - - -/** -Write into a memory bank of the XLight device. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + * \ingroup xlt_bank + Write into a memory bank of the XLight device. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE that contains the password assigned to the device. \param[in] bank the index of the memory bank that must be written. \param[in] data points to a buffer of size ::XLT_BANK_SIZE containing the data to be written into the memory. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark the password entry must be the same that was used in xlt_setup() call. If it was NULL, it must be NULL also in xlt_write(). \par Example @@ -876,8 +1035,8 @@ Write into a memory bank of the XLight device. strcpy((char*)data, "Some data"); memset(data + strlen("Some data"), 0x00, sizeof(data) - strlen("Some data")); - strcpy((char*)password, "My password"); - memset(password + strlen("My password"), 0x00, sizeof(password) - strlen("My password")); + strcpy((char*)password, "My XLight password"); + memset(password + strlen("My XLight password"), 0x00, sizeof(password) - strlen("My XLight password")); //write in bank 0 of an XLight dongle indexed by device = 0 status = xlt_write(device, password, 0, data); @@ -891,12 +1050,13 @@ XLT_LINK int XLT_API xlt_write(unsigned int device, const unsigned char* passwor /** -Read from a memory bank of the XLight device. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + * \ingroup xlt_bank + Read from a memory bank of the XLight device. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE that contains the password assigned to the device. \param[in] bank the index of the memory bank that must be read. \param[out] data points to a buffer of size ::XLT_BANK_SIZE that will receive the data read from the adressed memory bank. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark the password entry must be the same that was used in xlt_setup() call. If it was NULL, it must be NULL also in xlt_read(). \par Example @@ -907,8 +1067,8 @@ Read from a memory bank of the XLight device. unsigned char password[XLT_PASSWORD_SIZE]; unsigned char data[XLT_BANK_SIZE]; - strcpy((char*)password, "My password"); - memset(password + strlen("My password"), 0x00, sizeof(password) - strlen("My password")); + strcpy((char*)password, "My XLight password"); + memset(password + strlen("My XLight password"), 0x00, sizeof(password) - strlen("My XLight password")); //read from bank 0 of an XLight dongle status = xlt_read(device, password, 0, data); @@ -927,14 +1087,15 @@ XLT_LINK int XLT_API xlt_read(unsigned int device, const unsigned char* password /** + * \ingroup xlt_bank Freeze a given memory bank. After freezing it won't be possible write inside the given bank any longer. \note this function produces an irreversible setting onto the XLight device, hence use it very carefully. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE that contains the password assigned to the device. \param[in] bank the index of the memory bank that must be frozen. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark the password entry must be the same that was used in xlt_setup() call. If it was NULL, it must be NULL also in xlt_bank_freeze(). \par Example @@ -944,10 +1105,10 @@ Freeze a given memory bank. After freezing it won't be possible write inside the unsigned int device = 0; unsigned char password[XLT_PASSWORD_SIZE]; - strcpy((char*)password, "My password"); - memset(password + strlen("My password"), 0x00, sizeof(password) - strlen("My password")); + strcpy((char*)password, "My XLight password"); + memset(password + strlen("My XLight password"), 0x00, sizeof(password) - strlen("My XLight password")); - //freeze the bank 0 of a XLight dongle + //freeze the bank 0 of an XLight dongle //BEWARE: after the freeze the memory content of the bank 0 can't be modified any longer status = xlt_bank_freeze(device, password, 0); if (status != XLT_ERROR_SUCCESS){ @@ -961,11 +1122,12 @@ XLT_LINK int XLT_API xlt_bank_freeze(unsigned int device, const unsigned char* p /** +\deprecated Perform AES-256 encryption - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the plaintext to encrypt. \param[out] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE receiving the encrypted result. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note the encryption function uses as cryptographic key the Dongle Key entry set by xlt_setup(). \note We strongly recommend never to put Dongle Key in the protected application. Use Dongle Key to encrypt data, but not for authentication process like discussed in xlt_challenge() documentation. @@ -1028,11 +1190,12 @@ XLT_LINK int XLT_API xlt_encrypt(unsigned int device, const unsigned char* plain /** +\deprecated Perform AES-256 decryption. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the ciphertext to be decrypted. \param[out] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the result of the decryption. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark this function is the inverse of xlt_encrypt(), that is from ciphertext it returns the original plaintext passed to xlt_encrypt(). \note the decryption function uses as cryptographic key the Dongle Key entry set by xlt_setup(). @@ -1059,12 +1222,13 @@ XLT_LINK int XLT_API xlt_decrypt(unsigned int device, const unsigned char* ciphe /** +\deprecated Challenge-Response computation based on AES-256. The protected software send a value and check that the outcome is as expected. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] challenge points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the challenge data. \param[out] response points to the buffer of length ::XLT_CIPHERTEXT_SIZE receiving the response. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note the Challenge-Response mechanism uses as cryptographic key the cr_key (Challenge Response Key) entry set by xlt_setup(). \remark the challenge response mechanism is a sort of proof of identity without exposing details to eavesdroppers on the USB communication or on the dll interface. It is based onto the AES-256 encryption and the verifier inside the protected program must know the key used by the @@ -1140,13 +1304,14 @@ The protected software send a value and check that the outcome is as expected. XLT_LINK int XLT_API xlt_challenge(unsigned int device, const unsigned char* challenge, unsigned char* response); /** -Load on a XLight device the session AES key to be used for AES session encryption functions. + * \ingroup xlt_aes +Load on an XLight device the session AES key to be used for AES session encryption functions. See \ref AES_Session_Key for an introduction on Session Key protection. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] key_index index of the key to be used. This value runs from 0 to ::XLT_SESSION_NUMBER_OF_KEYS -1. \param[in] wrapped_key points to the buffer of length ::XLT_KEY_SIZE containing the Session Key encrypted with Dongle Key. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. This function must be used to set the AES key that will be used by xlt_session_encrypt() and xlt_session_decrypt(). This cryptographic key must be passed in encrypted (wrapped) form depending on the Dongle Key. In oreder to produce the wrapped form of the Session Key use xlt_session_wrap_key(). @@ -1162,13 +1327,14 @@ See \ref Session_KeyProtection "here" for a source code example using this funct XLT_LINK int XLT_API xlt_session_set_key(unsigned int device, unsigned int key_index, const unsigned char* wrapped_key); /** +\ingroup xlt_aes Encrypt data using a Session Key. See \ref AES_Session_Key for an introduction on Session Key protection. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] key_index index of the key to be used. This value runs from 0 to ::XLT_SESSION_NUMBER_OF_KEYS -1. \param[in] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the data to be encrypted \param[out] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE that will receive the encrypted data. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. This function performs AES-256 encryption of a plaintext of length ::XLT_CIPHERTEXT_SIZE and inserts the ciphertext result in a buffer of the same length. The AES key is one of the eight Session Keys specified by the index key_index, and the corrisponding key was previously set by the xlt_session_decrypt() function. @@ -1180,13 +1346,14 @@ See \ref AES_Session_Key for an introduction on Session Key protection. XLT_LINK int XLT_API xlt_session_encrypt(unsigned int device, unsigned int key_index, const unsigned char* plaintext, unsigned char* ciphertext); /** +* \ingroup xlt_aes Decrypt data using a Session Key. See \ref AES_Session_Key for an introduction on Session Key protection. - \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. + \param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] key_index index of the key to be used. This value runs from 0 to ::XLT_SESSION_NUMBER_OF_KEYS -1. \param[in] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the data to be decrypted. \param[out] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE that will receive the decrypted data. - \return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. + \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. This function performs AES-256 decryption of a ciphertext buffer with length of the block of the AES algorithm, that is a length of ::XLT_CIPHERTEXT_SIZE. The used key was set by a previous call of xlt_session_set_key(). @@ -1196,12 +1363,13 @@ See \ref AES_Session_Key for an introduction on Session Key protection. XLT_LINK int XLT_API xlt_session_decrypt(unsigned int device, unsigned int key_index, const unsigned char* ciphertext, unsigned char* plaintext); /** +* \ingroup xlt_aes Wraps a Session Key. See \ref AES_Session_Key for an introduction on Session Key protection. \param[in] session_key points to the AES key that will be used by xlt_session_encrypt() and xlt_session_decrypt(). It's length is of ::XLT_KEY_SIZE bytes. \param[in] dongle_key points to the value of the Dongle Key set up by xlt_setup() function. \param[out] wrapped_key points to a memory buffer of length ::XLT_KEY_SIZE that will receive the wrapped version of key. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note never use this function onto the protected software, in particular, never insert the Dongle Key into the protected software. This is an utility software to compute the wrapped version of a Session Key and must be done in an utility software not distributed to the @@ -1216,6 +1384,7 @@ See \ref Session_KeyPreliminary "here" for a source code example using this func XLT_LINK int XLT_API xlt_session_wrap_key(const unsigned char* session_key, const unsigned char* dongle_key, unsigned char* wrapped_key); /** +* \ingroup xlt_rsa Generate an RSA key. See \ref RSA_Protection for an introduction on the RSA protection in XLight. \param[in] bit_size the length in bit of the key to generate. The possible values are ::XLT_RSA_512_BIT_SIZE and ::XLT_RSA_1024_BIT_SIZE. @@ -1226,7 +1395,7 @@ See \ref RSA_Protection for an introduction on the RSA protection in XLight. If this parameter is NULL the public key is not retrieved. \param[in] public_key_size size of the public_key buffer. The size for a 1024 bit key is ::XLT_RSA_1024_PUB_KEY_SIZE and the size for a 512 bit key is ::XLT_RSA_512_PUB_KEY_SIZE. \param[out] p_public_key_len points to an unsigned integer that will receive the actual length of the generated formatted public key. -\return ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note this is an utility function that must be never used onto the protected software. Its purpose is RSA key generation and may be substituted by other software doing the same task. There are plenty of source code available in internet doing RSA key generation. @@ -1237,14 +1406,15 @@ XLT_LINK int XLT_API xlt_rsa_generate_key(unsigned int bit_size, unsigned char* unsigned char* public_key, unsigned int public_key_size, unsigned int* p_public_key_len); /** +* \ingroup xlt_rsa Wraps an RSA key. See \ref RSA_Protection for an introduction on the RSA protection in XLight. -\param[in] private_key points to a buffer containing a formatted private key +\param[in] private_key points to a buffer containing a formatted private key. \param[in] private_key_length length of the RSA formatted key (\ref RSA_format). \param[in] dongle_key points to a buffer containing Dongle Key. \param[out] wrapped_key points to the buffer that will receive an encryption of the RSA private key (wrapped). \param[in] wrapped_key_len the length of Wrapped Key pointed by wrapped_key. The length of a Wrapped Key must be ::XLT_RSA_1024_WRAPPED_KEY_SIZE for a 1024-bit key and ::XLT_RSA_512_WRAPPED_KEY_SIZE for a 512-bit key. -\return ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note this is an utility function that must be never used onto the protected software. Its purpose is to encrypt an RSA private key for protecting its content. The produced Wrapped Key may reside into a protected software or exposed to the public access without revealing its real content. @@ -1256,14 +1426,37 @@ In order to insert a private key onto the device the Wrapped Key must be XLT_LINK int XLT_API xlt_rsa_wrap_privkey(const unsigned char* private_key, unsigned int private_key_length, const unsigned char* dongle_key, unsigned char* wrapped_key, unsigned int wrapped_key_len); /** +* \ingroup xlt_rsa +Wraps an RSA key. +As xlt_rsa_wrap_privkey() function but with the addition to bind a specific recipient XLight device by its serial number. +See \ref RSA_Protection for an introduction on the RSA protection in XLight. +\param[in] private_key points to a buffer containing a formatted private key. +\param[in] private_key_length length of the RSA formatted key (\ref RSA_format). +\param[in] dongle_key points to a buffer containing Dongle Key. +\param[in] sn the serial number of the destination XLight device. +\param[out] wrapped_key points to the buffer that will receive an encryption of the RSA private key (wrapped). +\param[in] wrapped_key_len the length of Wrapped Key pointed by wrapped_key. The length of a Wrapped Key must be ::XLT_RSA_1024_WRAPPED_KEY_SIZE for a 1024-bit key and ::XLT_RSA_512_WRAPPED_KEY_SIZE for a 512-bit key. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. + +\note this is an utility function that must be never used onto the protected software. Its purpose is to encrypt an RSA private key for protecting its +content. The produced Wrapped Key may reside into a protected software or exposed to the public access without revealing its real content. +In order to insert a private key onto the device the Wrapped Key must be passed to the function xlt_rsa_set_privkey(). + +
Supported version: this function is available on XLight devices version 2.4 or later. +\sa xlt_rsa_wrap_privkey() +*/ +XLT_LINK int XLT_API xlt_rsa_wrap_privkey_sn(const unsigned char* private_key, unsigned int private_key_length, const unsigned char* dongle_key, unsigned int sn, unsigned char* wrapped_key, unsigned int wrapped_key_len); + +/** +* \ingroup xlt_rsa Load an RSA private key onto an XLight device. See \ref RSA_Protection for an introduction on the RSA protection in XLight. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] wrapped_key points to the buffer containing the wrapped RSA key to be inserted into ther XLight device. \param[in] wrapped_key_length the length of the Wrapped Key data. -\return ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. -\note on a XLight device it is possible to store two RSA keys: one 1024 bit key and one 512 bit key. The bit length reppresent the length of its +\note on an XLight device it is possible to store two RSA keys: one 1024 bit key and one 512 bit key. The bit length reppresent the length of its "modulus", not the length of the data containing the key (see \ref RSA_format). The device recognizes the two different key types and write them in their reserved memory place. The RSA key received from this function is not in clear form, but encrypted by the function xlt_rsa_wrap_privkey(). @@ -1276,6 +1469,7 @@ nevertheless it can be always overwritten with a new one. XLT_LINK int XLT_API xlt_rsa_set_privkey(unsigned int device, const unsigned char* wrapped_key, unsigned int wrapped_key_length); /** +* \ingroup xlt_rsa Performs RSA encryption. \deprecated just use for test purpose @@ -1287,13 +1481,14 @@ See \ref RSA_Protection for an introduction on the RSA protection in XLight. The allowed values for this argument are ::XLT_RSA_1024_PLAINTEXT_SIZE and ::XLT_RSA_512_PLAINTEXT_SIZE, if the plaintext is shorter it must be copied into a buffer of the proper length and zero padded up to its overall length. \param[out] ciphertext points to the buffer that will receive the result of the encryption. -\return ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note this function is present for test purpose, never use it in the application protected with XLight.
Supported version: this function is available on XLight devices version 2.0 or later. */ XLT_LINK int XLT_API xlt_never_use_this_rsa_encrypt(const unsigned char* public_key, unsigned int public_key_len, const unsigned char* plaintext, unsigned int plaintext_ciphertext_length, unsigned char* ciphertext); /** +* \ingroup xlt_rsa Performs a software RSA decryption. \deprecated just use for test purpose @@ -1305,21 +1500,22 @@ See \ref RSA_Protection for an introduction on the RSA protection in XLight. The allowed values for this argument are ::XLT_RSA_1024_PLAINTEXT_SIZE and ::XLT_RSA_512_PLAINTEXT_SIZE, if the plaintext is shorter it must be copied into a buffer of the proper length and zero padded up to its overall length. \param[out] plaintext points to the buffer that will receive the result of the decryption. -\return ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
Supported version: this function is available on XLight devices version 2.0 or later. */ XLT_LINK int XLT_API xlt_never_use_this_rsa_sw_decrypt(const unsigned char* private_key, unsigned int private_key_len, const unsigned char* ciphertext, unsigned int ciphertext_plaintext_length, unsigned char* plaintext); /** +* \ingroup xlt_rsa Runs an RSA decryption onto an XLight device. See \ref RSA_Protection for an introduction on the RSA protection in XLight. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] ciphertext points to the buffer containing the data to be decrypted. \param[in] ciphertext_plaintext_length the length of the data to be decrypted, and the size of the receiving buffer. The allowed values for this argument are ::XLT_RSA_1024_PLAINTEXT_SIZE and ::XLT_RSA_512_PLAINTEXT_SIZE, if the plaintext is shorter it must be copied into a buffer of the proper length and zero padded up to its overall length (see \ref RSA_format). \param[out] plaintext points to the buffer that will receive the result of the decryption. -\return ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \note the length of the ciphertext buffer must be the same of the plaintext. If the length is ::XLT_RSA_1024_PLAINTEXT_SIZE the 1024-bit key is used, if the length is ::XLT_RSA_512_PLAINTEXT_SIZE the 512-bit key is used, for any other value an error is returned.
Supported version: this function is available on XLight devices version 2.0 or later. @@ -1327,16 +1523,17 @@ if the length is ::XLT_RSA_512_PLAINTEXT_SIZE the 512-bit key is used, for any o XLT_LINK int XLT_API xlt_rsa_decrypt(unsigned int device, const unsigned char* ciphertext, unsigned int ciphertext_plaintext_length, unsigned char* plaintext); /** +\ingroup xlt_bank Lock a memory bank. \note this function produces an irreversible setting onto the XLight device, hence use it very carefully. See \ref locked_memory. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE. It contains the password assigned to the device with xlt_setup(). \param[in] bank the index of the memory bank that must be locked. \param[in] group_number the group number to be assigned to the locking bank. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. A locked memory bank can be written only using encrypted commands created by xlt_set_write_locked_group_check() or xlt_set_write_locked_serial_check() and performed by xlt_write_locked(). @@ -1355,16 +1552,17 @@ The remaining bytes are used by the locking mechanism management. XLT_LINK int XLT_API xlt_bank_lock(unsigned int device, const unsigned char* password, unsigned int bank, unsigned int group_number); /** +\ingroup xlt_bank Lock a memory bank in advanced mode (Lock2). \note this function produces an irreversible setting onto the XLight device, hence use it very carefully. See \ref locked_memory. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE. It contains the password assigned to the device with xlt_setup(). \param[in] bank the index of the memory bank that must be locked. \param[in] group_number the group number to be assigned to the locking bank. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. A locked2 memory bank can be written only using encrypted commands created by xlt_set_write_locked2_group_check() or xlt_set_write_locked2_serial_check() and performed by xlt_write_locked(). @@ -1383,27 +1581,29 @@ The remaining bytes are used by the locking mechanism management. XLT_LINK int XLT_API xlt_bank_lock2(unsigned int device, const unsigned char* password, unsigned int bank, unsigned int group_number); /** +\ingroup xlt_bank Perform a write operation in a locked bank (both normal and advanced Lock2 mode). See \ref locked_memory. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] bank the index of the memory bank that must be written. \param[in] transfer_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA containing the values computed by xlt_set_write_locked_serial_check() or xlt_set_write_locked_group_check(). -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \sa xlt_set_write_locked_serial_check(), xlt_set_write_locked_group_check(). */ XLT_LINK int XLT_API xlt_write_locked(unsigned int device, unsigned int bank, const unsigned char* transfer_data); /** +\ingroup xlt_bank Perform a read operation in a locked bank (both normal and advanced Lock2 mode). See \ref locked_memory. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. \param[in] bank the index of the memory bank that must be read. \param[out] transfer_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the content of the memory bank in encrypted form. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark in order to get the data in plain form the function xlt_decrypt_locked2_data() must be used. \note a locked bank can always be read using the xlt_read() function, while this function doesn't need the use of password, but its outcome can't be used as is, because it needs decryption. @@ -1416,6 +1616,7 @@ XLT_LINK int XLT_API xlt_read_locked(unsigned int device, unsigned int bank, uns /** +\ingroup xlt_bank Encrypt the buffer to be written into a locked bank of a specific XLight device. This data can be written only once and only in the device with a given serial number, provided that the destination bank is locked (see xlt_bank_lock2()). @@ -1428,7 +1629,7 @@ See \ref locked_memory. \param[out] transfer_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be applied onto the XLight device via the xlt_write_locked() function. to the XLight device with the xlt_write() function in order to write data into a locked bank. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark this function is to be considered as an utility not to be used diretly by the protected software. It can be used by the vendor of the protected software in order to remotely update the locked memory of a device. @@ -1440,6 +1641,7 @@ this remote update technique can be used, for instance, for license management p XLT_LINK int XLT_API xlt_set_write_locked_serial_check(const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int serial, const unsigned char* dongle_key , unsigned char* transfer_data); /** +\ingroup xlt_bank Encrypt the buffer to be written into a bank locked with Lock2 of a specific XLight device. This data can be written only once and only in the device with a given serial number, provided that the destination bank is locked (see xlt_bank_lock2()). @@ -1452,7 +1654,7 @@ See \ref locked_memory. \param[out] transfer_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be applied onto the XLight device via the xlt_write_locked() function. to the XLight device with the xlt_write() function in order to write data into a locked bank. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark this function is to be considered as an utility not to be used diretly by the protected software. It can be used by the vendor of the protected software in order to remotely update the locked memory of a device. @@ -1465,6 +1667,7 @@ this remote update technique can be used, for instance, for license management p XLT_LINK int XLT_API xlt_set_write_locked2_serial_check(const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int serial, const unsigned char* dongle_key , unsigned char* transfer_data); /** +\ingroup xlt_bank Encrypt the buffer to be written into a locked bank belonging to an XLight devices of a given group. This data can be written only once provided that the destination bank is locked (see xlt_bank_lock()). @@ -1476,7 +1679,7 @@ See \ref locked_memory. \param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains the AES-256 key Dongle Key set during xlt_getinfo() call. \param[out] transfer_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be applied onto the XLight device via the xlt_write_locked() function. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark the group number correspond to what is set on the dongle by xlt_bank_lock(). It is intended to define subgroups of devices each of them must be treated in the same way. @@ -1485,6 +1688,7 @@ For further notices see the comments of xlt_set_write_locked_serial_check(), the XLT_LINK int XLT_API xlt_set_write_locked_group_check(const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int group_number, const unsigned char* dongle_key, unsigned char* transfer_data); /** +\ingroup xlt_bank Encrypt the buffer to be written into a bank locked with Lock2 belonging to an XLight devices of a given group. This data can be written only once provided that the destination bank is locked (see xlt_bank_lock2()). @@ -1496,7 +1700,7 @@ See \ref locked_memory. \param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains the AES-256 key Dongle Key set during xlt_getinfo() call. \param[out] transfer_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be applied onto the XLight device via the xlt_write_locked() function. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark the group number correspond to what is set on the dongle by xlt_bank_lock2(). It is intended to define subgroups of devices each of them must be treated in the same way. @@ -1506,13 +1710,14 @@ For further notices see the comments of xlt_set_write_locked_serial_check(), the XLT_LINK int XLT_API xlt_set_write_locked2_group_check(const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int group_number, const unsigned char* dongle_key, unsigned char* transfer_data); /** +\ingroup xlt_bank Retrieve the data in clear form of the content of a locked memory bank. See \ref locked_memory. \param[in] transfer_data points to a buffer of length ::XLT_LOCKED_TRANSFER_DATA. \param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE containing the dangle_key key set by xlt_setup(). \param[out] data points to a buffer of length ::XLT_BANK_SIZE that will receice the decrypted value. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark xlt_decrypt_locked_data() retrieves the data in clear form of the content of a memory bank collected with a previous xlt_read_locked() call. xlt_decrypt_locked_data() and xlt_read_locked() are used in a server client memory bank read operation. The xlt_read_locked() doesn't need of any password @@ -1528,13 +1733,14 @@ These bytes convey information that may be retrieved using xlt_get_info_from_loc XLT_LINK int XLT_API xlt_decrypt_locked_data(const unsigned char* transfer_data, const unsigned char* dongle_key, unsigned char* data); /** +\ingroup xlt_bank Retrieve the data in clear form of the content of a locked with Lock2 memory bank. See \ref locked_memory. \param[in] transfer_data points to a buffer of length ::XLT_LOCKED_TRANSFER_DATA. \param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE containing the dangle_key key set by xlt_setup(). \param[out] data points to a buffer of length ::XLT_BANK_SIZE that will receice the decrypted value. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark xlt_decrypt_locked2_data() retrieves the data in clear form of the content of a memory bank collected with a previous xlt_read_locked() call. xlt_decrypt_locked2_data() and xlt_read_locked() are used in a server client memory bank read operation. The xlt_read_locked() doesn't need of any password @@ -1551,6 +1757,7 @@ These bytes convey information that may be retrieved using xlt_get_info_from_loc XLT_LINK int XLT_API xlt_decrypt_locked2_data(const unsigned char* transfer_data, const unsigned char* dongle_key, unsigned char* data); /** +\ingroup xlt_bank Return information of a locked bank (both normal and advanced Lock2 mode). See \ref locked_memory. @@ -1559,7 +1766,7 @@ See \ref locked_memory. \param[out] pcounter points to an unsigned int that will contain the current counter field of the locked bank. This parameter is optional and may be set to NULL. \param[out] pserial points to an unsigned int that will contain the serial number of the locked bank. This parameter is optional and may be set to NULL. \param[out] pgroup_number points to an unsigned int that will contain the group number of the locked bank. This parameter is optional and may be set to NULL. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark if the data passed to this function comes from a non locked bank the outcome of this function is meaningless. \remark the 'data' argument may come from a xlt_decrypt_locked_data() or a local xlt_read() call. */ @@ -1567,9 +1774,10 @@ XLT_LINK int XLT_API xlt_get_info_from_locked_bank(const unsigned char* data, un /** +\ingroup xlt_adv Virginize (reset) a demo XLight device. -\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_MAX -1. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark this function may be useful for testing allowing to completely cleanup a DEMO device, that is it doesn't work onto standard devices. A demo device is distinguished by standard ones by its serial number: it is set to the value '1'. This function may be useful especially while testing xlt_bank_freeze() and xlt_bank_lock2() functions which on normal devices cannot be reverted. @@ -1579,6 +1787,7 @@ This function may be useful especially while testing xlt_bank_freeze() and xlt_b XLT_LINK int XLT_API xlt_virg_demo(unsigned int device); /** +\ingroup xlt_adv Cleanup the allocated memory by the XLight functions. \remark in case of dll usage it is not necessary call this function, it is already called when the dll is unloaded. On the other hand it's not harmful to call it explicitly. It is also possible call any other function after the xlt_close() is called, but in this case xlt_close() must be called again. @@ -1587,8 +1796,9 @@ It is also possible call any other function after the xlt_close() is called, but XLT_LINK void XLT_API xlt_close(); /** +\ingroup xlt_adv Initialize the environment for XLight management. -\return returns ::XLT_ERROR_SUCCESS on success, an \ref Errors "error code" on failure. +\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure. \remark It is not necessary to call this function unless the running process is using multi-threading. In this case it is necessary call this (or any other function accessing the device) function before starting using multi-threading. @@ -1599,52 +1809,73 @@ After the first call there is no problem in using multi-threading. */ XLT_LINK int XLT_API xlt_init(); +/** +\ingroup xlt_adv +Perform the XLight and xNodus environment initialization to allow the reference of an xNodus device on the logical device index ::XLT_DEVICE_EXT_MAX - 1. +See \ref xnd_orig_prog for a usage example. +\param[in] addr_port a pointer to the null terminated name of the host to resolve and the port expressed as \
.\+This is the documentation of the \ref xnodus_api and \ref xltapi_old "APIs" for the communication between the host computer and the xNodus or XLight device. + +
+The libraries are supplied in dll and obj format. +- Dlls: xnodus32.dll (32 bit) xnodus.dll (AMD 64 bit) are usable by any application which can be interfaced with DLLs. +- OBJs: xnodus.obj, (32 and 64 bit) can be integrated into "Microsoft Visual Studio 2008" C, C++ projects. +
+The interfaces supplied by the libraries (both dll and obj) are declered inside the file xnd.h and xlt.h and this documentation describes such interfaces. + +
+The documentation is divided into the following sections:
+- \subpage xnodus_doc
+- \subpage xn_xlight_library
+- \subpage xlt_library "The old XLight APIs documentation (use deprecated)"
+*/
+
+
+#ifndef XND_H_1239854890
+#define XND_H_1239854890
+
+#include "xlt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef OXY_LONG
+#ifdef __LP64__ //MAC
+#define OXY_LONG int
+#else //__LP64__
+#define OXY_LONG long
+#endif //__LP64__
+#endif //OXY_LONG
+
+
+//\cond NOT_COMMENTED
+#define XND_LINK XLT_LINK
+#define XND_API XLT_API
+
+#ifndef OPT
+#define OPT
+#endif
+
+#ifndef OUT
+#define OUT
+#endif
+
+#ifndef INOUT
+#define INOUT
+#endif
+//\endcond
+
+
+/** \defgroup xnodus_errors_misc xNodus miscellaneous errors
+\ingroup xnodus_errors
+Generic xNodus errors
+@{
+*/
+#define XND_ERROR_SUCCESS XLT_ERROR_SUCCESS ///< the operation was successfully completed (alias for the ::XLT_ERROR_SUCCESS value)
+#define XND_ERROR_NOT_FOUND XLT_ERROR_NOT_FOUND ///< Device not found.
+#define XND_ERROR_INVALID_ARGUMENT XLT_ERROR_INVALID_ARGUMENT ///< Function called with an invalid argument.
+#define XND_ERROR_INVALID_STATE XLT_ERROR_INVALID_STATE ///< Invalid state of the device for the required operation.
+#define XND_ERROR_TRANSMIT XLT_ERROR_TRANSMIT ///< USB communication error.
+#define XND_ERROR_RESOURCE XLT_ERROR_RESOURCE ///< Resource error (usually not enough memory).
+
+
+#define XND_RELEASE_STILL_REFERENCED 1 ///< this is not a real error: returned by the release functions to indicate that the released object is still alive (used by other part of the program)
+
+#define XND_ERROR_FIND_NO_MORE_DEVICES -2000 ///< returned by xnd_device_find_next(), it indicates that there is no more xNodus device to enumerate and that the search process can be terminated
+#define XND_ERROR_FIND_NOT_FOUND_YET -2001 ///< returned by xnd_device_find_next(), it indicates that the search process is still running but at present no further xNodus devices are found
+
+//@} //xnodus_errors_misc
+
+/** \defgroup xnodus_errors_authentication xNodus Authentication errors
+\ingroup xnodus_errors
+Errors that may occurr during a session opening (xnd_xlt_session_open())
+ @{
+*/
+#define XND_ERROR_AU_AUTH_USER_NOT_FOUND -2040 ///< the User doesn't exist
+#define XND_ERROR_AU_AUTH_PROTOCOL_ERROR -2041 ///< generic protocol error
+#define XND_ERROR_AU_SESSION_TEMPORARY_UNAVAILABLE -2042 ///< retry to call the method in a while
+#define XND_ERROR_AU_SESSION_NOT_FOUND -2043 ///< an expeceted session is not (or no longer) existing
+#define XND_ERROR_AU_SESSION_SRV_ERROR -2044 ///< a session is already running
+#define XND_ERROR_AU_SESSION_INVALID_KEY -2045 ///< the cryptographic key is not valid
+#define XND_ERROR_AU_SESSION_ALREADY_RUNNING -2046 ///< a session is already running
+#define XND_ERROR_AU_AUTH_XNODUS_SERIAL_NOT_FOUND -2047 ///< The AuthUser doesn't exist
+#define XND_ERROR_AU_MISSING_KEY -2048 ///< a required cryptographic key is missing
+//@} //xnodus_errors_authentication
+
+/** \defgroup xnodus_errors_communication xNodus communication and network errors
+\ingroup xnodus_errors
+Communication error returned by the xNodus API library
+@{
+*/
+#define XND_ERROR_NET_OPEN_LL_FAILURE -2200 ///< error opening the socket connection
+#define XND_ERROR_NET_CONNECT_LL_FAILURE -2201 ///< socket connection failure
+#define XND_ERROR_NET_CONNECT_LL_TIMEOUT -2202 ///< timeout while opening the socket connection
+#define XND_ERROR_NET_SEND_FAILURE -2203 ///< transmission data to xNodus device failed
+#define XND_ERROR_NET_RECV_FAILURE -2204 ///< receiving data from xNodus device failed
+#define XND_ERROR_NET_RECV_BAD_FORMAT -2205 ///< bad format of the received data
+#define XND_ERROR_CONNECTION_ABORTED -2206 ///< socket connection aborted by the API
+#define XND_ERROR_NET_DNS_FAILURE -2210 ///< DNS resolution address failed
+#define XND_ERROR_INVALID_SUBNET_MASK -2211 ///< wrong subnet mask (this error may occur searching for xNodus device)
+#define XND_ERROR_UNKNOWN_TARGET -2212 ///< connecting to an unknown device
+//@} //xnodus_errors_communication
+
+/** \defgroup xnodus_errors_device xNodus errors returned by the device
+\ingroup xnodus_errors
+Errors returned directly by the xNodus device and passed back by the APIs
+@{
+*/
+#define XND_DEV_BASE_ERR -3000 ///< offset value for the errors returned by the device
+
+
+#define XND_ERROR_DEV_INVALID_ARGUMENT (XND_DEV_BASE_ERR -0x01) ///< invalid argument in a command #XND_DEV_BASE_ERR
+#define XND_ERROR_DEV_INVALID_COMMAND (XND_DEV_BASE_ERR -0x02) ///< invalid command for the current status of the device
+#define XND_ERROR_DEV_INVALID_COMMAND_SIGNATURE (XND_DEV_BASE_ERR -0x03) ///< corrupted command
+#define XND_ERROR_DEV_INVALID_SEQUENCE_NUMBER (XND_DEV_BASE_ERR - 0x04) ///< command reused or synchronization lost between client and device
+#define XND_ERROR_DEV_INVALID_DESTINATION (XND_DEV_BASE_ERR - 0x05) ///< an internal error (you shouldn't ever get)
+#define XND_ERROR_DEV_INVALID_KEY_TYPE (XND_DEV_BASE_ERR - 0x06) ///< wrong or non supported type of the cryptographic key used
+#define XND_ERROR_DEV_INVALID_DEVICE_STATUS (XND_DEV_BASE_ERR - 0x07) ///< status of the device invalid for the issued command
+#define XND_ERROR_DEV_RESET_IN_PROGRESS (XND_DEV_BASE_ERR - 0x08) ///< the device cannot work because it is about to be reset (this happen only during device maintenance, configuration, or firmware update)
+#define XND_ERROR_DEV_DEVICE_IS_EXPIRED (XND_DEV_BASE_ERR - 0x09) ///< the device license is expired
+#define XND_ERROR_DEV_INVALID_COMMAND_COUNTER (XND_DEV_BASE_ERR - 0x0A) ///< invalid counter value for the remote command (the passed value is not greater than the xNodus internal value returned by xnd_get_info(), structure ::XND_INFO parameter 'remote_counter')
+#define XND_ERROR_DEV_INVALID_SERIAL_NUMBER (XND_DEV_BASE_ERR - 0x0B) ///< the serial number doesn't match the expected one
+#define XND_ERROR_DEV_INVALID_XLIGHT_INSTANCE (XND_DEV_BASE_ERR - 0x0C) ///< the referenced virtual XLight on xNodus doesn't exist
+#define XND_ERROR_DEV_RSA_INTERNAL_ERROR (XND_DEV_BASE_ERR - 0x0D) ///< generic RSA internal error
+#define XND_ERROR_DEV_RSA_KEY_ABSENT (XND_DEV_BASE_ERR - 0x0E) ///< the needed RSA key is not present in the device
+#define XND_ERROR_DEV_RSA_INVALID_KEY_LEN (XND_DEV_BASE_ERR - 0x0F) ///< the cryptographic key length doesn't match the expected value
+#define XND_ERROR_AES_INVALID_KEY_LEN (XND_DEV_BASE_ERR - 0x10) ///< the cryptographic key length doesn't match the expected value
+#define XND_ERROR_AES_KEY_ABSENT (XND_DEV_BASE_ERR - 0x11) ///< the needed AES key is not present in the device
+#define XND_ERROR_DEV_INTERNAL_ERROR (XND_DEV_BASE_ERR - 0xFF) ///< generic internal error (this should never occur)
+
+
+#define XND_ERROR_DEV_USER_INVALID_TYPE (XND_DEV_BASE_ERR - 0x1003) ///< the user is not of the expected type for the function to be done
+#define XND_ERROR_DEV_USER_INVALID_XLT_INDEX (XND_DEV_BASE_ERR - 0x1004) ///< a users refer to a non existing virtual XLight device
+#define XND_ERROR_DEV_USER_NAME_ALREADY_EXIST (XND_DEV_BASE_ERR - 0x1005) ///< the user already exist (attempt to create an already existing user)
+#define XND_ERROR_DEV_USER_NO_MORE_SESSIONS_AVAILABLE (XND_DEV_BASE_ERR - 0x1006) ///< the attempt to open a session failed because the limit of the licenses for the user is reached
+#define XND_ERROR_DEV_USER_NO_SESSION_TO_CLOSE (XND_DEV_BASE_ERR - 0x1007) ///< no session of the user can be closed
+#define XND_ERROR_DEV_USER_NO_MORE_MODULES_AVAILABLE (XND_DEV_BASE_ERR - 0x1008) ///< the attempt to access to a module failed because the limit of the licenses is reached
+#define XND_ERROR_DEV_USER_EXPIRED (XND_DEV_BASE_ERR - 0x1009) ///< the session cannot be open because the user timelife is expired
+#define XND_ERROR_DEV_USER_NOT_PRESENT (XND_DEV_BASE_ERR - 0x100A) ///< the attempt to open a session failed because the user is not recognized by xNodus
+#define XND_ERROR_DEV_USER_NO_MORE_USER_AVAILABLE (XND_DEV_BASE_ERR - 0x100B) ///< it is impossible create a new user because the device already contains the maximum allowed number of user
+#define XND_ERROR_DEV_USER_INVALID_NAME (XND_DEV_BASE_ERR - 0x100C) ///< an action of the user requests a change on a different user without permission
+#define XND_ERROR_DEV_USER_ACCESS_DENIED (XND_DEV_BASE_ERR - 0x100E) ///< attempted to run a function not allowed to the current user
+#define XND_ERROR_DEV_USER_OXY_LICENSES_EXPIRED (XND_DEV_BASE_ERR - 0x1010) ///< Oxysec license period for the usage of users is expired (a renewal is necessary)
+
+#define XND_ERROR_DEV_SESSION_NO_MORE_SESSIONS_AVAILABLE (XND_DEV_BASE_ERR - 0x2001) ///< the attempt to open a session failed because the limit of the licenses is reached
+#define XND_ERROR_DEV_SESSION_INVALID_SESSION_ID (XND_DEV_BASE_ERR - 0x2004) ///< the session of the issued command doesn't exist or it is expired
+#define XND_ERROR_DEV_SESSION_INVALID_SESSION_STATUS (XND_DEV_BASE_ERR - 0x2005) ///< a command was sent when an authenticated session opening is not complete
+#define XND_ERROR_DEV_SESSION_INVALID_CHALLENGE (XND_DEV_BASE_ERR - 0x2006) ///< the authentication process failed for an invalid challenge check
+#define XND_ERROR_DEV_SESSION_INVALID_SIGNATURE (XND_DEV_BASE_ERR - 0x2007) ///< a client signature sent during authenticated session opening is wrong
+#define XND_ERROR_DEV_SESSION_TIMEOUT_EXPIRED (XND_DEV_BASE_ERR - 0x2008) ///< the session timeout is expired (the session is no longer available)
+#define XND_ERROR_DEV_SESSION_NOT_ENOUGH_LICENSES_AVAILABLE (XND_DEV_BASE_ERR - 0x2009) ///< OxySec license number reached (it is impossible assign the requested number of license because the available amount would be exceeded)
+#define XND_ERROR_DEV_SESSION_NO_MORE_SESSION_AVAILABLE (XND_DEV_BASE_ERR - 0x2012) ///< No more session can be established because the phisical limit of the device has been found
+
+#define XND_ERROR_DEV_SESSION_VK_INVALID_ALGO_TYPE (XND_DEV_BASE_ERR - 0x200A) ///< non existing algorithm id chosen for volatile key
+#define XND_ERROR_DEV_SESSION_VK_INVALID_KEY_LEN (XND_DEV_BASE_ERR - 0x200C) ///< invalid key len of a volatile key
+#define XND_ERROR_DEV_SESSION_VK_INVALID_DATA_LEN (XND_DEV_BASE_ERR - 0x200D) ///< invalid data length for encryption (it must be a multiple of 16)
+#define XND_ERROR_DEV_SESSION_VK_INVALID_HEADER_SIZE (XND_DEV_BASE_ERR - 0x200E) ///< inviled header length for GCM encryption (it must be a multiple of 16)
+#define XND_ERROR_DEV_SESSION_INVALID_CHECK_COUNTER (XND_DEV_BASE_ERR - 0x200F) ///< the counter is invalid in xnd_continue_session_check() call
+#define XN_ERROR_SESSION_VK_INVALID_SIGNATURE (XND_DEV_BASE_ERR - 0x2019) ///< the GCM of a GCM decryption is not as expected (the data are corrupted)
+
+#define XND_ERROR_DEV_MODULE_ALREADY_OPENED (XND_DEV_BASE_ERR - 0x3003) ///< the module is already open (and cannot be open again)
+#define XND_ERROR_DEV_MODULE_INVALID_INDEX (XND_DEV_BASE_ERR - 0x3004) ///< non existing module referred
+#define XND_ERROR_DEV_MODULE_NO_FREE_MODULE (XND_DEV_BASE_ERR - 0x3005) ///< no more license available for the module
+#define XND_ERROR_DEV_MODULE_EXPIRED (XND_DEV_BASE_ERR - 0x3007) ///< the license time of the module is expired
+
+#define XND_ERROR_DEV_LICENSE_MULTI_INSTANCE_INTERNAL_ERROR (XND_DEV_BASE_ERR - 0x2010) ///< an internal error occurred running a multi-instance session (see \ref xnd_users_group_lic)
+#define XND_ERROR_DEV_LICENSE_MULTI_INSTANCE_NO_SESSION_TO_CLOSE (XND_DEV_BASE_ERR - 0x2011) ///< there is no actual session to close in a multi-instance session management (see \ref xnd_users_group_lic)
+#define XND_ERROR_DEV_LICENSE_MULTI_INSTANCE_INVALID_CLIENT (XND_DEV_BASE_ERR - 0x2014) ///< the connected client is invalid
+#define XND_ERROR_DEV_LICENSE_MULTI_INSTANCE_INVALID_RND (XND_DEV_BASE_ERR - 0x2015) ///< instance protocol error
+#define XND_ERROR_DEV_LICENSE_MULTI_INSTANCE_NO_SESSION_AVAILABLE (XND_DEV_BASE_ERR - 0x2016) ///< Can't open a new instance, the computer has reached the maximum number of instances allowed
+#define XND_ERROR_DEV_LICENSE_LICENSE_INVALID_INSTANCE_QUANTITY (XND_DEV_BASE_ERR - 0x2017) ///< the configured number of instance exceed the allowed limit (64 instances)
+
+#define XND_ERROR_LICENSE_LOG_END (XND_DEV_BASE_ERR - 0x2018) ///< the log list is completed
+
+//#define XND_ERROR_MODULE_INTERNAL_ERROR (XND_DEV_BASE_ERR - 0x30FF) // internal
+
+//@} //xnodus_errors_device
+
+
+
+/**
+\defgroup xnd_RSA_const xNodus RSA size constant
+\ingroup xnodus_defines
+
+These are the constants for the various size of the RSA key managed by xNodus APIs that
+extend the XLight definitions
+
+@{
+*/
+#define XND_RSA_2048_BIT_SIZE 2048 ///< number of bits of the public modulus of a 2048 bit RSA key
+#define XND_RSA_2048_PUB_KEY_SIZE 260 ///
+Warning! This function can be executed only once! All the subsequent calls will fail.
+\note This function produces an irreversible setting onto the XLight device, hence use it very carefully.
+
+
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] label points to a buffer of length ::XLT_LABEL_SIZE. It contains the label, that is the identification name to be assigned to the device.
+\param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE. It contains the password to be assigned to the device.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains Dongle Key: the AES-256 key that will be used, for instance, by the functions xnd_xlt_session_wrap_key() and xnd_xlt_rsa_wrap_privkey().
+\param[in] cr_key points to a buffer of length ::XLT_KEY_SIZE. It contains an AES-256 key (Challenge Key) that will be used by the function xnd_xlt_challenge().
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark password, dongle_key (the Dongle Key) and cr_key (the Challenge Response Key or shortly Challenge Key) are optional arguments and they can be set to 0 (NULL).
+Whenever one of these entry is null it is considered as if it was an array of bytes filled with the value 0xFF (255 decimal). In other word, passing NULL is equivalent of passing a 0xFF bytes array.
+\note though password, Dongle Key and Challenge Key are optional, it is strongly recommended to set them with non trivial values
+to forbid memory access (using password) to unauthorized application, and to allow the protected application to make sure of the presence of the XLight device with cryptography
+that uses Dongle Key as the base to wrap the \ref xn_RSA_Protection "RSA" and \ref xn_AES_Session_Key "AES session" keys which constitutes the key point of the software protection.
+
+\parblock
+\note before calling xnd_xlt_setup() a device is in a non initialized state. In this context only the function xnd_xlt_getinfo() works.
+\endparblock
+\parblock
+\note Never put Dongle Key inside the protected application. This is a key on which many security features are based on, inserting it inside the
+protected application may yield fundamental information to hackers for emulating the XLight device also in its more advanced feaures.
+\endparblock
+\parblock
+\note Never put xnd_xlt_setup() inside the protected application as well: this function can be called from some initialization code used in
+safe environment. If you don't need to manage special setup procedure you can avoid to use this function and rely on the utilities supplied by OxySec.
+\endparblock
+
+\par Example
+In the code below the function GetFirstXLightDeviceContext() comes from \ref GetFirstXLightDeviceContext "this example".
+\code
+#include Supported version: this function is available on XLight devices version 1.01 or later.
+\see xnd_xlt_set_write_locked2_group_check(), xnd_xlt_set_write_locked2_serial_check()
+*/
+XND_LINK int XND_API xnd_xlt_bank_lock2(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* password, unsigned int bank, unsigned int group_number);
+
+/**
+\ingroup xnd_xlt_bank
+Freeze a given memory bank. After freezing it won't be possible write inside the given bank any longer.
+
+\note This function produces an irreversible setting onto the XLight device, hence use it very carefully.
+
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE that contains the password assigned to the device.
+\param[in] bank the index of the memory bank that must be frozen.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\remark The password entry must be the same that was used in xnd_xlt_setup() call. If it was NULL, it must be NULL also in xnd_xlt_bank_freeze().
+
+\par Example
+In the code below the function GetFirstXLightDeviceContext() comes from \ref GetFirstXLightDeviceContext "this example".
+\code{.c}
+void xlight_freeze_example()
+{
+ int status;
+ unsigned char password[XLT_PASSWORD_SIZE];
+ XND_XLT_ENV env = xnd_xlt_env_create();
+ XND_DEVICE_CONTEXT dev_ctx = 0;
+
+ //GetFirstXLightDeviceContext() comes from an example of the XNodus documentation
+ dev_ctx = GetFirstXLightDeviceContext(env);
+ if (!dev_ctx){
+ printf("An error occurred (probably no XLight device was found");
+ goto end;
+ }
+
+ strcpy((char*)password, "My XLight password");
+ memset(password + strlen("My XLight password"), 0x00, sizeof(password) - strlen("My XLight password"));
+
+ //freeze the bank 0 of an XLight dongle
+ //BEWARE: after the freeze the memory content of the bank 0 can't be modified any longer
+ status = xnd_xlt_bank_freeze(dev_ctx, password, 0);
+ if (status != XLT_ERROR_SUCCESS){
+ printf("An error has occurred.\n");
+ if (status == XLT_ERROR_FROZEN){
+ printf("The device was already frozen.\n");
+ }
+ }
+
+end:
+ xnd_xlt_devctx_release(dev_ctx);
+ xnd_xlt_env_free(env);
+}
+\endcode
+
+*/
+XND_LINK int XND_API xnd_xlt_bank_freeze(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* password, unsigned int bank);
+
+/**
+\deprecated
+This function is deprecated because substituted by the more effective \ref xn_AES_Session_Key "session encryption".
+
+Perform AES-256 encryption
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+ \param[in] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the plaintext to encrypt.
+ \param[out] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE receiving the encrypted result.
+ \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+ \note The encryption function uses as cryptographic key the Dongle Key entry set by xnd_xlt_setup().
+ \note We strongly recommend never to put Dongle Key in the protected application. Use Dongle Key to encrypt data, but not
+ for authentication processes as discussed in xnd_xlt_challenge() documentation.
+*/
+XND_LINK int XND_API xnd_xlt_encrypt(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* plaintext, unsigned char* ciphertext);
+
+/**
+\deprecated
+This function is deprecated because substituted by the more effective \ref xn_AES_Session_Key "session encryption".
+
+Perform AES-256 decryption.
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+ \param[in] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the ciphertext to be decrypted.
+ \param[out] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the result of the decryption.
+ \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+ \remark This function is the inverse of xnd_xlt_encrypt(), that is from ciphertext it returns the original plaintext passed to xnd_xlt_encrypt().
+ \note The decryption function uses as cryptographic key the Dongle Key entry set by xnd_xlt_setup().
+*/
+XND_LINK int XND_API xnd_xlt_decrypt(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* ciphertext, unsigned char* plaintext);
+
+/**
+\deprecated
+This function is deprecated because substituted by the more effective \ref xn_AES_Session_Key "session encryption".
+
+Challenge-Response computation based on AES-256.
+The protected software send a value and check that the outcome is as expected.
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+ \param[in] challenge points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the challenge data.
+ \param[out] response points to the buffer of length ::XLT_CIPHERTEXT_SIZE receiving the response.
+ \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+ \note The Challenge-Response mechanism uses as cryptographic key the cr_key (Challenge Response Key) entry set by xnd_xlt_setup().
+ \remark The challenge response mechanism is a sort of proof of identity without exposing details to eavesdroppers on the USB communication or
+ on the dll interface. It is based onto the AES-256 encryption and the verifier inside the protected program must know the key used by the
+ device. A good hacker debugging the code can come up to the encryption key, so the best policy is to make this task hard trying to hide
+ the key: for instance preparing the challenge and evaluating the response far from the code communicating with the dongle. The example below is not a good
+ example from this point of view and it must be considered just as an example. xnd_xlt_challenge() works in the same way of xnd_xlt_encrypt() but using a different AES key.
+
+ \note Another possible and better way is to calculate many pairs challenge-presponse in a safe environment (i.e. not in the protected application)
+ and use such pairs to verify the response of the dongle. This method avoid the exposure of the Challenge Response Key.
+*/
+XND_LINK int XND_API xnd_xlt_challenge(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* challenge, unsigned char* response);
+
+/**
+\ingroup xnd_xlt_aes
+Load on an XLight device the session AES key to be used for AES session encryption functions.
+See \ref xn_AES_Session_Key for an introduction on Session Key protection.
+
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+ \param[in] key_index index of the key to be used. This value runs from 0 to ::XLT_SESSION_NUMBER_OF_KEYS -1.
+ \param[in] wrapped_key points to the buffer of length ::XLT_KEY_SIZE containing the Session Key encrypted with Dongle Key.
+ \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+ This function must be used to set the AES key that will be used by xnd_xlt_session_encrypt() and xnd_xlt_session_decrypt(). This cryptographic key
+ must be passed in encrypted (wrapped) form depending on the Dongle Key. In oreder to produce the wrapped form of the Session Key use xnd_xlt_session_wrap_key().
+ It is possible to set ::XLT_SESSION_NUMBER_OF_KEYS sessin key simultaneously, with key_index it is possible to refer to one of these keys.
+
+ \note a Session Key is not permanent, it resides on the device as long as the dongle is plugged and powered, once the dongle is
+ removed the key is deleted. This means that it must be loaded every time it must be used. The default value, that is just after the device is plugged,
+ is a zero buffer.
+See \ref xn_Session_KeyProtection "here" for a source code example using this function.
+ Supported version: this function is available on XLight devices version 2.0 or later.
+\see xnd_xlt_session_encrypt(), xnd_xlt_session_decrypt(), xnd_xlt_session_wrap_key().
+*/
+XND_LINK int XND_API xnd_xlt_session_set_key(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_index, const unsigned char* wrapped_key);
+
+/**
+\ingroup xnd_xlt_aes
+Encrypt data using a Session Key.
+See \ref xn_AES_Session_Key for an introduction on Session Key protection.
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+ \param[in] key_index index of the key to be used. This value runs from 0 to ::XLT_SESSION_NUMBER_OF_KEYS -1.
+ \param[in] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the data to be encrypted
+ \param[out] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE that will receive the encrypted data.
+ \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+ This function performs AES-256 encryption of a plaintext of length ::XLT_CIPHERTEXT_SIZE and inserts the ciphertext result in a buffer of the same length.
+ The AES key is one of the eight Session Keys specified by the index key_index, and the corrisponding key was previously set by the xnd_xlt_session_decrypt() function.
+
+ See \ref xn_Session_KeyProtection "here" for a source code example using this function.
+ Supported version: this function is available on XLight devices version 2.0 or later.
+ \see xnd_xlt_session_decrypt(), xnd_xlt_session_set_key(), xnd_xlt_session_wrap_key().
+*/
+XND_LINK int XND_API xnd_xlt_session_encrypt(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_index, const unsigned char* plaintext, unsigned char* ciphertext);
+
+/**
+\ingroup xnd_xlt_aes
+Decrypt data using a Session Key.
+See \ref xn_AES_Session_Key for an introduction on Session Key protection.
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+ \param[in] key_index index of the key to be used. This value runs from 0 to ::XLT_SESSION_NUMBER_OF_KEYS -1.
+ \param[in] ciphertext points to the buffer of length ::XLT_CIPHERTEXT_SIZE containing the data to be decrypted.
+ \param[out] plaintext points to the buffer of length ::XLT_CIPHERTEXT_SIZE that will receive the decrypted data.
+ \return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+ This function performs AES-256 decryption of a ciphertext buffer with length of the block of the AES algorithm, that is a length of ::XLT_CIPHERTEXT_SIZE.
+ The used key was set by a previous call of xnd_xlt_session_set_key().
+ Supported version: this function is available on XLight devices version 2.0 or later.
+ \see xnd_xlt_session_encrypt(), xnd_xlt_session_set_key(), xnd_xlt_session_wrap_key().
+*/
+XND_LINK int XND_API xnd_xlt_session_decrypt(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_index, const unsigned char* ciphertext, unsigned char* plaintext);
+
+/**
+\ingroup xnd_xlt_aes
+Wraps a Session Key.
+See \ref xn_AES_Session_Key for an introduction on Session Key protection.
+ \param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+ \param[in] key points to the AES key that will be used by xnd_xlt_session_encrypt() and xnd_xlt_session_decrypt(). It's length is of ::XLT_KEY_SIZE bytes.
+ \param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+ \param[out] wrapped_key points to a memory buffer of length ::XLT_KEY_SIZE that will receive the wrapped version of key.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\note Never use this function onto the protected software, in particular, never insert the Dongle Key into the protected software.
+This is an utility software to compute the wrapped version of a Session Key and must be done in an utility software not distributed to the
+final user. The Wrapped Key must be used onto the protected software and loaded onto the XLight dongle using xnd_xlt_session_set_key().
+
+See \ref xn_Session_KeyPreliminary "here" for a source code example using this function.
+
+ Supported version: this function is available on XLight devices version 2.0 or later.
+
+\sa xnd_xlt_session_set_key().
+*/
+XND_LINK int XND_API xnd_xlt_session_wrap_key(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* key, const unsigned char* dongle_key, unsigned char* wrapped_key);
+
+/**
+\ingroup xnd_xlt_rsa
+Generate an RSA key.
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] bit_size the length in bit of the key to generate. The possible values are ::XLT_RSA_512_BIT_SIZE and ::XLT_RSA_1024_BIT_SIZE.
+\param[out] private_key points to the buffer that will receive the generated RSA private key formatted with XLight RSA Key format (\ref xn_RSA_format).
+\param[in] private_key_size size of the private_key buffer. The size for a 1024 bit key is ::XLT_RSA_1024_PRIV_KEY_SIZE and the size for a 512 bit key is ::XLT_RSA_512_PRIV_KEY_SIZE.
+\param[out] p_private_key_len points to an unsigned integer that will receive the actual length of the generated formatted private key.
+\param[out] public_key points to the buffer that will receive the generated RSA public key formatted in XLight RSA Key format (\ref xn_RSA_format).
+If this parameter is NULL the public key is not retrieved.
+\param[in] public_key_size size of the public_key buffer. The size for a 1024 bit key is ::XLT_RSA_1024_PUB_KEY_SIZE and the size for a 512 bit key is ::XLT_RSA_512_PUB_KEY_SIZE.
+\param[out] p_public_key_len points to an unsigned integer that will receive the actual length of the generated formatted public key.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\note This is an utility function that must be never used onto the protected software. Its purpose is RSA key generation and may be substituted
+by other software doing the same task. There are plenty of source code available in internet doing RSA key generation.
+ Supported version: this function is available on XLight devices version 2.0 or later.
+\sa xnd_xlt_rsa_wrap_privkey().
+*/
+XND_LINK int XND_API xnd_xlt_rsa_generate_key(XND_DEVICE_CONTEXT dev_ctx, unsigned int bit_size, unsigned char* private_key, unsigned int private_key_size, unsigned int* p_private_key_len, unsigned char* public_key, unsigned int public_key_size, unsigned int* p_public_key_len);
+
+/**
+\ingroup xnd_xlt_rsa
+Wraps an RSA key.
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] private_key points to a buffer containing a formatted private key.
+\param[in] private_key_length length of the RSA formatted key (\ref xn_RSA_format).
+\param[in] dongle_key points to a buffer containing Dongle Key.
+\param[out] wrapped_key points to the buffer that will receive an encryption of the RSA private key (wrapped).
+\param[in] wrapped_key_len the length of Wrapped Key pointed by wrapped_key. The length of a Wrapped Key must be ::XLT_RSA_1024_WRAPPED_KEY_SIZE for a 1024-bit key and ::XLT_RSA_512_WRAPPED_KEY_SIZE for a 512-bit key.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\note This is an utility function that must be never used onto the protected software. Its purpose is to encrypt an RSA private key for protecting its
+content. The produced Wrapped Key may reside into a protected software or exposed to the public access without revealing its real content.
+In order to insert a private key onto the device the Wrapped Key must be passed to the function xnd_xlt_rsa_set_privkey().
+\sa xnd_xlt_rsa_set_privkey()
+*/
+XND_LINK int XND_API xnd_xlt_rsa_wrap_privkey(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* private_key, unsigned int private_key_length, const unsigned char* dongle_key, unsigned char* wrapped_key, unsigned int wrapped_key_len);
+
+/**
+\ingroup xnd_xlt_rsa
+Wraps an RSA key.
+As xnd_xlt_rsa_wrap_privkey() function but with the addition to bind a specific recipient XLight device by its serial number.
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] private_key points to a buffer containing a formatted private key.
+\param[in] private_key_length length of the RSA formatted key (\ref xn_RSA_format).
+\param[in] dongle_key points to a buffer containing Dongle Key.
+\param[in] sn the serial number of the destination XLight device.
+\param[out] wrapped_key points to the buffer that will receive an encryption of the RSA private key (wrapped).
+\param[in] wrapped_key_len the length of Wrapped Key pointed by wrapped_key. The length of a Wrapped Key must be ::XLT_RSA_1024_WRAPPED_KEY_SIZE for a 1024-bit key and ::XLT_RSA_512_WRAPPED_KEY_SIZE for a 512-bit key.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\note This is an utility function that must be never used onto the protected software. Its purpose is to encrypt an RSA private key for protecting its
+content. The produced Wrapped Key may reside into a protected software or exposed to the public access without revealing its real content.
+In order to insert a private key onto the device the Wrapped Key must be passed to the function xnd_xlt_rsa_set_privkey().
+
+ Supported version: this function is available on XLight devices version 2.4 or later.
+\sa xnd_xlt_rsa_wrap_privkey()
+*/
+XND_LINK int XND_API xnd_xlt_rsa_wrap_privkey_sn(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* private_key, unsigned int private_key_length, const unsigned char* dongle_key, unsigned int sn, unsigned char* wrapped_key, unsigned int wrapped_key_len);
+
+/**
+\ingroup xnd_xlt_rsa
+Load an RSA private key onto an XLight device.
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] wrapped_key points to the buffer containing the wrapped RSA key to be inserted into ther XLight device.
+\param[in] wrapped_key_length the length of the Wrapped Key data.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\note on an XLight device it is possible to store two RSA keys: one 1024 bit key and one 512 bit key. The bit length reppresent the length of its
+"modulus", not the length of the data containing the key (see \ref RSA_format). The device recognizes the two different key types and write them in their reserved memory place.
+
+The RSA key received from this function is not in clear form, but encrypted by the function xnd_xlt_rsa_wrap_privkey().
+In this way the RSA private key can be set by the protected program without exposing any relevant data, and hence preventing a hacker to understand the values (which would ruin all the security protocol based on RSA).
+
+\note an RSA key is present onto the device also after device removal because it is written in a non volatile memory,
+nevertheless it can be always overwritten with a new one.
+ Supported version: this function is available on XLight devices version 2.0 or later.
+\see xnd_xlt_rsa_wrap_privkey().
+*/
+XND_LINK int XND_API xnd_xlt_rsa_set_privkey(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* wrapped_key, unsigned int wrapped_key_length);
+
+/**
+\ingroup xnd_xlt_rsa
+Performs RSA encryption.
+\deprecated just use for test purpose
+
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] public_key points to the buffer containing the formatted public key used for the encryption.
+\param[in] public_key_len length of the formatted public key. The allowed values are ::XLT_RSA_1024_PUB_KEY_SIZE and ::XLT_RSA_512_PUB_KEY_SIZE.
+\param[in] plaintext points to the buffer containing the data to be encrypted.
+\param[in] plaintext_ciphertext_length the length of plaintext and the size of the buffer pointed by ciphertext.
+The allowed values for this argument are ::XLT_RSA_1024_PLAINTEXT_SIZE and ::XLT_RSA_512_PLAINTEXT_SIZE, if the plaintext is shorter it must be
+copied into a buffer of the proper length and zero padded up to its overall length.
+\param[out] ciphertext points to the buffer that will receive the result of the encryption.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\note This function is present for test purpose, never use it in the application protected with XLight.
+*/
+XND_LINK int XND_API xnd_xlt_never_use_this_rsa_encrypt(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* public_key, unsigned int public_key_len, const unsigned char* plaintext, unsigned int plaintext_ciphertext_length, unsigned char* ciphertext);
+
+/**
+\ingroup xnd_xlt_rsa
+Performs a software RSA decryption.
+\deprecated just use for test purpose
+
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] private_key points to a buffer containing the formatted private RSA key to be used.
+\param[in] private_key_len length of the formatted private key. The allowed values are ::XLT_RSA_1024_PRIV_KEY_SIZE and ::XLT_RSA_512_PRIV_KEY_SIZE.
+\param[in] ciphertext points to the buffer containing the data to be decrypted.
+\param[in] ciphertext_plaintext_length the length of the data to be decrypted, and the size of the receiving buffer.
+The allowed values for this argument are ::XLT_RSA_1024_PLAINTEXT_SIZE and ::XLT_RSA_512_PLAINTEXT_SIZE, if the plaintext is shorter it must be
+copied into a buffer of the proper length and zero padded up to its overall length.
+\param[out] plaintext points to the buffer that will receive the result of the decryption.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+*/
+XND_LINK int XND_API xnd_xlt_never_use_this_rsa_sw_decrypt(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* private_key, unsigned int private_key_len, const unsigned char* ciphertext, unsigned int ciphertext_plaintext_length, unsigned char* plaintext);
+
+/**
+\ingroup xnd_xlt_rsa
+Runs an RSA decryption onto an XLight device.
+See \ref xn_RSA_Protection for an introduction on the RSA protection in XLight.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] ciphertext points to the buffer containing the data to be decrypted.
+\param[in] ciphertext_plaintext_length the length of the data to be decrypted, and the size of the receiving buffer.
+The allowed values for this argument are ::XLT_RSA_1024_PLAINTEXT_SIZE and ::XLT_RSA_512_PLAINTEXT_SIZE, if the plaintext is shorter it must be
+copied into a buffer of the proper length and zero padded up to its overall length (see \ref xn_RSA_format).
+\param[out] plaintext points to the buffer that will receive the result of the decryption.
+\return ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\note The length of the ciphertext buffer must be the same of the plaintext. If the length is ::XLT_RSA_1024_PLAINTEXT_SIZE the 1024-bit key is used,
+if the length is ::XLT_RSA_512_PLAINTEXT_SIZE the 512-bit key is used, for any other value an error is returned.
+ Supported version: this function is available on XLight devices version 2.0 or later.
+*/
+XND_LINK int XND_API xnd_xlt_rsa_decrypt(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* ciphertext, unsigned int ciphertext_plaintext_length, unsigned char* plaintext);
+
+/**
+\ingroup xnd_xlt_bank
+Perform a write operation in a locked bank (both normal and advanced Lock2 mode).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] bank the index of the memory bank that must be written.
+\param[in] data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA containing the values computed by xnd_xlt_set_write_locked_serial_check() or
+xlt_set_write_locked_group_check().
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\sa xnd_xlt_set_write_locked2_serial_check(), xnd_xlt_set_write_locked2_group_check().
+*/
+XND_LINK int XND_API xnd_xlt_write_locked(XND_DEVICE_CONTEXT dev_ctx, unsigned int bank, const unsigned char* data);
+
+/**
+\ingroup xnd_xlt_bank
+Perform a read operation in a locked bank (both normal and advanced Lock2 mode).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] bank the index of the memory bank that must be read.
+\param[out] data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the content of the memory bank in encrypted form.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\remark in order to get the data in plain form the function xnd_xlt_decrypt_locked2_data() must be used.
+\note a locked bank can always be read using the xnd_xlt_read() function, while this function doesn't need the use
+of password, but its outcome can't be used as is, because it needs decryption.
+
+A locked memory bank is subjected to a restriction in its dimension: only ::XLT_LOCKED_BANK_DATA_LENGTH will be freely available for reading and writing.
+The remaining bytes are used by the locking mechanism management.
+\sa xnd_xlt_decrypt_locked2_data().
+*/
+XND_LINK int XND_API xnd_xlt_read_locked(XND_DEVICE_CONTEXT dev_ctx, unsigned int bank, unsigned char* data);
+
+/**
+\ingroup xnd_xlt_bank
+Encrypt the buffer to be written into a locked bank of a specific XLight device.
+This data can be written only once and only in the device with a given serial number, provided that the destination bank is locked (see xnd_xlt_bank_lock2()).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] data points to a buffer of length ::XLT_LOCKED_BANK_DATA_LENGTH, that contains the value that must be written onto a locked bank.
+\param[in] bank specify the index of the memory bank that must written.
+\param[in] new_counter new counter value: this value must be greater than the counter value currently contained into the locked bank.
+\param[in] serial the serial number of the XLight device target.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains the AES-256 key Dongle Key set during xnd_xlt_getinfo() call.
+\param[out] encryted_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be
+applied onto the XLight device via the xnd_xlt_write_locked() function.
+to the XLight device with the xnd_xlt_write() function in order to write data into a locked bank.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark This function is to be considered as an utility not to be used diretly by the protected software.
+It can be used by the vendor of the protected software in order to remotely update the locked memory of a device.
+In this scenario the Dongle Key key must never be used onto the protected software, but used only to generate update for the device memory.
+This way it is possible to remotely update the content of a locked bank. A locked bank can be read normally by a protected application using xnd_xlt_read(), so
+this remote update technique can be used, for instance, for license management purposes.
+\sa xnd_xlt_set_write_locked_group_check(), xnd_xlt_write_locked(), xnd_xlt_read_locked(), xnd_xlt_decrypt_locked_data().
+*/
+XND_LINK int XND_API xnd_xlt_set_write_locked_serial_check(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int serial, const unsigned char* dongle_key , unsigned char* encryted_data);
+
+/**
+\ingroup xnd_xlt_bank
+Encrypt the buffer to be written into a locked bank belonging to an XLight devices of a given group.
+This data can be written only once provided that the destination bank is locked (see xnd_xlt_bank_lock()).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] data points to a buffer of length ::XLT_LOCKED_BANK_DATA_LENGTH, that contains the value that must be written into the locked bank.
+\param[in] bank specify the index of the memory bank that must written.
+\param[in] new_counter new counter value: this value must be greater than the counter value currently contained into the locked bank.
+\param[in] group_number the group number of the XLight devices for which the encrypted buffer is prepared.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains the AES-256 key Dongle Key set during xnd_xlt_getinfo() call.
+\param[out] encryted_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be
+applied onto the XLight device via the xnd_xlt_write_locked() function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark The group number correspond to what is set on the dongle by xnd_xlt_bank_lock().
+It is intended to define subgroups of devices each of them must be treated in the same way.
+For further notices see the comments of xnd_xlt_set_write_locked_serial_check(), they hold also for this function.
+*/
+XND_LINK int XND_API xnd_xlt_set_write_locked_group_check(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int group_number, const unsigned char* dongle_key, unsigned char* encryted_data);
+
+/**
+\ingroup xnd_xlt_bank
+Encrypt the buffer to be written into a bank locked with Lock2 of a specific XLight device.
+This data can be written only once and only in the device with a given serial number, provided that the destination bank is locked (see xnd_xlt_bank_lock2()).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] data points to a buffer of length ::XLT_LOCKED_BANK_DATA_LENGTH, that contains the value that must be written onto a locked bank.
+\param[in] bank specify the index of the memory bank that must written.
+\param[in] new_counter new counter value: this value must be greater than the counter value currently contained into the locked bank.
+\param[in] serial the serial number of the XLight device target.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains the AES-256 key Dongle Key set during xnd_xlt_getinfo() call.
+\param[out] encryted_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be
+applied onto the XLight device via the xnd_xlt_write_locked() function.
+to the XLight device with the xnd_xlt_write() function in order to write data into a locked bank.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark This function is to be considered as an utility not to be used diretly by the protected software.
+It can be used by the vendor of the protected software in order to remotely update the locked memory of a device.
+In this scenario the Dongle Key key must never be used onto the protected software, but used only to generate update for the device memory.
+This way it is possible to remotely update the content of a locked bank. A locked bank can be read normally by a protected application using xnd_xlt_read(), so
+this remote update technique can be used, for instance, for license management purposes.
+ Supported version: this function is available on XLight devices version 1.01 or later.
+\see xnd_xlt_set_write_locked2_group_check(), xnd_xlt_write_locked(), xnd_xlt_read_locked(), xnd_xlt_decrypt_locked2_data().
+*/
+XND_LINK int XND_API xnd_xlt_set_write_locked2_serial_check(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int serial, const unsigned char* dongle_key , unsigned char* encryted_data);
+
+/**
+\ingroup xnd_xlt_bank
+Encrypt the buffer to be written into a bank locked with Lock2 belonging to an XLight devices of a given group.
+This data can be written only once provided that the destination bank is locked (see xnd_xlt_bank_lock2()).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] data points to a buffer of length ::XLT_LOCKED_BANK_DATA_LENGTH, that contains the value that must be written into the locked bank.
+\param[in] bank specify the index of the memory bank that must written.
+\param[in] new_counter new counter value: this value must be greater than the counter value currently contained into the locked bank.
+\param[in] group_number the group number of the XLight devices for which the encrypted buffer is prepared.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE. It contains the AES-256 key Dongle Key set during xnd_xlt_getinfo() call.
+\param[out] encryted_data points to a buffer of size ::XLT_LOCKED_TRANSFER_DATA that will receive the encrypted write command that will be
+applied onto the XLight device via the xnd_xlt_write_locked() function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark The group number correspond to what is set on the dongle by xnd_xlt_bank_lock2().
+It is intended to define subgroups of devices each of them must be treated in the same way.
+For further notices see the comments of xnd_xlt_set_write_locked_serial_check(), they hold also for this function.
+ Supported version: this function is available on XLight devices version 1.01 or later.
+*/
+XND_LINK int XND_API xnd_xlt_set_write_locked2_group_check(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* data, unsigned int bank, unsigned int new_counter, unsigned int group_number, const unsigned char* dongle_key, unsigned char* encryted_data);
+
+/**
+\ingroup xnd_xlt_bank
+Retrieve the data in clear form of the content of a locked memory bank.
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] encrypted_data points to a buffer of length ::XLT_LOCKED_TRANSFER_DATA.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE containing the dangle_key key set by xnd_xlt_setup().
+\param[out] data points to a buffer of length ::XLT_BANK_SIZE that will receice the decrypted value.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark xnd_xlt_decrypt_locked_data() retrieves the data in clear form of the content of a memory bank collected with a previous xnd_xlt_read_locked() call.
+xnd_xlt_decrypt_locked_data() and xnd_xlt_read_locked() are used in a server client memory bank read operation. The xnd_xlt_read_locked() doesn't need of any password
+and cryptographic key to be used but produces an encrypted buffer that can be understood only by the holder of the Dongle Key crypto-key.
+xnd_xlt_read_locked() can be executed by non trusted people to collect information. Afterwards xnd_xlt_decrypt_locked_data() allows the authorized parts to decrypt
+and read the content of the memory bank.
+
+The buffer returned by xnd_xlt_decrypt_locked_data() is ::XLT_KEY_SIZE bytes long, but only the first ::XLT_LOCKED_BANK_DATA_LENGTH bytes are the significant data
+that can be written and used by the application. The remaining bytes are managed internally by the library and used for the 'locked bank' management.
+These bytes convey information that may be retrieved using xnd_xlt_get_info_from_locked_bank(), such information are necessary for writing inside a locked bank.
+\sa xnd_xlt_read_locked(), xnd_xlt_get_info_from_locked_bank()
+
+*/
+XND_LINK int XND_API xnd_xlt_decrypt_locked_data(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* encrypted_data, const unsigned char* dongle_key, unsigned char* data);
+
+/**
+\ingroup xnd_xlt_bank
+Retrieve the data in clear form of the content of a locked with Lock2 memory bank.
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] encrypted_data points to a buffer of length ::XLT_LOCKED_TRANSFER_DATA.
+\param[in] dongle_key points to a buffer of length ::XLT_KEY_SIZE containing the dangle_key key set by xnd_xlt_setup().
+\param[out] data points to a buffer of length ::XLT_BANK_SIZE that will receice the decrypted value.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark xnd_xlt_decrypt_locked2_data() retrieves the data in clear form of the content of a memory bank collected with a previous xnd_xlt_read_locked() call.
+xnd_xlt_decrypt_locked2_data() and xnd_xlt_read_locked() are used in a server client memory bank read operation. The xnd_xlt_read_locked() doesn't need of any password
+and cryptographic key to be used but produces an encrypted buffer that can be understood only by the holder of the Dongle Key crypto-key.
+xnd_xlt_read_locked() can be executed by non trusted people to collect information. Afterwards xnd_xlt_decrypt_locked2_data() allows the authorized parts to decrypt
+and read the content of the memory bank.
+
+The buffer returned by xnd_xlt_decrypt_locked2_data() is ::XLT_KEY_SIZE bytes long, but only the first ::XLT_LOCKED_BANK_DATA_LENGTH bytes are the significant data
+that can be written and used by the application. The remaining bytes are managed internally by the library and used for the 'locked bank' management.
+These bytes convey information that may be retrieved using xnd_xlt_get_info_from_locked_bank(), such information are necessary for writing inside a locked bank.
+ Supported version: this function is available on XLight devices version 1.01 or later.
+\sa xnd_xlt_read_locked(), xnd_xlt_get_info_from_locked_bank()
+*/
+XND_LINK int XND_API xnd_xlt_decrypt_locked2_data(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* encrypted_data, const unsigned char* dongle_key, unsigned char* data);
+
+/**
+\ingroup xnd_xlt_bank
+Return information of a locked bank (both normal and advanced Lock2 mode).
+
+See \ref xn_locked_memory.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] data points to a buffer of length ::XLT_BANK_SIZE, that contains the value retrieved from a locked bank by xnd_xlt_read() or xnd_xlt_decrypt_locked_data().
+\param[out] pbank points to an unsigned int that will contain the bank number to which the data belongs. This parameter is optional and may be set to NULL.
+\param[out] pcounter points to an unsigned int that will contain the current counter field of the locked bank. This parameter is optional and may be set to NULL.
+\param[out] pserial points to an unsigned int that will contain the serial number of the locked bank. This parameter is optional and may be set to NULL.
+\param[out] pgroup_number points to an unsigned int that will contain the group number of the locked bank. This parameter is optional and may be set to NULL.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\remark If the data passed to this function comes from a non locked bank the outcome of this function is meaningless.
+\remark The 'data' argument may come from a xnd_xlt_decrypt_locked_data() or a local xnd_xlt_read() call.
+*/
+XND_LINK int XND_API xnd_xlt_get_info_from_locked_bank(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* data, unsigned int* pbank, unsigned int* pcounter, unsigned int* pserial, unsigned int* pgroup_number);
+
+/**
+\ingroup xnd_xlt_device
+Virginize (reset) a demo XLight device.
+\remark It doesn't work at all on a virtual XLight device of an xNodus device.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\remark This function may be useful for testing allowing to completely cleanup a DEMO device, that is it doesn't work onto standard devices.
+A demo device is distinguished by standard ones by its serial number: it is set to the value '1'.
+This function may be useful especially while testing xnd_xlt_bank_freeze() and xnd_xlt_bank_lock2() functions which on normal devices cannot be reverted.
+
+\note OxySec supplies DEMO devices only for evaluation purpose and must be used only for testing on the standard devices.
+*/
+XND_LINK int XND_API xnd_xlt_virg_demo(XND_DEVICE_CONTEXT dev_ctx);
+
+//\cond NOT_COMMENTED
+XND_LINK int XND_API xnd_xlt_setserial(XND_DEVICE_CONTEXT dev_ctx, unsigned int sn);
+//\endcond
+
+/**
+\ingroup xnd_xlt_sd
+Get memory size information of the memory flash in XLight SD devices.
+\remark This function is not supported by xNodus devices.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] p_mem_size_in_blocks points to an unsigned integer receiving the size in memory blocks (512 bytes) of the overall memory flash.
+\param[out] p_enc_mem_size_in_blocks points to an unsigned integer receiving the size in memory blocks of the encrypted disk. If not present the return value is zero.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_SDMEM.
+*/
+XND_LINK int XND_API xnd_xlt_storage_get_mem_size(XND_DEVICE_CONTEXT dev_ctx, unsigned int *p_mem_size_in_blocks, unsigned int *p_enc_mem_size_in_blocks);
+
+/**
+\ingroup xnd_xlt_sd
+Initialize the memory flash of an XLight SD device.
+\remark This function is not supported by xNodus devices.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] locked_mem_size_in_blocks the size in blocks of the desired size for the encrypted disk. If no encrypted disk is desired set this value to '0' (zero).
+\param[in] dongle_key points to a buffer containing the Dongle Key set by xnd_xlt_setup() function.
+\param[in] disk_password points to a buffer of length ::XLT_DISK_PASSWORD_SIZE containing the password that will be used to mount and unmount the encrypted disk.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_SDMEM.
+*/
+XND_LINK int XND_API xnd_xlt_storage_set(XND_DEVICE_CONTEXT dev_ctx, unsigned int locked_mem_size_in_blocks, const unsigned char* dongle_key, const unsigned char* disk_password);
+
+/**
+\ingroup xnd_xlt_sd
+Mount the encrypted disk of an XLight SD device.
+\remark This function is not supported by xNodus devices.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] disk_password points to a buffer of length ::XLT_DISK_PASSWORD_SIZE containing the password set by xnd_xlt_storage_set() function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_SDMEM.
+*/
+XND_LINK int XND_API xnd_xlt_storage_unlock(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* disk_password);
+
+/**
+\ingroup xnd_xlt_sd
+Mount the encrypted disk of an XLight SD device with read only access.
+\remark This function is not supported by xNodus devices.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] disk_password points to a buffer of length ::XLT_DISK_PASSWORD_SIZE containing the password set by xnd_xlt_storage_set() function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_SDMEM.
+*/
+XND_LINK int XND_API xnd_xlt_storage_unlock_ro(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* disk_password);
+
+/**
+\ingroup xnd_xlt_sd
+Unmount the encrypted disk of an XLight SD device.
+\remark This function is not supported by xNodus devices.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] disk_password points to a buffer of length ::XLT_DISK_PASSWORD_SIZE containing the password set by xnd_xlt_storage_set() function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_SDMEM.
+*/
+XND_LINK int XND_API xnd_xlt_storage_lock(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* disk_password);
+
+//\cond NOT_COMMENTED
+XND_LINK int XND_API xnd_xlt_reserved(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* direct_cmd, unsigned int direct_cmd_len, unsigned char* direct_resp, unsigned int direct_resp_size);
+XND_LINK int XND_API xnd_xlt_reserved2(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* dongle_key, unsigned int serial, const unsigned char* oxy_pre_cmd, unsigned int oxy_pre_cmd_len, unsigned char* direct_resp, unsigned int direct_resp_size);
+XND_LINK int XND_API xnd_xlt_xlightsd_switch_to_nondemo(XND_DEVICE_CONTEXT dev_ctx);
+XND_LINK int XND_API xnd_xlt_get_device_name(XND_DEVICE_CONTEXT dev_ctx, char* device_name, unsigned int device_name_size);
+//\endcond
+
+/**
+\ingroup xnd_xlt_counter
+Update and get the value of a counter.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] counter index of the counter to be used. This entry may take values from 0 to ::XLT_COUNTERS_NUM - 1.
+\param[in] sub_value value to be subtracted to the indexed counter. If this value is 0 (zero) the counter value is read without modifying it.
+\param[out] p_new_value point to an unsigned int value that will receive the value of the counter after the subtraction.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+If sub_value is greater than the current counter value, its new value will be zero and the function returns ::XLT_ERROR_SUCCESS. This is still the case also if the counter value is already zero.
+
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_update_get_counter(XND_DEVICE_CONTEXT dev_ctx, unsigned int counter, unsigned int sub_value, unsigned int* p_new_value);
+
+/**
+\ingroup xnd_xlt_timer
+Retrieve the current value of the timer.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] p_value point to an unsigned int value that will receive the current value of the timer.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_get_timer(XND_DEVICE_CONTEXT dev_ctx, unsigned int* p_value);
+
+/**
+\ingroup xnd_xlt_counter
+Generate a command buffer to set a counter.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] counter_cmd points to the structure ::XLT_COUNTER_CMD containing the settings to be applied to a counter.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] enc_cmd points to a buffer that will receive the encrypted form of the command.
+\param[in] enc_cmd_size length of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will contain the number of bytes copied in enc_cmd. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_generate_counter_settings(XND_DEVICE_CONTEXT dev_ctx, const XLT_COUNTER_CMD* counter_cmd, const unsigned char* dongle_key, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_tc
+Apply a timer or counter command onto the device.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] enc_cmd point to a buffer containing the encrypted command to be applied to the device.
+\param[in] enc_cmd_len the length of the encrypted command.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_enc_apply_timer_counter(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_cmd, unsigned int enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_counter
+Read in encrypted form the current state of all the counters of the device.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] enc_data points to a buffer that will receive the encrypted counters data retrieved from the XLight dongle.
+\param[in] enc_data_size length of the buffer pointed by enc_data.
+\param[out] p_enc_data_len points to an unsigned integer that will receive the number of bytes copied in enc_data. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_enc_read_counters(XND_DEVICE_CONTEXT dev_ctx, unsigned char* enc_data, unsigned int enc_data_size, unsigned int* p_enc_data_len);
+
+/**
+\ingroup xnd_xlt_timer
+Generate a command buffer to a set the timer.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] timer_cmd points to the structure ::XLT_TIMER_CMD containing the settings to be applied to the timer.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] enc_cmd points to a buffer that will receive the encrypted form of the command.
+\param[in] enc_cmd_size length of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will contain the number of bytes copied in enc_cmd. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_generate_timer_settings(XND_DEVICE_CONTEXT dev_ctx, const XLT_TIMER_CMD* timer_cmd, const unsigned char* dongle_key, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_timer
+Generate a command buffer to increase the timer value.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] timer_add_cmd points to the structure ::XLT_TIMER_ADD_CMD containing the add timer settings to be applied.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] enc_cmd points to a buffer that will receive the encrypted form of the command.
+\param[in] enc_cmd_size length of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will contain the number of bytes copied in enc_cmd. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_generate_timer_add_settings(XND_DEVICE_CONTEXT dev_ctx, const XLT_TIMER_ADD_CMD* timer_add_cmd, const unsigned char* dongle_key, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_timer
+Read in encrypted form the current state the device timer.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] enc_data points to a buffer that will receive the encrypted timer data retrieved from the XLight dongle.
+\param[in] enc_data_size length of the buffer pointed by enc_data.
+\param[out] p_enc_data_len points to an unsigned integer that will receive the number of bytes copied in enc_data. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_enc_read_timer(XND_DEVICE_CONTEXT dev_ctx, unsigned char* enc_data, unsigned int enc_data_size, unsigned int* p_enc_data_len);
+
+/**
+\ingroup xnd_xlt_tc
+Decrypt encrypted data from the device regarding timer or counters.
+This function also extract data from encrypted commands.
+See \ref xn_TIMER_COUNTERS for an introduction to timer and counters management.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] enc_data points to encrypted data retrieved from the device or containing an encrypted command.
+\param[in] enc_data_len length of the encrypted buffer.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] retrieved_data points to an instance of structure ::XLT_TIMER_COUNTER_INFO that will contain the decryption of the data or command passed to this function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\see \ref xn_TIMER_COUNTERS.
+*/
+XND_LINK int XND_API xnd_xlt_timer_counters_retrieve(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_data, unsigned int enc_data_len, const unsigned char* dongle_key, XLT_TIMER_COUNTER_INFO* retrieved_data);
+
+/**
+\ingroup xnd_xlt_date
+Read in encrypted form the current state of the date license management of the device.
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] enc_data points to a buffer that will receive the encrypted date license data retrieved from the XLight dongle.
+\param[in] enc_data_size length of the buffer pointed by enc_data.
+\param[out] p_enc_data_len points to an unsigned integer that will receive the number of bytes copied in enc_data. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_enc_read_date(XND_DEVICE_CONTEXT dev_ctx, unsigned char* enc_data, unsigned int enc_data_size, unsigned int* p_enc_data_len);
+
+/**
+\ingroup xnd_xlt_date
+Read the current state of the date license management of the device.
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] date_info points to a XLT_DATE_DATA struct that will receive the date license data of the connected device.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\note xnd_xlt_read_date() can be run by the protected application to see the current status of the license but some ::XLT_DATE_DATA entries are set always to zero and can be collected only using
+remote functions. Such entries are:
+
+
+
+@{
+*/
+#define XND_ENCRYPTION_MODE_ECB 0 ///< ECB encryption mode
+#define XND_ENCRYPTION_MODE_CBC 1 ///< CBC encryption mode
+#define XND_ENCRYPTION_MODE_IGE 2 ///< IGE encryption mode
+#define XND_ENCRYPTION_MODE_GCM 3 ///< GCM encryption mode
+
+//@} //xnd_encryption_mode
+
+/**
+\ingroup xnd_volatile_g
+Perform a volatile encryption (see \ref xnd_volatile).
+\param[in] dev_ctx a ::XND_DEVICE_CONTEXT handle referring to a device context object with open session.
+\param[in] key_byte_len the length in byte of the AES key (32, 24 or 16).
+\param[in] mode_of_operation mode of operation of the encryption selected using the values from /ref xnd_encryption_mode.
+\param[in] plaintext points to the buffer containing the data to encrypt.
+\param[in] plaintext_len the length of the plaintext. This value must be a multiple of 16.
+\param[in] ini_vect points to buffer containing the initialization vector for the CBC or GCM mode. In case of CBC 16 bytes will be considered, while for GCM 12 bytes are taken. This entry may be set to 0 for ECB, IGE and also for CBC mode.
+\param[in] gcm_aad_len the length of the AAD (additional authenticated data) part of the plaintext when using GCM. The AAD part is the heading part of the plaintext buffer and its length must be not grater than the plaintext length. 'gcm_aad_len' must be set to '0' using the other encryption modes and can be set to 0 with GCM. This value must be a multiple of 16.
+\param[out] ciphertext points to a buffer that will receive the result of the encryption operation.
+\param[in] ciphertext_size the length in bytes of the buffer pointed by the 'ciphertext' argument.
+\param[out] p_ciphertext_len points to a buffer that will receive the length of the returned ciphertext.
+\return ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+The original GCM doesn't have the restrictions present here (including the multiple of 16 requests) to exploit the hardware encryption supplied by the device.
+\note Every user can run this function.
+*/
+XND_LINK int XND_API xnd_volatile_encrypt(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_byte_len, unsigned int mode_of_operation, const unsigned char* plaintext, unsigned int plaintext_len, OPT const unsigned char* ini_vect, OPT unsigned int gcm_aad_len, unsigned char* ciphertext, unsigned int ciphertext_size, OPT OUT unsigned int* p_ciphertext_len);
+
+/**
+\ingroup xnd_volatile_g
+Perform a volatile decryption (see \ref xnd_volatile).
+\param[in] dev_ctx a ::XND_DEVICE_CONTEXT handle referring to a device context object with open session.
+\param[in] key_byte_len the length in byte of the AES key (32, 24 or 16).
+\param[in] mode_of_operation mode of operation of the encryption selected using the values from /ref xnd_encryption_mode.
+\param[in] ciphertext points to a buffer containing the data to be decrypted.
+\param[in] ciphertext_len the length of the ciphertext. This value must be a multiple of 16.
+\param[in] ini_vect points to buffer containing the initialization vector for the CBC or GCM mode. In case of CBC 16 bytes will be considered, while for GCM 12 bytes are taken. This entry may be set to 0 for ECB, IGE and also for CBC mode.
+\param[in] gcm_aad_len the length of the AAD (additional authenticated data) part of the plaintext when using GCM. The AAD part is the heading part of the plaintext buffer and its length must be not grater than the plaintext length. 'gcm_aad_len' must be set to '0' using the other encryption modes and can be set to 0 with GCM. This value must be a multiple of 16.
+\param[out] plaintext points to a buffer that will receive the result of the decryption operation.
+\param[in] plaintext_size the length in bytes of the buffer pointed by the 'plaintext' argument.
+\param[out] p_plaintext_len points to a buffer that will receive the length of the returned plaintext.
+\return ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+The original GCM doesn't have the restrictions present here (including the multiple of 16 requests) to exploit the hardware encryption supplied by the device.
+\note Every user can run this function.
+*/
+XND_LINK int XND_API xnd_volatile_decrypt(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_byte_len, unsigned int mode_of_operation, const unsigned char* ciphertext, unsigned int ciphertext_len, OPT const unsigned char* ini_vect, OPT unsigned int gcm_aad_len, unsigned char* plaintext, unsigned int plaintext_size, OPT unsigned int* p_plaintext_len);
+
+/**
+\ingroup xnd_functions
+Test function for manage the 'session check' procedure system (see \ref xnd_session_check)
+\param[in] key a ::XND_KEY_DATA handle to a cryptographic key corresponding to the used non non volatile key present on xNodus.
+\param[in] counter_value the progressive counter of the session check procedure.
+\param[in] random_data points to the random data needed for the procedure
+\param[in] random_data_len the length of the random data. This value must be 12 for AES encryption or the length of the public module expressed in byte minus '4' when using RSA.
+\param[out] enc_msg points to a buffer that will receive the computed value to be send to the xNodus device.
+\param[in] enc_msg_size the size in byte of the buffer pointed by the 'enc_msg' entry.
+\param[out] p_enc_msg_len points to an unsigned integer that will receive the real length of the computed value written in 'enc_msg'. If set to '0' the length is not retrieved.
+\return ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+\note This function is present for testing purpose, never use it in the application protected with xNodus.
+\see xnd_start_session_check(), xnd_continue_session_check().
+*/
+XND_LINK int XND_API xnd_never_use_session_check_prepare(XND_KEY_DATA key, unsigned int counter_value, const unsigned char* random_data, unsigned int random_data_len, unsigned char* enc_msg, unsigned int enc_msg_size, unsigned int* p_enc_msg_len);
+
+/**
+\ingroup xnd_functions
+Start a 'session check' procedure (see \ref xnd_session_check).
+\param[in] dev_ctx a ::XND_DEVICE_CONTEXT handle referring to a device context object with open session.
+\param[in] key_type key type of the desired non volatile key. This value takes values from \ref xnd_info_key_type.
+\param[in] enc_msg points to a buffer containing the encrypted data that starts the session check procedure (computed by xnd_never_use_session_check_prepare() or, better, equivalent functions).
+\param[in] enc_msg_len the length of the 'enc_msg' entry.
+\param[out] dec_msg points to a buffer that will receive the data produced by by xNodus (a decryption of the incoming data).
+\param[in] dec_msg_size the size in byte of the buffer pointed by the 'dec_msg' entry.
+\param[out] p_dec_msg_len points to an unsigned integer that will receive the real length of the computed value written in 'dec_msg'. If set to '0' the length is not retrieved.
+\return ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+\see xnd_continue_session_check(), xnd_never_use_session_check_prepare().
+*/
+XND_LINK int XND_API xnd_start_session_check(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_type, const unsigned char* enc_msg, unsigned int enc_msg_len, unsigned char* dec_msg, unsigned int dec_msg_size, unsigned int* p_dec_msg_len);
+
+/**
+\ingroup xnd_functions
+Continue a 'session check' procedure (see \ref xnd_session_check).
+\param[in] dev_ctx a ::XND_DEVICE_CONTEXT handle referring to a device context object with open session.
+\param[in] key_type key type of the desired non volatile key. This value takes values from \ref xnd_info_key_type.
+\param[in] enc_msg points to a buffer containing the encrypted data that starts the session check procedure (computed by xnd_never_use_session_check_prepare() or, better, equivalent functions).
+\param[in] enc_msg_len the length of the 'enc_msg' entry.
+\param[out] dec_msg points to a buffer that will receive the data produced by by xNodus (a decryption of the incoming data).
+\param[in] dec_msg_size the size in byte of the buffer pointed by the 'dec_msg' entry.
+\param[out] p_dec_msg_len points to an unsigned integer that will receive the real length of the computed value written in 'dec_msg'. If set to '0' the length is not retrieved.
+\return ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+\see xnd_start_session_check(), xnd_never_use_session_check_prepare().
+*/
+XND_LINK int XND_API xnd_continue_session_check(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_type, const unsigned char* enc_msg, unsigned int enc_msg_len, unsigned char* dec_msg, unsigned int dec_msg_size, unsigned int* p_dec_msg_len);
+
+/**
+\ingroup xnd_functions
+Return a true (hardware) random number.
+\param[in] dev_ctx a ::XND_DEVICE_CONTEXT handle referring to a device context object with open session.
+\param[out] random points to a buffer that will receive the random buffer.
+\param[in] len the length in bytes of the desired random buffer.
+\return ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+*/
+XND_LINK int XND_API xnd_get_true_random(XND_DEVICE_CONTEXT dev_ctx, OUT unsigned char* random, unsigned int len);
+
+/**
+Start SBL (Secure Boot Loader) command structure for remote command
+
+This is the structure of the remote start boot loader command.
+In order to perform a remote reboot it is necessary set the serial number (just the final four bytes of the sixteen overall)
+and set a counter greater than the current one. Both values are returned by xnd_get_info().
+
+It is suggested to use the unix time for destination_counter: this allow to avoid to read its value and grant to use a value
+greater than the previous one
+
+SBL (Secure Boot Loader) is the xNodus configuration that is used to update the firmware: only a OxySec signed firmware can be uploaded.
+When a device is in SBL configuration it can't do anything but update the firmware to a newer version.
+*/
+typedef struct _REMOTE_SBL_CMD {
+ unsigned char destination_serial_part[4]; ///< Final four bytes of the device serial number of the destination xNodus device (XND_INFO.sn).
+ unsigned int destination_counter; ///< Counter of the operation (must be grater than XND_INFO.remote_counter).
+}REMOTE_SBL_CMD;
+typedef REMOTE_SBL_CMD *P_REMOTE_SBL_CMD; ///< pointer to ::REMOTE_SBL_CMD type
+
+
+/**
+Start SBL (Secure Boot Loader) response structure for remote command
+
+This is the structure of the remote start boot loader command answer. It contains the argument of the command and the status of the operation
+*/
+typedef struct _REMOTE_SBL_RESP {
+ REMOTE_SBL_CMD issued_cmd; ///< arguments of the remote start boot loader command sent to the device
+ int status; ///< the status of the operation returned by the device
+}REMOTE_SBL_RESP;
+typedef REMOTE_SBL_RESP *P_REMOTE_SBL_RESP; ///< pointer to ::REMOTE_SBL_RESP type
+
+/**
+\ingroup xnodus_remote_cmd
+Write a buffer for the remote execution of the start of the Secure Boot Loader on a given device.
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] remote_sbl_cmd points to a structure ::REMOTE_SBL_CMD with the arguments of the command.
+\param[out] enc_cmd points to a buffer that will receive the command buffer to be remotely applied to the device using xnd_apply_remote_command()
+\param[in] enc_cmd_size the size of the buffer pointed by 'enc_cmd'.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the length of the command pointed by 'enc_cmd'.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+\remark To apply the command to the xNodus device it is necessary run xnd_apply_remote_command() in an application that can communicate directly to the target xNodus device. As input it needs the generated encrypted command
+(i.e. the result pointed by enc_cmd). If it is necessary to know the result of the operation of xnd_apply_remote_command(), the function xnd_remote_resp_start_sbl() can analyze the response to the command.
+\see xnd_apply_remote_command(), xnd_remote_resp_start_sbl().
+*/
+XND_LINK int XND_API xnd_remote_cmd_start_sbl(XND_DEVICE_CONTEXT dev_ctx, const REMOTE_SBL_CMD* remote_sbl_cmd, OUT unsigned char* enc_cmd, unsigned int enc_cmd_size, OUT unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnodus_remote_cmd
+Retrieve the status of a remote start 'Secure Boot Loader' call
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] enc_resp points to a buffer containing the response of xNodus returned by the function xnd_apply_remote_command().
+\param[in] enc_resp_len the length of the buffer pointed by 'enc_resp'.
+\param[out] p_resp points to a struct of type ::REMOTE_SBL_RESP that will be filled with the status and data of the remote operation.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+\see xnd_remote_cmd_start_sbl().
+*/
+XND_LINK int XND_API xnd_remote_resp_start_sbl(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_resp, unsigned int enc_resp_len, OUT P_REMOTE_SBL_RESP p_resp);
+
+/**
+Non volatile key set command structure for remote command
+
+This is the structure of the remote 'non volatile key set' command.
+In order to perform a remote 'non volatile key set' it is necessary (in addition to the key values) set the serial number (just the final four bytes of the sixteen overall)
+and set a counter greater than the current one. Both values are returned by xnd_get_info().
+
+It is suggested to use the unix time for destination_counter: this allow to avoid to read its value and grant to use a value
+greater than the previous one
+*/
+typedef struct _REMOTE_NON_VOLATILE_KEY_SET_CMD {
+ unsigned int key_type; ///< type of cryptographic key to be set (values from \ref xnd_info_key_type).
+ unsigned int key_len; ///< length of cryptographic key
+ unsigned char key[XND_RSA_4096_PRIV_KEY_SIZE];///< cryptographic key to be set expressed in XLight or xNodus format (see \ref xnd_key_data).
+ unsigned char destination_serial_part[4];///< final four bytes of the xNodus device serial number (XND_INFO.sn).
+ unsigned int destination_counter; ///< counter of the operation (must be grater than XND_INFO.remote_counter).
+}REMOTE_NON_VOLATILE_KEY_SET_CMD;
+typedef REMOTE_NON_VOLATILE_KEY_SET_CMD *P_REMOTE_NON_VOLATILE_KEY_SET_CMD; ///< pointer to ::REMOTE_NON_VOLATILE_KEY_SET_CMD type
+
+/**
+Non volatile key set response structure for remote command
+
+This is the structure of the remote 'non volatile key set' command answer. It contains the argument of the command and the status of the operation
+*/
+typedef struct _REMOTE_NON_VOLATILE_KEY_SET_RESP {
+ REMOTE_NON_VOLATILE_KEY_SET_CMD issued_cmd; ///< arguments of the remote non volatile set key command sent to the device
+ int status; ///< the status of the operation returned by the device
+}REMOTE_NON_VOLATILE_KEY_SET_RESP;
+typedef REMOTE_NON_VOLATILE_KEY_SET_RESP *P_REMOTE_NON_VOLATILE_KEY_SET_RESP; ///< pointer to ::REMOTE_NON_VOLATILE_KEY_SET_RESP type
+
+/**
+\ingroup xnodus_remote_cmd
+Set a non volatile key remotely.
+
+Construct a remote command buffer to perform the same task of the xnd_non_volatile_key_set() function.
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] cmd points to a structure ::REMOTE_NON_VOLATILE_KEY_SET_CMD with the arguments of the command.
+\param[out] enc_cmd points to a buffer that will receive the command buffer to be remotely applied to the device using xnd_apply_remote_command().
+\param[in] enc_cmd_size the size of the buffer pointed by 'enc_cmd'.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the length of the command pointed by 'enc_cmd'.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+\remark To apply the command to the xNodus device it is necessary run xnd_apply_remote_command() in an application that can communicate directly to the target xNodus device. As input it needs the generated encrypted command
+(i.e. the result pointed by enc_cmd). If it is necessary to know the result of the operation of xnd_apply_remote_command(), the function xnd_remote_resp_non_volatile_key_set() can analyze the response to the command.
+\see xnd_remote_resp_non_volatile_key_set(), xnd_apply_remote_command().
+*/
+XND_LINK int XND_API xnd_remote_cmd_non_volatile_key_set(XND_DEVICE_CONTEXT dev_ctx, const REMOTE_NON_VOLATILE_KEY_SET_CMD* cmd, OUT unsigned char* enc_cmd, unsigned int enc_cmd_size, OUT unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnodus_remote_cmd
+
+Retrieve the status of a remote 'non volatile key set' command.
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] enc_resp points to a buffer containing the response of xNodus returned by the function xnd_apply_remote_command().
+\param[in] enc_resp_len the length of the buffer pointed by 'enc_resp'.
+\param[out] p_resp points to a struct of type ::REMOTE_NON_VOLATILE_KEY_SET_RESP that will be filled with the status and data of the remote operation.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+
+\see xnd_remote_cmd_non_volatile_key_set(), xnd_apply_remote_command().
+*/
+XND_LINK int XND_API xnd_remote_resp_non_volatile_key_set(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_resp, unsigned int enc_resp_len, OUT P_REMOTE_NON_VOLATILE_KEY_SET_RESP p_resp);
+
+
+/**
+User create and update command structure for remote command
+
+This is the structure of the remote 'create user' (see xnd_create_user()) and 'update user' command (see xnd_update_user()).
+In order to perform a remote 'create user' or 'update user' it is necessary set the serial number (just the final four bytes of the sixteen overall)
+and set a counter greater than the current one. Both values are returned by xnd_get_info().
+
+It is suggested to use the unix time for destination_counter: this allow to avoid to read its value and grant to use a value
+greater than the previous one
+*/
+typedef struct _REMOTE_UPDATE_USER_CMD {
+ unsigned int is_update; ///< if set to 0 this is a remote 'create user' command, otherwise it is an 'update user' command
+ unsigned int _unused; ///< unused
+ XND_USER_INFO user_info; ///< value to be set remotely. In case of update the entry set_values_mask can be used to change a subset of values.
+ unsigned char destination_serial_part[4];///< final four bytes of the xNodus device serial number(XND_INFO.sn).
+ unsigned int destination_counter; ///< counter of the operation (must be grater than XND_INFO.remote_counter).
+}REMOTE_UPDATE_USER_CMD;
+typedef REMOTE_UPDATE_USER_CMD *P_REMOTE_UPDATE_USER_CMD; ///< pointer to ::REMOTE_UPDATE_USER_CMD type
+
+/**
+User create and update response structure for remote command
+
+This is the structure of the remote user create and update command answer. It contains the argument of the command and the status of the operation
+*/
+typedef struct _REMOTE_UPDATE_USER_RESP {
+ REMOTE_UPDATE_USER_CMD issued_cmd; ///< arguments of the 'create and update user' command sent to the device
+ int status; ///< the status of the operation returned by the device
+ unsigned int _unused; ///< unused
+}REMOTE_UPDATE_USER_RESP;
+typedef REMOTE_UPDATE_USER_RESP *P_REMOTE_UPDATE_USER_RESP; ///< pointer to ::REMOTE_UPDATE_USER_RESP type
+
+/**
+\ingroup xnodus_remote_cmd
+Create or update a user remotely.
+
+Construct a remote command buffer to perform the same task of the xnd_create_user() or xnd_update_user() functions.
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] cmd points to a structure ::REMOTE_UPDATE_USER_CMD with the arguments of the command.
+\param[out] enc_cmd points to a buffer that will receive the command buffer to be remotely applied to the device using xnd_apply_remote_command().
+\param[in] enc_cmd_size the size of the buffer pointed by 'enc_cmd'.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the length of the command pointed by 'enc_cmd'.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+\remark To apply the command to the xNodus device it is necessary run xnd_apply_remote_command() in an application that can communicate directly to the target xNodus device. As input it needs the generated encrypted command
+(i.e. the result pointed by enc_cmd). If it is necessary to know the result of the operation of xnd_apply_remote_command(), the function xnd_remote_resp_update_user() can analyze the response to the command.
+\see xnd_remote_resp_update_user(), xnd_apply_remote_command().
+*/
+XND_LINK int XND_API xnd_remote_cmd_update_user(XND_DEVICE_CONTEXT dev_ctx, const REMOTE_UPDATE_USER_CMD* cmd, OUT unsigned char* enc_cmd, unsigned int enc_cmd_size, OUT unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnodus_remote_cmd
+
+Retrieve the status of a remote 'user create or update' command.
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] enc_resp points to a buffer containing the response of xNodus returned by the function xnd_apply_remote_command().
+\param[in] enc_resp_len the length of the buffer pointed by 'enc_resp'.
+\param[out] p_resp points to a struct of type ::REMOTE_UPDATE_USER_RESP that will be filled with the status and data of the remote operation.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+
+\see xnd_remote_cmd_update_user(), xnd_apply_remote_command().
+*/
+XND_LINK int XND_API xnd_remote_resp_update_user(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_resp, unsigned int enc_resp_len, OUT P_REMOTE_UPDATE_USER_RESP p_resp);
+
+/**
+Delete user command structure for remote command
+
+This is the structure of the remote 'delete user' (see xnd_delete_user()).
+In order to perform a remote 'delete user' it is necessary set the serial number (just the final four bytes of the sixteen overall)
+and set a counter greater than the current one. Both values are returned by xnd_get_info().
+
+It is suggested to use the unix time for destination_counter: this allow to avoid to read its value and grant to use a value
+greater than the previous one
+*/
+typedef struct _REMOTE_DELETE_USER_CMD {
+ XND_USER_NAME user_name; ///< User to be deleted
+ unsigned char destination_serial_part[4];///< final four bytes of the xNodus device serial number (XND_INFO.sn).
+ unsigned int destination_counter; ///< counter of the operation (must be grater than XND_INFO.remote_counter).
+}REMOTE_DELETE_USER_CMD;
+typedef REMOTE_DELETE_USER_CMD *P_REMOTE_DELETE_USER_CMD; ///< pointer to ::REMOTE_DELETE_USER_CMD type
+
+/**
+Delete user response structure for remote command
+
+This is the structure of the remote delete user answer. It contains the argument of the command and the status of the operation
+*/
+typedef struct _REMOTE_DELETE_USER_RESP {
+ REMOTE_DELETE_USER_CMD issued_cmd; ///< arguments of the 'delete user' command sent to the device
+ int status; ///< the status of the operation returned by the device
+}REMOTE_DELETE_USER_RESP;
+typedef REMOTE_DELETE_USER_RESP *P_REMOTE_DELETE_USER_RESP; ///< pointer to ::REMOTE_DELETE_USER_RESP type
+
+/**
+\ingroup xnodus_remote_cmd
+Delete a user remotely.
+
+Construct a remote command buffer to perform the same task of the xnd_delete_user().
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] cmd points to a structure ::REMOTE_DELETE_USER_CMD with the arguments of the command.
+\param[out] enc_cmd points to a buffer that will receive the command buffer to be remotely applied to the device using xnd_apply_remote_command().
+\param[in] enc_cmd_size the size of the buffer pointed by 'enc_cmd'.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the length of the command pointed by 'enc_cmd'.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+\remark To apply the command to the xNodus device it is necessary run xnd_apply_remote_command() in an application that can communicate directly to the target xNodus device. As input it needs the generated encrypted command
+(i.e. the result pointed by enc_cmd). If it is necessary to know the result of the operation of xnd_apply_remote_command(), the function xnd_remote_resp_delete_user() can analyze the response to the command.
+\see xnd_remote_resp_delete_user(), xnd_apply_remote_command().
+*/
+XND_LINK int XND_API xnd_remote_cmd_delete_user(XND_DEVICE_CONTEXT dev_ctx, const REMOTE_DELETE_USER_CMD* cmd, OUT unsigned char* enc_cmd, unsigned int enc_cmd_size, OUT unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnodus_remote_cmd
+
+Retrieve the status of a remote 'delete user' command.
+\param[in] dev_ctx an administrator device context object handle.
+\param[in] enc_resp points to a buffer containing the response of xNodus returned by the function xnd_apply_remote_command().
+\param[in] enc_resp_len the length of the buffer pointed by 'enc_resp'.
+\param[out] p_resp points to a struct of type ::REMOTE_DELETE_USER_RESP that will be filled with the status and data of the remote operation.
+\return ::XND_ERROR_SUCCESS if found, an \ref xnodus_errors "error code" on failure.
+
+\see xnd_remote_cmd_delete_user(), xnd_apply_remote_command().
+*/
+XND_LINK int XND_API xnd_remote_resp_delete_user(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_resp, unsigned int enc_resp_len, OUT P_REMOTE_DELETE_USER_RESP p_resp);
+
+/**
+\ingroup xnodus_remote_cmd
+Apply a remote command.
+\param[in] dev_ctx a ::XND_DEVICE_CONTEXT handle referring to a device context object where the session state (open or not) is irrelevant.
+\param[in] send_buf points to a buffer containing the encrypted remote commmand.
+\param[in] send_len the length in bytes of the buffer pointed by 'send_buf'.
+\param[out] p_recv_len points to an unsigned integer that will receive the length of the returned response.
+\param[in] recv_timeout_ms timeout in millisecond of the operation. If this value is set to '0' a default value is taken.
+\param[out] p_ret_status points to an integer receiving the inner status of the executed command: ::XND_ERROR_SUCCESS on success, an \ref xnodus_errors "error code" on failure.
+\return return a buffer that containing the encrypted response to the command.
+\remark The buffer returned by the function must be freed calling xnd_free().
+*/
+XND_LINK unsigned char* XND_API xnd_apply_remote_command(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* send_buf, unsigned int send_len, OPT unsigned int recv_timeout_ms, OUT unsigned int* p_recv_len, OUT int* p_ret_status);
+
+/**
+\defgroup xnd_log_mask xNodus Log mask
+\ingroup xnodus_defines
+
+Mask values for the information to retrieve by the log functions (see \ref xnd_get_log_list_start())
+These mask values are used as significant bit mask also in the field set_values_mask of the structure ::XND_LOG_DATA
+@{
+*/
+#define XND_LOG_SIGNIFICANT_MASK_LICENSE_ID_HASH 0x00000001 ///< license_id_hash entry in ::XND_LOG_DATA is significant
+#define XND_LOG_SIGNIFICANT_MASK_OPEN_INSTANCES 0x00000002 ///< num_open_instances entry in ::XND_LOG_DATA is significant
+#define XND_LOG_SIGNIFICANT_MASK_USER_IDX 0x00000004 ///< user_idx entry in ::XND_LOG_DATA is significant
+#define XND_LOG_SIGNIFICANT_MASK_USER_NAME 0x00000008 ///< user_name entry in ::XND_LOG_DATA is significant
+#define XND_LOG_SIGNIFICANT_MASK_CLIENT_IP 0x00000010 ///< ip_addr entry in ::XND_LOG_DATA is significant
+#define XND_LOG_SIGNIFICANT_MASK_OPEN_MODULES 0x00000020 ///< open_modules entry in ::XND_LOG_DATA is significant
+//@} //xnd_log_mask
+
+/**
+\ingroup xnodus_defines
+minimum information data mask that can be retrieved by the log functions
+*/
+#define XND_LOG_MASK_MIN (XND_LOG_SIGNIFICANT_MASK_LICENSE_ID_HASH | XND_LOG_SIGNIFICANT_MASK_OPEN_INSTANCES)
+
+/**
+\ingroup xnodus_defines
+complete information data mask that can be retrieved by the log functions
+*/
+#define XND_LOG_SIGNIFICANT_MASK_ALL (XND_LOG_SIGNIFICANT_MASK_LICENSE_ID_HASH | XND_LOG_SIGNIFICANT_MASK_OPEN_INSTANCES | \
+ XND_LOG_SIGNIFICANT_MASK_USER_IDX | XND_LOG_SIGNIFICANT_MASK_USER_NAME | XND_LOG_SIGNIFICANT_MASK_CLIENT_IP | XND_LOG_SIGNIFICANT_MASK_OPEN_MODULES)
+
+/**
+\ingroup xnodus_defines
+Length of the License identifier value inside the structure ::XND_LOG_DATA
+*/
+#define XND_LOG_ID_HASH_LEN 4
+
+/**
+\ingroup xnodus_log
+Log structure,
+Description of the status of a given using license instance.
+In case multi-instance (see \ref xnd_users_group_lic) is not used this values represent the data of an open session, in case
+of multi-instance usage it collects the description of the sum of the session that are using a specific license instance.
+
+The entry num_open_instances counts the number of session referring to the license instance.
+
+*/
+typedef struct _XND_LOG_DATA{
+ unsigned int set_values_mask;///
+
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_read_date(XND_DEVICE_CONTEXT dev_ctx, XLT_DATE_DATA* date_info);
+
+/**
+\ingroup xnd_xlt_date
+Set the current time (date) of the device.
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] time the current Unix Time.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_set_date(XND_DEVICE_CONTEXT dev_ctx, unsigned int time);
+
+/**
+\ingroup xnd_xlt_date
+Retrieve the challenge buffer generated by the XLight device for update signed update (\ref xn_SIGNED_DATE_UPDATE_CONSTRAINT)
+The challenge buffer need to be used for setting the signed date onto the device
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[out] enc_challenge points to a buffer that will receive an encoded form of the challenge buffer generated by the device. The length of the buffer must be not less than ::XLT_DATE_ENC_CHALLENGE_SIZE bytes long.
+\param[in] enc_challenge_size length of the buffer pointed by challenge.
+\param[out] p_enc_challenge_len points to an unsigned integer that will receive the length of the bytes copied in challenge. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_date_get_challenge(XND_DEVICE_CONTEXT dev_ctx, unsigned char* enc_challenge, unsigned int enc_challenge_size, unsigned int* p_enc_challenge_len);
+
+/**
+\ingroup xnd_xlt_date
+Generate the license date expiration command
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date (and the \ref xn_SetDateExpiration for an example of xnd_xlt_generate_date_expiration_cmd() usage).
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] cmd points to the structure containing all the settings for the license expiration command.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] enc_cmd points to a buffer that will receive the encrypted form of the command for setting the expiration license date of an XLight device. The length of the buffer must be not less than ::XLT_DATE_ENC_EXP_CMD_SIZE bytes long.
+\param[in] enc_cmd_size length of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the length of the bytes copied in enc_cmd. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_generate_date_expiration_cmd(XND_DEVICE_CONTEXT dev_ctx, const XLT_DATE_SET_EXPIRATION_CMD* cmd, const unsigned char* dongle_key, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_date
+Generate the signed date command.
+This command uses the challenge retrieved by the XLight device using the function xnd_xlt_date_get_challenge() and decoded by xnd_xlt_date_enc_retrieve().
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] time current Unix Time.
+\param[in] challenge the challenge buffer generated by the dongle.
+\param[in] challenge_len length of the challenge entry.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] enc_cmd points to a buffer that will receive the encrypted form of the command for the signed update of the time of the device. The length of the buffer must be not less than ::XLT_DATE_SIG_UPD_CMD_SIZE bytes long.
+\param[in] enc_cmd_size length of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the length of the bytes copied in enc_cmd. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\note The challenge entry is not the enc_challenge argument returned by the function xnd_xlt_date_get_challenge(), but this is the challenge buffer of the structure ::XLT_DATE_CHALLENGE returned by xnd_xlt_date_enc_retrieve().
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_generate_signed_date_cmd(XND_DEVICE_CONTEXT dev_ctx, unsigned int time, const unsigned char* challenge, unsigned int challenge_len, const unsigned char* dongle_key, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_date
+Apply both license expiration setting and signed date update to the XLight device.
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] enc_cmd point to a buffer containing the encrypted command to be applied to the device.
+\param[in] enc_cmd_len the length of the encrypted command.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_apply_date_enc_cmd(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_cmd, unsigned int enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_date
+Decrypt the encrypted data returned by the device regarding the date license settings.
+This function also extract data from encrypted commands for date management.
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] enc_data points to encrypted data retrieved from the device or containing an encrypted command.
+\param[in] enc_data_len length of the encrypted buffer.
+\param[in] dongle_key points to the value of the Dongle Key set up by xnd_xlt_setup() function.
+\param[out] retrieved_data points to an instance of structure ::XLT_DATE_INFO that will contain the decryption of the data or command passed to this function.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_date_enc_retrieve(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_data, unsigned int enc_data_len, const unsigned char* dongle_key, XLT_DATE_INFO* retrieved_data);
+
+/**
+\ingroup xnd_xlt_date
+Date management function.
+This function can take care of all the date management for the XLight device.
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date (and expecially the paragraph \ref xn_AUTO_MANAGE_DATE_UPDATE).
+An XLight device with date based licensing needs to be regularly accessed for setting its signed time and "normal" (non signed) time.
+The non automatic functions used for such tasks are the xnd_xlt_apply_date_enc_cmd() (in conjunction with other vendor side operation) for the signed time and the xnd_xlt_set_date() for the non signed time.
+xlt_date_manage() is able to completely substitute these tasks and regularly update the device also accessing internet services for getting signed update time.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] cmd one of the \ref xlt_date_manage_cmd.
+\param[in] device device index for the selection of a specific XLight device. This value runs from 0 to ::XLT_DEVICE_EXT_MAX -1.
+\param[in] options the options of the command specified by the cmd argument.
+\param[in] args points to a string containing arguments for addressing internet URL for signed time update or NTP time service.
+\param[in] label points to a buffer with length of ::XLT_LABEL_SIZE byte containing the label of the XLight device to be addressed. If this entry is set to NULL, every device is addressed.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\note The device argument is considered only when the cmd argument has values \ref ::XLT_DATE_MANAGE_DO_SET_TIME and ::XLT_DATE_MANAGE_DO_SET_TIME_ASYNC.
+
+The entry options and args gets values with different meaning depending on the value of the cmd entry:
+
+when cmd is chosen among
+
+
+
+The options entry takes the values shown here: \ref DATE_OPT_VAL; while args is a string containing web addresses to reach an NTP service or the OxySec signed date service:
+see \ref xn_AUTO_MANAGE_DATE_UPDATE to see how to build it up.
+
+When cmd is ::XLT_DATE_MANAGE_SET_IDLE_TIME_SEC the options entry represents the second of tha new idle value (that is the time elapsing from one update test cicle and the other). Usually you don't need to
+use this command value. The args entry is ignored.
+
+When cmd is ::XLT_DATE_MANAGE_MAKE_LOGS the options entry is considered as a boolean value: '1' starts the log management, '0' stops it (the default is no log, so you need to activate it to get the log). The args entry is ignored.
+
+When cmd is ::XLT_DATE_MANAGE_LOG_ONLY_ERROR the options entry is considered as a boolean value: '1' makes the log manager to keep track only of errors, '0' makes the log manager to keep track of every event (the defalut is '0'). The args entry is ignored.
+
+When cmd is ::XLT_DATE_MANAGE_LOG_SET_QUEUE_LEN the options entry is the value of the desired log buffer, that is the maximum number of the log records that can be taken. When that number is passed the older records are discarded.
+The default value for this entry is 10000. The args entry is ignored.
+
+For every other value of the cmd entry options and args are ignored.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_date_manage(XND_DEVICE_CONTEXT dev_ctx, unsigned int cmd, unsigned int device, unsigned int options, const char* args, const unsigned char* label);
+
+/**
+\ingroup xnd_xlt_date
+Retrieve the number of log records collected by the automatic date management process issued by xnd_xlt_date_manage().
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[out] p_num_entries points to an unsigned integer that will receive the number of log record currently collected.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_date_manage_get_num_log_records(XND_DEVICE_CONTEXT dev_ctx, unsigned int* p_num_entries);
+
+/**
+\ingroup xnd_xlt_date
+Retrieve log records collected by the automatic date management process issued by xnd_xlt_date_manage().
+See \ref xn_DATE_LICENSING for an introduction to XLight license management based on the date.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to a real or fake device.
+\param[in] starting_index the index of the first record to read from the log.
+\param[in] num_entries the number of entries to read from the log.
+\param[out] date_log the array of XLT_DATE_LOG structure that will receive the log records. The array must contain not less then num_entries items.
+\param[out] p_num_entries_retrieved points to an unsigned integer that will receive the number of entries copied into the date_log array. This entry may be set also to 0 (NULL).
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+See \ref xn_DATE_LICENSING
+*/
+XND_LINK int XND_API xnd_xlt_date_manage_get_log_records(XND_DEVICE_CONTEXT dev_ctx, unsigned int starting_index, unsigned int num_entries, XLT_DATE_LOG date_log[], unsigned int* p_num_entries_retrieved);
+
+/**
+\ingroup xnd_xlt_ss
+Open a session on the device (see \ref xnd_session_on_xlight).
+\remark This function is not supported by xNodus devices, use xnd_xlt_session_open() instead.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\param[in] password points to a buffer of length ::XLT_PASSWORD_SIZE. It contains the password to be assigned to the device.
+\param[out] p_already_open points to an unsigned integer that will contain '1' if the session was already open, and '0' if not. If the pointer p_already_open is set to zero the argument is ignored.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\remark If the device referenced is xNodus the argument p_already_open is always ignored.
+*/
+XND_LINK int XND_API xnd_xlt_c_open_session(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* password, unsigned int* p_already_open);
+
+/**
+\ingroup xnd_xlt_ss
+Close a session on the device (see \ref xnd_session_on_xlight).
+\remark This function is not supported by xNodus devices, use xnd_xlt_session_close() instead.
+\param[in] dev_ctx ::XND_DEVICE_CONTEXT handle referring to the selected device.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+*/
+XND_LINK int XND_API xnd_xlt_c_close_session(XND_DEVICE_CONTEXT dev_ctx);
+//xnd_xlt_functions
+
+
+//#define XND_XLT_MODULE_CONFIG_CMD_LEN 32
+
+/**
+\ingroup xnd_xlt_module
+XLight command for setting the module mask inside an XLight device (see \ref xnd_modules).
+\param[in] dev_ctx a generic device context handle.
+\param[in] modules_mask a 64 bit variable that defines the modules that the protected application can open.
+\param[in] dongle_key points to the dongle_key of the XLight device (see xnd_xlt_setup()).
+\param[in] unix_time current time expressed in unix time.
+\param[in] sn serial number of the target XLight device. If this entry is set to '0' every device will accept the command.
+\param[out] enc_cmd points to a buffer that will receive the command for setting the module mask inside the specified XLight device using xnd_xlt_config_modules_apply().
+\param[in] enc_cmd_size the size in bytes of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the actual length of the retrieved command written in enc_cmd.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark The module support for XLight is based on a mask, because a module can be set (1) or inactive (0), there is no counting process to establish the number of instances of the pretected application that can gain access of the module,
+here it is only possible to set 'all' or 'none'. The value 0x0000000000000001 set as usable the module 0, 0x0000000000000002 set as usable the module 1, ... 0x8000000000000000 set as usable the module 63. So to make active the modules
+1,4, and 62 it must be used 0x4000000000000012.
+
+\remark This command works only on XLight version 2.50 and later
+\see xnd_xlt_config_modules_apply()
+*/
+XND_LINK int XND_API xnd_xlt_config_modules_cmd_wrap(XND_DEVICE_CONTEXT dev_ctx, XLT_ULONG_LONG modules_mask, const unsigned char* dongle_key, unsigned int unix_time, OPT unsigned int sn, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_module
+Write the managed module mask on an XLight device applying the command generated by the function xnd_xlt_config_modules_cmd_wrap() (see \ref xnd_modules).
+\param[in] dev_ctx a device context referring to the desired XLight device.
+\param[in] enc_cmd points to a buffer containing the encrypted command generated by xnd_xlt_config_modules_cmd_wrap()
+\param[in] enc_cmd_len the length in bytes of the encrypted command.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\remark This command works only on XLight version 2.50 and later.
+\see xnd_xlt_config_modules_cmd_wrap()
+*/
+XND_LINK int XND_API xnd_xlt_config_modules_apply(XND_DEVICE_CONTEXT dev_ctx, unsigned char* enc_cmd, unsigned int enc_cmd_len);
+
+//#define XLT_MODULE_SET_KEY_CMD_LEN 272
+/**
+\ingroup xnd_xlt_module
+XLight command for setting module challenge keys inside an XLight device (see \ref xnd_module_challenge).
+\param[in] dev_ctx a generic device context handle.
+\param[in] key_type key type of used key. This value takes values from \ref xnd_info_key_type.
+\param[in] key points to a buffer containing a key expressed in XLight or xNodus format (see \ref xnd_key_data).
+\param[in] key_len the length of the key entry.
+\param[in] dongle_key points to the dongle_key of the XLight device (see xnd_xlt_setup()).
+\param[in] sn serial number of the target XLight device. If this entry is set to '0' every device will accept the command.
+\param[out] enc_cmd points to a buffer that will receive the command for setting the specific key inside the specified XLight device using xnd_xlt_set_modules_key_apply().
+\param[in] enc_cmd_size the size in bytes of the buffer pointed by enc_cmd.
+\param[out] p_enc_cmd_len points to an unsigned integer that will receive the actual length of the retrieved command written in enc_cmd.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+\parblock
+\remark Only one key type (among RSA 512, RSA 1024 and AES) for the module challenge can be present on the XLight device at a time (while xNodus can select any of the present non volatile keys).
+\endparblock
+\parblock
+\remark This command works only on XLight version 2.50 and later
+\endparblock
+*/
+XND_LINK int XND_API xnd_xlt_set_modules_key_cmd_wrap(XND_DEVICE_CONTEXT dev_ctx, unsigned int key_type, const unsigned char* key, unsigned int key_len, const unsigned char* dongle_key, OPT unsigned int sn, unsigned char* enc_cmd, unsigned int enc_cmd_size, unsigned int* p_enc_cmd_len);
+
+/**
+\ingroup xnd_xlt_module
+Write a module challenge key on an XLight device applying the command generated by the function xnd_xlt_set_modules_key_cmd_wrap() (see \ref xnd_module_challenge).
+\param[in] dev_ctx a device context referring to the desired XLight device.
+\param[in] enc_cmd points to a buffer containing the encrypted command generated by xnd_xlt_set_modules_key_cmd_wrap()
+\param[in] enc_cmd_len the length in bytes of the encrypted command.
+\return returns ::XLT_ERROR_SUCCESS on success, an \ref xlt_Errors "error code" on failure.
+
+\remark This command works only on XLight version 2.50 and later
+*/
+XND_LINK int XND_API xnd_xlt_set_modules_key_apply(XND_DEVICE_CONTEXT dev_ctx, const unsigned char* enc_cmd, unsigned int enc_cmd_len);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //XND_H_1239854890
diff --git a/OxySec/Lib/x32/oxyxlt.obj b/OxySec/Lib/x32/oxyxlt.obj
deleted file mode 100644
index 3812dbf..0000000
Binary files a/OxySec/Lib/x32/oxyxlt.obj and /dev/null differ
diff --git a/OxySec/Lib/x32/xnodus32.obj b/OxySec/Lib/x32/xnodus32.obj
new file mode 100644
index 0000000..67765e4
Binary files /dev/null and b/OxySec/Lib/x32/xnodus32.obj differ
diff --git a/OxySec/Lib/x64/oxyxlt.obj b/OxySec/Lib/x64/oxyxlt.obj
deleted file mode 100644
index 79c070b..0000000
Binary files a/OxySec/Lib/x64/oxyxlt.obj and /dev/null differ
diff --git a/OxySec/Lib/x64/xnodus.obj b/OxySec/Lib/x64/xnodus.obj
new file mode 100644
index 0000000..edabee8
Binary files /dev/null and b/OxySec/Lib/x64/xnodus.obj differ