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.

154 lines
3.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: SIPObjCT.cpp (Catalog)
  8. //
  9. // Contents: Microsoft SIP Provider
  10. //
  11. // History: 24-Feb-1997 pberkman created
  12. //
  13. //--------------------------------------------------------------------------
  14. #include "global.hxx"
  15. #include "sipobjct.hxx"
  16. #include "mscat.h"
  17. ////////////////////////////////////////////////////////////////////////////
  18. //
  19. // construct/destruct:
  20. //
  21. SIPObjectCatalog_::SIPObjectCatalog_(DWORD id) : SIPObject_(id)
  22. {
  23. }
  24. ////////////////////////////////////////////////////////////////////////////
  25. //
  26. // public:
  27. //
  28. BOOL SIPObjectCatalog_::GetSignedDataMsg(SIP_SUBJECTINFO *pSI,DWORD dwIdx,
  29. DWORD *pdwDLen,BYTE *pbData,
  30. DWORD *pdwEncodeType)
  31. {
  32. if ((dwIdx != 0) ||
  33. (!(pdwEncodeType)))
  34. {
  35. SetLastError((DWORD)ERROR_INVALID_PARAMETER);
  36. return(FALSE);
  37. }
  38. if (pSI->dwUnionChoice == MSSIP_ADDINFO_BLOB)
  39. {
  40. if (!(pSI->psBlob) ||
  41. !(_ISINSTRUCT(MS_ADDINFO_BLOB, pSI->psBlob->cbStruct, pbMemSignedMsg)))
  42. {
  43. SetLastError((DWORD)ERROR_INVALID_PARAMETER);
  44. return(FALSE);
  45. }
  46. if (!(pbData))
  47. {
  48. *pdwDLen = pSI->psBlob->cbMemObject;
  49. return(TRUE);
  50. }
  51. if (*pdwDLen < pSI->psBlob->cbMemObject)
  52. {
  53. SetLastError(ERROR_INSUFFICIENT_BUFFER);
  54. return(FALSE);
  55. }
  56. memcpy(pbData, pSI->psBlob->pbMemObject, pSI->psBlob->cbMemObject);
  57. return(TRUE);
  58. }
  59. if (this->FileHandleFromSubject(pSI))
  60. {
  61. *pdwEncodeType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
  62. if (!(pbData))
  63. {
  64. *pdwDLen = this->cbFileMap;
  65. return(TRUE);
  66. }
  67. if (this->cbFileMap > *pdwDLen)
  68. {
  69. SetLastError(ERROR_INSUFFICIENT_BUFFER);
  70. return(FALSE);
  71. }
  72. __try {
  73. memcpy(pbData, this->pbFileMap, this->cbFileMap);
  74. }
  75. __except(EXCEPTION_EXECUTE_HANDLER) {
  76. SetLastError(GetExceptionCode());
  77. return(FALSE);
  78. }
  79. return(TRUE);
  80. }
  81. return(FALSE);
  82. }
  83. BOOL SIPObjectCatalog_::PutSignedDataMsg(SIP_SUBJECTINFO *pSI,DWORD *dwIdx,
  84. DWORD dwDLen,BYTE *pbData,
  85. DWORD dwEncodeType)
  86. {
  87. if (!(pbData))
  88. {
  89. SetLastError((DWORD)ERROR_INVALID_PARAMETER);
  90. return(FALSE);
  91. }
  92. this->fUseFileMap = FALSE;
  93. if (this->FileHandleFromSubject(pSI, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ))
  94. {
  95. if (SetFilePointer(this->hFile, 0, NULL, FILE_BEGIN) == 0xFFFFFFFF)
  96. {
  97. return(FALSE);
  98. }
  99. SetEndOfFile(this->hFile);
  100. DWORD cbWritten;
  101. cbWritten = 0;
  102. if (!(WriteFile(this->hFile, pbData, dwDLen, &cbWritten, NULL)) ||
  103. (cbWritten != dwDLen))
  104. {
  105. return(FALSE);
  106. }
  107. return(TRUE);
  108. }
  109. return(FALSE);
  110. }
  111. BOOL SIPObjectCatalog_::CreateIndirectData(SIP_SUBJECTINFO *pSI,DWORD *pdwDLen,
  112. SIP_INDIRECT_DATA *psData)
  113. {
  114. if (pdwDLen)
  115. {
  116. *pdwDLen = 0;
  117. }
  118. return(TRUE);
  119. }