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.

167 lines
4.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: sipadd.cpp
  8. //
  9. // Contents: Microsoft Internet Security SIP Provider
  10. //
  11. // Functions: CryptSIPAddProvider
  12. //
  13. // *** local functions ***
  14. // _RegisterSIPFunc
  15. //
  16. // History: 04-Jun-1997 pberkman created
  17. //
  18. //--------------------------------------------------------------------------
  19. #include "global.hxx"
  20. #include "cryptreg.h"
  21. #include "wintrust.h"
  22. #include "sipbase.h"
  23. BOOL _RegisterSIPFunc(char *pszTag, char *pszGuid, WCHAR *pwszDll, WCHAR *pwszFunc);
  24. BOOL WINAPI CryptSIPAddProvider(IN SIP_ADD_NEWPROVIDER *psNewProv)
  25. {
  26. BOOL fRet;
  27. char szGuid[REG_MAX_GUID_TEXT];
  28. fRet = TRUE;
  29. if (!(psNewProv) ||
  30. !(WVT_ISINSTRUCT(SIP_ADD_NEWPROVIDER, psNewProv->cbStruct, pwszRemoveFuncName)) ||
  31. !(psNewProv->pwszDLLFileName) ||
  32. !(psNewProv->pwszGetFuncName) ||
  33. !(psNewProv->pwszPutFuncName) ||
  34. !(psNewProv->pwszCreateFuncName) ||
  35. !(psNewProv->pwszVerifyFuncName) ||
  36. !(psNewProv->pwszRemoveFuncName))
  37. {
  38. goto InvalidParam;
  39. }
  40. if (!(_Guid2Sz(psNewProv->pgSubject, &szGuid[0])))
  41. {
  42. goto GuidConvertFailed;
  43. }
  44. if (!(_RegisterSIPFunc(SIPFUNC_PUTSIGNATURE, &szGuid[0],
  45. psNewProv->pwszDLLFileName, psNewProv->pwszPutFuncName)))
  46. {
  47. goto RegisterPutFailed;
  48. }
  49. if (!(_RegisterSIPFunc(SIPFUNC_GETSIGNATURE, &szGuid[0],
  50. psNewProv->pwszDLLFileName, psNewProv->pwszGetFuncName)))
  51. {
  52. goto RegisterGetFailed;
  53. }
  54. if (!(_RegisterSIPFunc(SIPFUNC_REMSIGNATURE, &szGuid[0],
  55. psNewProv->pwszDLLFileName, psNewProv->pwszRemoveFuncName)))
  56. {
  57. goto RegisterRemoveFailed;
  58. }
  59. if (!(_RegisterSIPFunc(SIPFUNC_CREATEINDIRECT, &szGuid[0],
  60. psNewProv->pwszDLLFileName, psNewProv->pwszCreateFuncName)))
  61. {
  62. goto RegisterCreateFailed;
  63. }
  64. if (!(_RegisterSIPFunc(SIPFUNC_VERIFYINDIRECT, &szGuid[0],
  65. psNewProv->pwszDLLFileName, psNewProv->pwszVerifyFuncName)))
  66. {
  67. goto RegisterVerifyFailed;
  68. }
  69. if (psNewProv->pwszIsFunctionName)
  70. {
  71. if (!(_RegisterSIPFunc(SIPFUNC_ISMYTYPE, &szGuid[0],
  72. psNewProv->pwszDLLFileName, psNewProv->pwszIsFunctionName)))
  73. {
  74. goto RegisterIsMyTypeFailed;
  75. }
  76. }
  77. if ((WVT_ISINSTRUCT(SIP_ADD_NEWPROVIDER, psNewProv->cbStruct, pwszIsFunctionNameFmt2)) &&
  78. (psNewProv->pwszIsFunctionNameFmt2))
  79. {
  80. if (!(_RegisterSIPFunc(SIPFUNC_ISMYTYPE2, &szGuid[0],
  81. psNewProv->pwszDLLFileName, psNewProv->pwszIsFunctionNameFmt2)))
  82. {
  83. goto RegisterIsMyType2Failed;
  84. }
  85. }
  86. fRet = TRUE;
  87. CommonReturn:
  88. return(fRet);
  89. ErrorReturn:
  90. fRet = FALSE;
  91. goto CommonReturn;
  92. TRACE_ERROR_EX(DBG_SS, RegisterPutFailed);
  93. TRACE_ERROR_EX(DBG_SS, RegisterGetFailed);
  94. TRACE_ERROR_EX(DBG_SS, RegisterRemoveFailed);
  95. TRACE_ERROR_EX(DBG_SS, RegisterCreateFailed);
  96. TRACE_ERROR_EX(DBG_SS, RegisterVerifyFailed);
  97. TRACE_ERROR_EX(DBG_SS, RegisterIsMyTypeFailed);
  98. TRACE_ERROR_EX(DBG_SS, RegisterIsMyType2Failed);
  99. TRACE_ERROR_EX(DBG_SS, GuidConvertFailed);
  100. SET_ERROR_VAR_EX(DBG_SS, InvalidParam, ERROR_INVALID_PARAMETER);
  101. }
  102. BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
  103. {
  104. BOOL fRet;
  105. char szGuid[REG_MAX_GUID_TEXT];
  106. if (!(pgProv))
  107. {
  108. goto InvalidParam;
  109. }
  110. if (!(_Guid2Sz(pgProv, &szGuid[0])))
  111. {
  112. goto GuidConvertFailed;
  113. }
  114. fRet = TRUE;
  115. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_PUTSIGNATURE, &szGuid[0]);
  116. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_GETSIGNATURE, &szGuid[0]);
  117. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_REMSIGNATURE, &szGuid[0]);
  118. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_CREATEINDIRECT, &szGuid[0]);
  119. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_VERIFYINDIRECT, &szGuid[0]);
  120. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_ISMYTYPE, &szGuid[0]);
  121. fRet &= CryptUnregisterOIDFunction(0, SIPFUNC_ISMYTYPE2, &szGuid[0]);
  122. CommonReturn:
  123. return(fRet);
  124. ErrorReturn:
  125. fRet = FALSE;
  126. goto CommonReturn;
  127. TRACE_ERROR_EX(DBG_SS, GuidConvertFailed);
  128. SET_ERROR_VAR_EX(DBG_SS, InvalidParam, ERROR_INVALID_PARAMETER);
  129. }
  130. BOOL _RegisterSIPFunc(char *pszTag, char *pszGuid, WCHAR *pwszDll, WCHAR *pwszFunc)
  131. {
  132. char szFunc[REG_MAX_FUNC_NAME];
  133. WideCharToMultiByte(0, 0, pwszFunc, -1, &szFunc[0], REG_MAX_FUNC_NAME, NULL, NULL);
  134. return(CryptRegisterOIDFunction(0, pszTag, pszGuid, pwszDll, &szFunc[0]));
  135. }