Leaked source code of windows server 2003
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.

118 lines
3.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: memory.cpp
  8. //
  9. // Contents: Microsoft Internet Security Trust Provider
  10. //
  11. // Functions: WVTNew
  12. // WVTDelete
  13. // WVTAddStore
  14. // WVTAddSigner
  15. // WVTAddCertContext
  16. // WVTAddPrivateData
  17. //
  18. // History: 07-Jun-1997 pberkman created
  19. //
  20. //--------------------------------------------------------------------------
  21. #include "global.hxx"
  22. // PFN_CPD_MEM_ALLOC
  23. void *WVTNew(DWORD cbSize)
  24. {
  25. void *pvRet;
  26. pvRet = (void *)new char[cbSize];
  27. if (!(pvRet))
  28. {
  29. assert(pvRet);
  30. SetLastError(ERROR_NOT_ENOUGH_MEMORY);
  31. }
  32. return(pvRet);
  33. }
  34. // PFN_CPD_MEM_FREE
  35. void WVTDelete(void *pvMem)
  36. {
  37. DELETE_OBJECT(pvMem);
  38. }
  39. // PFN_CPD_ADD_STORE
  40. BOOL WVTAddStore(CRYPT_PROVIDER_DATA *pProvData, HCERTSTORE hStore)
  41. {
  42. HCERTSTORE hStoreDup;
  43. hStoreDup = CertDuplicateStore(hStore);
  44. return(AddToStoreChain(hStoreDup, &pProvData->chStores, &pProvData->pahStores));
  45. }
  46. // PFN_CPD_ADD_SGNR
  47. BOOL WVTAddSigner(CRYPT_PROVIDER_DATA *pProvData,
  48. BOOL fCounterSigner,
  49. DWORD idxSigner,
  50. CRYPT_PROVIDER_SGNR *pSngr2Add)
  51. {
  52. if (fCounterSigner)
  53. {
  54. if (idxSigner > pProvData->csSigners)
  55. {
  56. return(FALSE);
  57. }
  58. return(AddToSignerChain(pSngr2Add,
  59. &pProvData->pasSigners[idxSigner].csCounterSigners,
  60. &pProvData->pasSigners[idxSigner].pasCounterSigners));
  61. }
  62. return(AddToSignerChain(pSngr2Add, &pProvData->csSigners, &pProvData->pasSigners));
  63. }
  64. // PFN_CPD_ADD_CERT
  65. BOOL WVTAddCertContext(CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner,
  66. BOOL fCounterSigner, DWORD idxCounterSigner, PCCERT_CONTEXT pCert)
  67. {
  68. CRYPT_PROVIDER_CERT sCert;
  69. if (idxSigner > pProvData->csSigners)
  70. {
  71. return(FALSE);
  72. }
  73. memset(&sCert, 0x00, sizeof(CRYPT_PROVIDER_CERT));
  74. sCert.cbStruct = sizeof(CRYPT_PROVIDER_CERT);
  75. sCert.pCert = CertDuplicateCertificateContext(pCert);
  76. if (fCounterSigner)
  77. {
  78. if (idxCounterSigner > pProvData->pasSigners[idxSigner].csCounterSigners)
  79. {
  80. return(FALSE);
  81. }
  82. return(AddToCertChain(&sCert,
  83. &pProvData->pasSigners[idxSigner].pasCounterSigners[idxCounterSigner].csCertChain,
  84. &pProvData->pasSigners[idxSigner].pasCounterSigners[idxCounterSigner].pasCertChain));
  85. }
  86. return(AddToCertChain(&sCert,
  87. &pProvData->pasSigners[idxSigner].csCertChain,
  88. &pProvData->pasSigners[idxSigner].pasCertChain));
  89. }
  90. // PFN_CPD_ADD_PRIVDATA
  91. BOOL WVTAddPrivateData(CRYPT_PROVIDER_DATA *pProvData, CRYPT_PROVIDER_PRIVDATA *psPrivData2Add)
  92. {
  93. return(AllocateNewChain(sizeof(CRYPT_PROVIDER_PRIVDATA), psPrivData2Add,
  94. &pProvData->csProvPrivData,
  95. (void **)&pProvData->pasProvPrivData,
  96. psPrivData2Add->cbStruct));
  97. }