| 524 | } |
| 525 | |
| 526 | BOOL GetTimeStampSignerInfo(PCMSG_SIGNER_INFO pSignerInfo, PCMSG_SIGNER_INFO* pCounterSignerInfo) |
| 527 | { |
| 528 | PCCERT_CONTEXT pCertContext = NULL; |
| 529 | BOOL fReturn = FALSE; |
| 530 | BOOL fResult; |
| 531 | DWORD dwSize; |
| 532 | |
| 533 | __try |
| 534 | { |
| 535 | *pCounterSignerInfo = NULL; |
| 536 | |
| 537 | // Loop through unathenticated attributes for |
| 538 | // szOID_RSA_counterSign OID. |
| 539 | for (DWORD n = 0; n < pSignerInfo->UnauthAttrs.cAttr; n++) |
| 540 | { |
| 541 | if (lstrcmpA(pSignerInfo->UnauthAttrs.rgAttr[n].pszObjId, |
| 542 | szOID_RSA_counterSign) == 0) |
| 543 | { |
| 544 | // Get size of CMSG_SIGNER_INFO structure. |
| 545 | fResult = CryptDecodeObject(ENCODING, |
| 546 | PKCS7_SIGNER_INFO, |
| 547 | pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].pbData, |
| 548 | pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].cbData, |
| 549 | 0, |
| 550 | NULL, |
| 551 | &dwSize); |
| 552 | if (!fResult) |
| 553 | { |
| 554 | //_tprintf(_T("CryptDecodeObject failed with %x\n"), |
| 555 | // GetLastError()); |
| 556 | __leave; |
| 557 | } |
| 558 | |
| 559 | // Allocate memory for CMSG_SIGNER_INFO. |
| 560 | *pCounterSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSize); |
| 561 | if (!*pCounterSignerInfo) |
| 562 | { |
| 563 | //_tprintf(_T("Unable to allocate memory for timestamp info.\n")); |
| 564 | __leave; |
| 565 | } |
| 566 | |
| 567 | // Decode and get CMSG_SIGNER_INFO structure |
| 568 | // for timestamp certificate. |
| 569 | fResult = CryptDecodeObject(ENCODING, |
| 570 | PKCS7_SIGNER_INFO, |
| 571 | pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].pbData, |
| 572 | pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].cbData, |
| 573 | 0, |
| 574 | (PVOID)*pCounterSignerInfo, |
| 575 | &dwSize); |
| 576 | if (!fResult) |
| 577 | { |
| 578 | //_tprintf(_T("CryptDecodeObject failed with %x\n"), |
| 579 | // GetLastError()); |
| 580 | __leave; |
| 581 | } |
| 582 | |
| 583 | fReturn = TRUE; |