I have an application that stores and retrieves binary data from the registry. The application writes the data correctly to the registry but it cannot read all the data from the key if a 0x00 (zero, NULL) appears anywhere in the data written to the registry key. RegQueryValueEx appears to only read all the binary data up to the 0x00. For example, if I store 7b d1 13 74 00 d8 24 a3 in the registry, RegQueryValueEx only returns 7b d1 13 74. The key is a REG_BINARY key.
The data that is written to the key is first encrypted using the Rijndael method. So, I have no control over what is written to the reigstry. The Rijndael method occassionally generates a 0x00 when encrypting.
The code that I use to read the binary data is as follows:
Code:
char szEncryptedHAIKey[81] = {0};
char szHAIKey[81] = {0};
memset(szHAIKey, 0, sizeof szHAIKey);
iDatasize = sizeof (szEncryptedHAIKey);
RegQueryValueEx(hKey, "HAIKey",
NULL, NULL, (unsigned char *)&szEncryptedHAIKey, (unsigned long *)&iDatasize);
Decrypt(szEncryptedHAIKey,szHAIKey , 80, ECB);
Any assistance would be greatly appreciated.