| 366 | } |
| 367 | |
| 368 | static DWORD LoadCKeyEntry(TCascStorage * hs, const char * szVariableName, const char * szDataPtr, const char * szDataEnd, void * pvParam) |
| 369 | { |
| 370 | PCASC_CKEY_ENTRY pCKeyEntry = (PCASC_CKEY_ENTRY)pvParam; |
| 371 | size_t nLength = strlen(szVariableName); |
| 372 | size_t HashCount = 0; |
| 373 | |
| 374 | // Ignore "xxx-config" items |
| 375 | if(StringEndsWith(szVariableName, nLength, "-config", 7)) |
| 376 | return ERROR_SUCCESS; |
| 377 | |
| 378 | // If the variable ends at "-size", it means we need to capture the size |
| 379 | if(StringEndsWith(szVariableName, nLength, "-size", 5)) |
| 380 | { |
| 381 | DWORD ContentSize = CASC_INVALID_SIZE; |
| 382 | DWORD EncodedSize = CASC_INVALID_SIZE; |
| 383 | |
| 384 | // Load the content size |
| 385 | szDataPtr = CaptureDecimalInteger(szDataPtr, szDataEnd, &ContentSize); |
| 386 | if(szDataPtr == NULL) |
| 387 | return ERROR_BAD_FORMAT; |
| 388 | |
| 389 | CaptureDecimalInteger(szDataPtr, szDataEnd, &EncodedSize); |
| 390 | pCKeyEntry->ContentSize = ContentSize; |
| 391 | pCKeyEntry->EncodedSize = EncodedSize; |
| 392 | return ERROR_SUCCESS; |
| 393 | } |
| 394 | |
| 395 | // If the string doesn't end with "-config", assume it's the CKey/EKey |
| 396 | else |
| 397 | { |
| 398 | // Get the number of hashes. It is expected to be 1 or 2 |
| 399 | if(CaptureHashCount(szDataPtr, szDataEnd, &HashCount) != NULL) |
| 400 | { |
| 401 | // Capture the CKey |
| 402 | if(HashCount >= 1) |
| 403 | { |
| 404 | // Load the CKey. This should alway be there |
| 405 | szDataPtr = CaptureSingleHash(szDataPtr, szDataEnd, pCKeyEntry->CKey, MD5_HASH_SIZE); |
| 406 | if(szDataPtr == NULL) |
| 407 | return ERROR_BAD_FORMAT; |
| 408 | pCKeyEntry->Flags |= CASC_CE_HAS_CKEY; |
| 409 | } |
| 410 | |
| 411 | // Capture EKey, if any |
| 412 | if(HashCount == 2) |
| 413 | { |
| 414 | // Load the EKey into the structure |
| 415 | szDataPtr = CaptureSingleHash(szDataPtr, szDataEnd, pCKeyEntry->EKey, MD5_HASH_SIZE); |
| 416 | if(szDataPtr == NULL) |
| 417 | return ERROR_BAD_FORMAT; |
| 418 | pCKeyEntry->Flags |= CASC_CE_HAS_EKEY; |
| 419 | |
| 420 | // Increment the number of EKey entries loaded from text build file |
| 421 | hs->EKeyEntries++; |
| 422 | } |
| 423 | |
| 424 | return (HashCount == 1 || HashCount == 2) ? ERROR_SUCCESS : ERROR_BAD_FORMAT; |
| 425 | } |
no test coverage detected