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.

141 lines
4.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: provider.cpp
  8. //
  9. // Contents: Microsoft Internet Security Trust Provider
  10. //
  11. // Functions: WintrustAddProvider
  12. // WintrustRemoveProvider
  13. //
  14. // History: 30-May-1997 pberkman created
  15. //
  16. //--------------------------------------------------------------------------
  17. #include "global.hxx"
  18. #include "cryptreg.h"
  19. static void inline MySetRegProvider(
  20. GUID *pgActionID,
  21. WCHAR *pwszRegKey,
  22. WCHAR *pwszDLLName,
  23. WCHAR *pwszFuncName,
  24. BOOL *pfRet,
  25. DWORD *pdwErr
  26. )
  27. {
  28. BOOL fRet;
  29. fRet = SetRegProvider(pgActionID, pwszRegKey, pwszDLLName, pwszFuncName);
  30. if (!fRet && *pfRet) {
  31. *pfRet = FALSE;
  32. *pdwErr = GetLastError();
  33. }
  34. }
  35. BOOL WINAPI WintrustAddActionID(IN GUID *pgActionID,
  36. IN DWORD fdwFlags,
  37. IN CRYPT_REGISTER_ACTIONID *psProvInfo)
  38. {
  39. if (!(psProvInfo) ||
  40. !(WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(CRYPT_REGISTER_ACTIONID, psProvInfo->cbStruct, sTestPolicyProvider)))
  41. {
  42. SetLastError(ERROR_INVALID_PARAMETER);
  43. return(FALSE);
  44. }
  45. BOOL fRet;
  46. DWORD dwErr;
  47. fRet = TRUE;
  48. dwErr = 0;
  49. MySetRegProvider(pgActionID,
  50. REG_INIT_PROVIDER_KEY,
  51. psProvInfo->sInitProvider.pwszDLLName,
  52. psProvInfo->sInitProvider.pwszFunctionName,
  53. &fRet,
  54. &dwErr);
  55. MySetRegProvider(pgActionID,
  56. REG_OBJTRUST_PROVIDER_KEY,
  57. psProvInfo->sObjectProvider.pwszDLLName,
  58. psProvInfo->sObjectProvider.pwszFunctionName,
  59. &fRet,
  60. &dwErr);
  61. MySetRegProvider(pgActionID,
  62. REG_SIGTRUST_PROVIDER_KEY,
  63. psProvInfo->sSignatureProvider.pwszDLLName,
  64. psProvInfo->sSignatureProvider.pwszFunctionName,
  65. &fRet,
  66. &dwErr);
  67. MySetRegProvider(pgActionID,
  68. REG_CERTTRUST_PROVIDER_KEY,
  69. psProvInfo->sCertificateProvider.pwszDLLName,
  70. psProvInfo->sCertificateProvider.pwszFunctionName,
  71. &fRet,
  72. &dwErr);
  73. MySetRegProvider(pgActionID,
  74. REG_CERTPOL_PROVIDER_KEY,
  75. psProvInfo->sCertificatePolicyProvider.pwszDLLName,
  76. psProvInfo->sCertificatePolicyProvider.pwszFunctionName,
  77. &fRet,
  78. &dwErr);
  79. MySetRegProvider(pgActionID,
  80. REG_FINALPOL_PROVIDER_KEY,
  81. psProvInfo->sFinalPolicyProvider.pwszDLLName,
  82. psProvInfo->sFinalPolicyProvider.pwszFunctionName,
  83. &fRet,
  84. &dwErr);
  85. MySetRegProvider(pgActionID,
  86. REG_TESTPOL_PROVIDER_KEY,
  87. psProvInfo->sTestPolicyProvider.pwszDLLName,
  88. psProvInfo->sTestPolicyProvider.pwszFunctionName,
  89. &fRet,
  90. &dwErr);
  91. // this member was added 7/23/1997 pberkman
  92. if (WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(CRYPT_REGISTER_ACTIONID, psProvInfo->cbStruct, sCleanupProvider))
  93. {
  94. MySetRegProvider(pgActionID,
  95. REG_CLEANUP_PROVIDER_KEY,
  96. psProvInfo->sCleanupProvider.pwszDLLName,
  97. psProvInfo->sCleanupProvider.pwszFunctionName,
  98. &fRet,
  99. &dwErr);
  100. }
  101. if (!fRet && (fdwFlags & WT_ADD_ACTION_ID_RET_RESULT_FLAG))
  102. {
  103. SetLastError(dwErr);
  104. return FALSE;
  105. } else {
  106. return TRUE;
  107. }
  108. }
  109. BOOL WINAPI WintrustRemoveActionID(IN GUID *pgActionID)
  110. {
  111. RemoveRegProvider(pgActionID, REG_INIT_PROVIDER_KEY);
  112. RemoveRegProvider(pgActionID, REG_OBJTRUST_PROVIDER_KEY);
  113. RemoveRegProvider(pgActionID, REG_SIGTRUST_PROVIDER_KEY);
  114. RemoveRegProvider(pgActionID, REG_CERTTRUST_PROVIDER_KEY);
  115. RemoveRegProvider(pgActionID, REG_CERTPOL_PROVIDER_KEY);
  116. RemoveRegProvider(pgActionID, REG_FINALPOL_PROVIDER_KEY);
  117. RemoveRegProvider(pgActionID, REG_TESTPOL_PROVIDER_KEY);
  118. RemoveRegProvider(pgActionID, REG_CLEANUP_PROVIDER_KEY);
  119. return(TRUE);
  120. }