Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

811 lines
18 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: crldist.cpp
  7. //
  8. // Contents: Cert Server Extension Encoding/Decoding implementation
  9. //
  10. //---------------------------------------------------------------------------
  11. #include "pch.cpp"
  12. #pragma hdrstop
  13. #include <assert.h>
  14. #include "resource.h"
  15. #include "crldist.h"
  16. #include "celib.h"
  17. //+--------------------------------------------------------------------------
  18. // CCertEncodeCRLDistInfo::~CCertEncodeCRLDistInfo -- destructor
  19. //
  20. // free memory associated with this instance
  21. //+--------------------------------------------------------------------------
  22. CCertEncodeCRLDistInfo::~CCertEncodeCRLDistInfo()
  23. {
  24. _Cleanup();
  25. }
  26. //+--------------------------------------------------------------------------
  27. // CCertEncodeCRLDistInfo::_Cleanup -- release all resources
  28. //
  29. // free memory associated with this instance
  30. //+--------------------------------------------------------------------------
  31. VOID
  32. CCertEncodeCRLDistInfo::_Cleanup()
  33. {
  34. if (NULL != m_aValue)
  35. {
  36. if (!m_fConstructing)
  37. {
  38. if (NULL != m_DecodeInfo)
  39. {
  40. LocalFree(m_DecodeInfo);
  41. m_DecodeInfo = NULL;
  42. }
  43. }
  44. else
  45. {
  46. CRL_DIST_POINT *pDistPoint;
  47. CRL_DIST_POINT *pDistPointEnd;
  48. for (pDistPoint = m_aValue, pDistPointEnd = &m_aValue[m_cValue];
  49. pDistPoint < pDistPointEnd;
  50. pDistPoint++)
  51. {
  52. CERT_ALT_NAME_ENTRY *pName;
  53. CERT_ALT_NAME_ENTRY *pNameEnd;
  54. pName = pDistPoint->DistPointName.FullName.rgAltEntry;
  55. if (NULL != pName)
  56. {
  57. for (pNameEnd = &pName[pDistPoint->DistPointName.FullName.cAltEntry];
  58. pName < pNameEnd;
  59. pName++)
  60. {
  61. if (NULL != pName->pwszURL) // test arbitrary union arm
  62. {
  63. LocalFree(pName->pwszURL);
  64. }
  65. }
  66. LocalFree(pDistPoint->DistPointName.FullName.rgAltEntry);
  67. }
  68. }
  69. LocalFree(m_aValue);
  70. }
  71. m_aValue = NULL;
  72. }
  73. assert(NULL == m_DecodeInfo);
  74. m_fConstructing = FALSE;
  75. }
  76. //+--------------------------------------------------------------------------
  77. // CCertEncodeCRLDistInfo::_MapDistPoint -- map a distribution point
  78. //
  79. //+--------------------------------------------------------------------------
  80. HRESULT
  81. CCertEncodeCRLDistInfo::_MapDistPoint(
  82. IN BOOL fEncode,
  83. IN LONG DistPointIndex,
  84. OUT LONG **ppNameCount,
  85. OUT CERT_ALT_NAME_ENTRY ***ppaName)
  86. {
  87. HRESULT hr = S_OK;
  88. CRL_DIST_POINT *pDistPoint;
  89. if (fEncode)
  90. {
  91. pDistPoint = m_fConstructing? m_aValue : NULL;
  92. }
  93. else
  94. {
  95. pDistPoint = m_aValue;
  96. }
  97. if (NULL == pDistPoint)
  98. {
  99. hr = E_INVALIDARG;
  100. ceERRORPRINTLINE("bad parameter", hr);
  101. goto error;
  102. }
  103. if (m_cValue <= DistPointIndex)
  104. {
  105. ceERRORPRINTLINE("bad DistPointIndex parameter", hr);
  106. hr = E_INVALIDARG;
  107. goto error;
  108. }
  109. *ppNameCount =
  110. (LONG *) &pDistPoint[DistPointIndex].DistPointName.FullName.cAltEntry;
  111. *ppaName = &pDistPoint[DistPointIndex].DistPointName.FullName.rgAltEntry;
  112. error:
  113. return(hr);
  114. }
  115. //+--------------------------------------------------------------------------
  116. // CCertEncodeCRLDistInfo::_MapName -- map a name
  117. //
  118. //+--------------------------------------------------------------------------
  119. HRESULT
  120. CCertEncodeCRLDistInfo::_MapName(
  121. IN BOOL fEncode,
  122. IN LONG DistPointIndex,
  123. IN LONG NameIndex,
  124. OUT CERT_ALT_NAME_ENTRY **ppName)
  125. {
  126. HRESULT hr;
  127. LONG *pNameCount;
  128. CERT_ALT_NAME_ENTRY **paName;
  129. if (NULL == ppName)
  130. {
  131. hr = E_POINTER;
  132. ceERRORPRINTLINE("NULL parm", hr);
  133. goto error;
  134. }
  135. hr = _MapDistPoint(fEncode, DistPointIndex, &pNameCount, &paName);
  136. if (S_OK != hr)
  137. {
  138. ceERRORPRINTLINE("_MapDistPoint", hr);
  139. goto error;
  140. }
  141. if (*pNameCount <= NameIndex)
  142. {
  143. ceERRORPRINTLINE("bad NameIndex parameter", hr);
  144. hr = E_INVALIDARG;
  145. goto error;
  146. }
  147. *ppName = &(*paName)[NameIndex];
  148. error:
  149. return(hr);
  150. }
  151. //+--------------------------------------------------------------------------
  152. // CCertEncodeCRLDistInfo::Decode -- Decode CRLDistInfo
  153. //
  154. // Returns S_OK on success.
  155. //+--------------------------------------------------------------------------
  156. STDMETHODIMP
  157. CCertEncodeCRLDistInfo::Decode(
  158. /* [in] */ BSTR const strBinary)
  159. {
  160. HRESULT hr = S_OK;
  161. DWORD cbCRLDist;
  162. _Cleanup();
  163. if (NULL == strBinary)
  164. {
  165. hr = E_POINTER;
  166. ceERRORPRINTLINE("NULL parm", hr);
  167. goto error;
  168. }
  169. // Decode CRL_DIST_POINTS_INFO:
  170. if (!ceDecodeObject(
  171. X509_ASN_ENCODING,
  172. X509_CRL_DIST_POINTS,
  173. (BYTE *) strBinary,
  174. SysStringByteLen(strBinary),
  175. FALSE,
  176. (VOID **) &m_DecodeInfo,
  177. &cbCRLDist))
  178. {
  179. hr = ceHLastError();
  180. ceERRORPRINTLINE("ceDecodeObject", hr);
  181. goto error;
  182. }
  183. m_aValue = m_DecodeInfo->rgDistPoint;
  184. m_cValue = m_DecodeInfo->cDistPoint;
  185. error:
  186. if (S_OK != hr)
  187. {
  188. _Cleanup();
  189. }
  190. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::Decode"));
  191. }
  192. //+--------------------------------------------------------------------------
  193. // CCertEncodeCRLDistInfo::GetDistPointCount -- Get the Distribution Name Count
  194. //
  195. // Returns S_OK on success.
  196. //+--------------------------------------------------------------------------
  197. STDMETHODIMP
  198. CCertEncodeCRLDistInfo::GetDistPointCount(
  199. /* [out, retval] */ LONG __RPC_FAR *pDistPointCount)
  200. {
  201. HRESULT hr = E_INVALIDARG;
  202. if (NULL == m_aValue)
  203. {
  204. ceERRORPRINTLINE("bad parameter", hr);
  205. goto error;
  206. }
  207. if (NULL == pDistPointCount)
  208. {
  209. hr = E_POINTER;
  210. ceERRORPRINTLINE("NULL parm", hr);
  211. goto error;
  212. }
  213. *pDistPointCount = m_cValue;
  214. hr = S_OK;
  215. error:
  216. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetDistPointCount"));
  217. }
  218. //+--------------------------------------------------------------------------
  219. // CCertEncodeCRLDistInfo::GetNameCount -- Get a Name Count
  220. //
  221. // Returns S_OK on success.
  222. //+--------------------------------------------------------------------------
  223. STDMETHODIMP
  224. CCertEncodeCRLDistInfo::GetNameCount(
  225. /* [in] */ LONG DistPointIndex,
  226. /* [out, retval] */ LONG __RPC_FAR *pNameCount)
  227. {
  228. HRESULT hr;
  229. LONG *pCount;
  230. CERT_ALT_NAME_ENTRY **paName;
  231. if (NULL == pNameCount)
  232. {
  233. hr = E_POINTER;
  234. ceERRORPRINTLINE("NULL parm", hr);
  235. goto error;
  236. }
  237. hr = _MapDistPoint(FALSE, DistPointIndex, &pCount, &paName);
  238. if (S_OK != hr)
  239. {
  240. ceERRORPRINTLINE("_MapDistPoint", hr);
  241. goto error;
  242. }
  243. if (NULL == *paName)
  244. {
  245. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  246. ceERRORPRINTLINE("uninitialized", hr);
  247. goto error;
  248. }
  249. *pNameCount = *pCount;
  250. error:
  251. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetNameCount"));
  252. }
  253. //+--------------------------------------------------------------------------
  254. // CCertEncodeCRLDistInfo::GetNameChoice -- Get a Name Choice
  255. //
  256. // Returns S_OK on success.
  257. //+--------------------------------------------------------------------------
  258. STDMETHODIMP
  259. CCertEncodeCRLDistInfo::GetNameChoice(
  260. /* [in] */ LONG DistPointIndex,
  261. /* [in] */ LONG NameIndex,
  262. /* [out, retval] */ LONG __RPC_FAR *pNameChoice)
  263. {
  264. HRESULT hr;
  265. CERT_ALT_NAME_ENTRY *pName;
  266. if (NULL == pNameChoice)
  267. {
  268. hr = E_POINTER;
  269. ceERRORPRINTLINE("NULL parm", hr);
  270. goto error;
  271. }
  272. hr = _MapName(FALSE, DistPointIndex, NameIndex, &pName);
  273. if (S_OK != hr)
  274. {
  275. ceERRORPRINTLINE("_MapName", hr);
  276. goto error;
  277. }
  278. *pNameChoice = pName->dwAltNameChoice;
  279. if (0 == pName->dwAltNameChoice)
  280. {
  281. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  282. ceERRORPRINTLINE("uninitialized", hr);
  283. goto error;
  284. }
  285. error:
  286. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetNameChoice"));
  287. }
  288. //+--------------------------------------------------------------------------
  289. // CCertEncodeCRLDistInfo::GetName -- Get a Name
  290. //
  291. // Returns S_OK on success.
  292. //+--------------------------------------------------------------------------
  293. STDMETHODIMP
  294. CCertEncodeCRLDistInfo::GetName(
  295. /* [in] */ LONG DistPointIndex,
  296. /* [in] */ LONG NameIndex,
  297. /* [out, retval] */ BSTR __RPC_FAR *pstrName)
  298. {
  299. HRESULT hr;
  300. CERT_ALT_NAME_ENTRY *pName;
  301. WCHAR const *pwsz = NULL;
  302. char const *psz = NULL;
  303. if (NULL == pstrName)
  304. {
  305. hr = E_POINTER;
  306. ceERRORPRINTLINE("NULL parm", hr);
  307. goto error;
  308. }
  309. ceFreeBstr(pstrName);
  310. hr = _MapName(FALSE, DistPointIndex, NameIndex, &pName);
  311. if (S_OK != hr)
  312. {
  313. ceERRORPRINTLINE("_MapName", hr);
  314. goto error;
  315. }
  316. switch (pName->dwAltNameChoice)
  317. {
  318. case CERT_ALT_NAME_RFC822_NAME:
  319. pwsz = pName->pwszRfc822Name;
  320. break;
  321. case CERT_ALT_NAME_DNS_NAME:
  322. pwsz = pName->pwszDNSName;
  323. break;
  324. case CERT_ALT_NAME_URL:
  325. pwsz = pName->pwszURL;
  326. break;
  327. case CERT_ALT_NAME_REGISTERED_ID:
  328. psz = pName->pszRegisteredID;
  329. break;
  330. //case CERT_ALT_NAME_DIRECTORY_NAME:
  331. //case CERT_ALT_NAME_OTHER_NAME:
  332. //case CERT_ALT_NAME_X400_ADDRESS:
  333. //case CERT_ALT_NAME_EDI_PARTY_NAME:
  334. //case CERT_ALT_NAME_IP_ADDRESS:
  335. default:
  336. assert(0 == pName->dwAltNameChoice);
  337. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  338. ceERRORPRINTLINE("uninitialized", hr);
  339. goto error;
  340. }
  341. // we'd better assure 1 and only 1 of these is non null
  342. if ((NULL != pwsz) ^ (NULL == psz))
  343. {
  344. hr = E_UNEXPECTED;
  345. _JumpError(hr, error, "((NULL != pwsz) ^ (NULL == psz))");
  346. }
  347. hr = E_OUTOFMEMORY;
  348. if (NULL != pwsz)
  349. {
  350. if (!ceConvertWszToBstr(pstrName, pwsz, -1))
  351. {
  352. ceERRORPRINTLINE("no memory", hr);
  353. goto error;
  354. }
  355. }
  356. else
  357. {
  358. assert(NULL != psz);
  359. if (!ceConvertSzToBstr(pstrName, psz, -1))
  360. {
  361. ceERRORPRINTLINE("no memory", hr);
  362. goto error;
  363. }
  364. }
  365. hr = S_OK;
  366. error:
  367. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::GetName"));
  368. }
  369. //+--------------------------------------------------------------------------
  370. // CCertEncodeCRLDistInfo::Reset -- clear out data
  371. //
  372. // Returns S_OK on success.
  373. //+--------------------------------------------------------------------------
  374. STDMETHODIMP
  375. CCertEncodeCRLDistInfo::Reset(
  376. /* [in] */ LONG DistPointCount)
  377. {
  378. HRESULT hr = S_OK;
  379. CERT_NAME_VALUE *aNameValue = NULL;
  380. _Cleanup();
  381. m_fConstructing = TRUE;
  382. if (CENCODEMAX < DistPointCount || 0 > DistPointCount)
  383. {
  384. hr = E_INVALIDARG;
  385. ceERRORPRINTLINE("bad count parameter", hr);
  386. goto error;
  387. }
  388. m_aValue = (CRL_DIST_POINT *) LocalAlloc(
  389. LMEM_FIXED | LMEM_ZEROINIT,
  390. DistPointCount * sizeof(m_aValue[0]));
  391. if (NULL == m_aValue)
  392. {
  393. hr = E_OUTOFMEMORY;
  394. ceERRORPRINTLINE("LocalAlloc", hr);
  395. goto error;
  396. }
  397. m_cValue = DistPointCount;
  398. error:
  399. if (S_OK != hr)
  400. {
  401. _Cleanup();
  402. }
  403. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::Reset"));
  404. }
  405. //+--------------------------------------------------------------------------
  406. // CCertEncodeCRLDistInfo::SetNameCount -- Set the Name Count
  407. //
  408. // Returns S_OK on success.
  409. //+--------------------------------------------------------------------------
  410. STDMETHODIMP
  411. CCertEncodeCRLDistInfo::SetNameCount(
  412. /* [in] */ LONG DistPointIndex,
  413. /* [in] */ LONG NameCount)
  414. {
  415. HRESULT hr;
  416. LONG *pNameCount;
  417. CERT_ALT_NAME_ENTRY **paName;
  418. hr = E_INVALIDARG;
  419. if (!m_fConstructing)
  420. {
  421. ceERRORPRINTLINE("bad parameter", hr);
  422. goto error;
  423. }
  424. if (CENCODEMAX < NameCount || 0 > NameCount)
  425. {
  426. ceERRORPRINTLINE("bad count parameter", hr);
  427. goto error;
  428. }
  429. hr = _MapDistPoint(FALSE, DistPointIndex, &pNameCount, &paName);
  430. if (S_OK != hr)
  431. {
  432. ceERRORPRINTLINE("_MapDistPoint", hr);
  433. goto error;
  434. }
  435. if (0 != *pNameCount || NULL != *paName)
  436. {
  437. hr = E_INVALIDARG;
  438. ceERRORPRINTLINE("bad parameter", hr);
  439. goto error;
  440. }
  441. *paName = (CERT_ALT_NAME_ENTRY *) LocalAlloc(
  442. LMEM_FIXED | LMEM_ZEROINIT,
  443. NameCount * sizeof(CERT_ALT_NAME_ENTRY));
  444. if (NULL == *paName)
  445. {
  446. hr = E_OUTOFMEMORY;
  447. ceERRORPRINTLINE("LocalAlloc", hr);
  448. goto error;
  449. }
  450. *pNameCount = NameCount;
  451. error:
  452. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::SetNameCount"));
  453. }
  454. //+--------------------------------------------------------------------------
  455. // CCertEncodeCRLDistInfo::SetNameEntry -- Set a Name Netry
  456. //
  457. // Returns S_OK on success.
  458. //+--------------------------------------------------------------------------
  459. STDMETHODIMP
  460. CCertEncodeCRLDistInfo::SetNameEntry(
  461. /* [in] */ LONG DistPointIndex,
  462. /* [in] */ LONG NameIndex,
  463. /* [in] */ LONG NameChoice,
  464. /* [in] */ BSTR const strName)
  465. {
  466. HRESULT hr;
  467. CERT_ALT_NAME_ENTRY *pName;
  468. WCHAR **ppwsz = NULL;
  469. char **ppsz = NULL;
  470. if (NULL == strName)
  471. {
  472. hr = E_POINTER;
  473. ceERRORPRINTLINE("NULL parm", hr);
  474. goto error;
  475. }
  476. if (!m_fConstructing)
  477. {
  478. hr = E_INVALIDARG;
  479. ceERRORPRINTLINE("bad parameter", hr);
  480. goto error;
  481. }
  482. hr = _MapName(TRUE, DistPointIndex, NameIndex, &pName);
  483. if (S_OK != hr)
  484. {
  485. ceERRORPRINTLINE("_MapName", hr);
  486. goto error;
  487. }
  488. if (NULL != pName->pwszURL)
  489. {
  490. hr = E_INVALIDARG;
  491. ceERRORPRINTLINE("bad parameter", hr);
  492. goto error;
  493. }
  494. switch (NameChoice)
  495. {
  496. case CERT_ALT_NAME_RFC822_NAME:
  497. ppwsz = &pName->pwszRfc822Name;
  498. break;
  499. case CERT_ALT_NAME_DNS_NAME:
  500. ppwsz = &pName->pwszDNSName;
  501. break;
  502. case CERT_ALT_NAME_URL:
  503. ppwsz = &pName->pwszURL;
  504. break;
  505. case CERT_ALT_NAME_REGISTERED_ID:
  506. hr = ceVerifyObjId(strName);
  507. if (S_OK != hr)
  508. {
  509. ceERRORPRINTLINE("ceVerifyObjId", hr);
  510. goto error;
  511. }
  512. ppsz = &pName->pszRegisteredID;
  513. break;
  514. //case CERT_ALT_NAME_DIRECTORY_NAME:
  515. //case CERT_ALT_NAME_OTHER_NAME:
  516. //case CERT_ALT_NAME_X400_ADDRESS:
  517. //case CERT_ALT_NAME_EDI_PARTY_NAME:
  518. //case CERT_ALT_NAME_IP_ADDRESS:
  519. }
  520. if (NULL != ppwsz)
  521. {
  522. if (NULL != *ppwsz)
  523. {
  524. hr = E_INVALIDARG;
  525. ceERRORPRINTLINE("string already set", hr);
  526. goto error;
  527. }
  528. hr = ceVerifyAltNameString(NameChoice, strName);
  529. if (S_OK != hr)
  530. {
  531. ceERRORPRINTLINE("ceVerifyAltNameString", hr);
  532. goto error;
  533. }
  534. *ppwsz = ceDuplicateString(strName);
  535. if (NULL == *ppwsz)
  536. {
  537. hr = E_OUTOFMEMORY;
  538. ceERRORPRINTLINE("ceDuplicateString", hr);
  539. goto error;
  540. }
  541. }
  542. else if (NULL != ppsz)
  543. {
  544. if (NULL != *ppsz)
  545. {
  546. hr = E_INVALIDARG;
  547. ceERRORPRINTLINE("string already set", hr);
  548. goto error;
  549. }
  550. if (!ceConvertWszToSz(ppsz, strName, -1))
  551. {
  552. hr = E_OUTOFMEMORY;
  553. ceERRORPRINTLINE("ceConvertWszToSz", hr);
  554. goto error;
  555. }
  556. }
  557. else
  558. {
  559. hr = E_INVALIDARG;
  560. ceERRORPRINTLINE("bad NameChoice parameter", hr);
  561. goto error;
  562. }
  563. pName->dwAltNameChoice = NameChoice;
  564. error:
  565. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::SetNameEntry"));
  566. }
  567. //+--------------------------------------------------------------------------
  568. // CCertEncodeCRLDistInfo::_VerifyNames -- Verify names
  569. //
  570. // Returns S_OK on success.
  571. //+--------------------------------------------------------------------------
  572. BOOL
  573. CCertEncodeCRLDistInfo::_VerifyNames(
  574. IN LONG DistPointIndex)
  575. {
  576. HRESULT hr;
  577. BOOL fOk = FALSE;
  578. LONG Count;
  579. LONG *pNameCount;
  580. LONG i;
  581. CERT_ALT_NAME_ENTRY **paName;
  582. assert(m_fConstructing);
  583. hr = _MapDistPoint(TRUE, DistPointIndex, &pNameCount, &paName);
  584. if (S_OK != hr)
  585. {
  586. ceERRORPRINTLINE("_MapDistPoint", hr);
  587. goto error;
  588. }
  589. Count = *pNameCount;
  590. if (0 != Count)
  591. {
  592. CERT_ALT_NAME_ENTRY *pName;
  593. pName = *paName;
  594. assert(NULL != pName);
  595. for (i = 0; i < Count; pName++, i++)
  596. {
  597. if (NULL == pName->pwszURL) // test arbitrary union arm
  598. {
  599. hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
  600. ceERRORPRINTLINE("uninitialized name", hr);
  601. goto error;
  602. }
  603. }
  604. }
  605. fOk = TRUE;
  606. error:
  607. return(fOk);
  608. }
  609. //+--------------------------------------------------------------------------
  610. // CCertEncodeCRLDistInfo::Encode -- Encode CRLDistInfo
  611. //
  612. // Returns S_OK on success.
  613. //+--------------------------------------------------------------------------
  614. STDMETHODIMP
  615. CCertEncodeCRLDistInfo::Encode(
  616. /* [out, retval] */ BSTR __RPC_FAR *pstrBinary)
  617. {
  618. HRESULT hr = S_OK;
  619. CRL_DIST_POINTS_INFO CRLDistInfo;
  620. BYTE *pbEncoded = NULL;
  621. DWORD cbEncoded;
  622. LONG i;
  623. CRLDistInfo.cDistPoint = m_cValue;
  624. CRLDistInfo.rgDistPoint = m_aValue;
  625. if (NULL == pstrBinary)
  626. {
  627. hr = E_POINTER;
  628. ceERRORPRINTLINE("NULL parm", hr);
  629. goto error;
  630. }
  631. ceFreeBstr(pstrBinary);
  632. if (!m_fConstructing || NULL == m_aValue)
  633. {
  634. hr = E_INVALIDARG;
  635. ceERRORPRINTLINE("bad parameter", hr);
  636. goto error;
  637. }
  638. for (i = 0; i < m_cValue; i++)
  639. {
  640. m_aValue[i].DistPointName.dwDistPointNameChoice =
  641. CRL_DIST_POINT_FULL_NAME;
  642. // Verify all entries are initialized:
  643. if (!_VerifyNames(i))
  644. {
  645. hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
  646. ceERRORPRINTLINE("uninitialized name", hr);
  647. goto error;
  648. }
  649. }
  650. // Encode CRL_DIST_POINTS_INFO:
  651. if (!ceEncodeObject(
  652. X509_ASN_ENCODING,
  653. X509_CRL_DIST_POINTS,
  654. &CRLDistInfo,
  655. 0,
  656. FALSE,
  657. &pbEncoded,
  658. &cbEncoded))
  659. {
  660. hr = ceHLastError();
  661. ceERRORPRINTLINE("ceEncodeObject", hr);
  662. goto error;
  663. }
  664. if (!ceConvertWszToBstr(pstrBinary, (WCHAR const *) pbEncoded, cbEncoded))
  665. {
  666. hr = E_OUTOFMEMORY;
  667. ceERRORPRINTLINE("ceConvertWszToBstr", hr);
  668. goto error;
  669. }
  670. error:
  671. if (NULL != pbEncoded)
  672. {
  673. LocalFree(pbEncoded);
  674. }
  675. return(_SetErrorInfo(hr, L"CCertEncodeCRLDistInfo::Encode"));
  676. }
  677. //+--------------------------------------------------------------------------
  678. // CCertEncodeCRLDistInfo::_SetErrorInfo -- set error object information
  679. //
  680. // Returns passed HRESULT
  681. //+--------------------------------------------------------------------------
  682. HRESULT
  683. CCertEncodeCRLDistInfo::_SetErrorInfo(
  684. IN HRESULT hrError,
  685. IN WCHAR const *pwszDescription)
  686. {
  687. assert(FAILED(hrError) || S_OK == hrError || S_FALSE == hrError);
  688. if (FAILED(hrError))
  689. {
  690. HRESULT hr;
  691. hr = ceDispatchSetErrorInfo(
  692. hrError,
  693. pwszDescription,
  694. wszCLASS_CERTENCODECRLDISTINFO,
  695. &IID_ICertEncodeCRLDistInfo);
  696. assert(hr == hrError);
  697. }
  698. return(hrError);
  699. }