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.

144 lines
3.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: SIPObjFL.cpp (Flat)
  8. //
  9. // Contents: Microsoft SIP Provider
  10. //
  11. // History: 15-Feb-1997 pberkman created
  12. //
  13. //--------------------------------------------------------------------------
  14. #include "global.hxx"
  15. #include "sipobjfl.hxx"
  16. ////////////////////////////////////////////////////////////////////////////
  17. //
  18. // construct/destruct:
  19. //
  20. SIPObjectFlat_::SIPObjectFlat_(DWORD id) : SIPObject_(id)
  21. {
  22. memset(&SpcLink,0x00,sizeof(SPC_LINK));
  23. SpcLink.dwLinkChoice = SPC_FILE_LINK_CHOICE;
  24. SpcLink.pwszFile = OBSOLETE_TEXT_W;
  25. }
  26. ////////////////////////////////////////////////////////////////////////////
  27. //
  28. // public:
  29. //
  30. BOOL SIPObjectFlat_::GetSignedDataMsg(SIP_SUBJECTINFO *pSI,DWORD dwIdx,
  31. DWORD *pdwDLen,BYTE *pbData,
  32. DWORD *pdwEncodeType)
  33. {
  34. *pdwDLen = 0;
  35. *pdwEncodeType = PKCS_7_ASN_ENCODING | X509_ASN_ENCODING;
  36. return(TRUE);
  37. }
  38. BOOL SIPObjectFlat_::VerifyIndirectData(SIP_SUBJECTINFO *pSI,
  39. SIP_INDIRECT_DATA *psData)
  40. {
  41. MS_ADDINFO_FLAT *pAddInfo;
  42. SIP_INDIRECT_DATA *pInd;
  43. if (!(WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(SIP_SUBJECTINFO, pSI->cbSize, dwUnionChoice)) ||
  44. !(pSI->psFlat) ||
  45. !(psData))
  46. {
  47. if (this->FileHandleFromSubject(pSI)) // if the file exists, set bad parameter!
  48. {
  49. SetLastError((DWORD)ERROR_INVALID_PARAMETER);
  50. }
  51. return(FALSE);
  52. }
  53. if ((pSI->dwUnionChoice == MSSIP_ADDINFO_FLAT) &&
  54. (pSI->psFlat->cbStruct == sizeof(MS_ADDINFO_FLAT)))
  55. {
  56. pInd = pSI->psFlat->pIndirectData;
  57. }
  58. else if ((pSI->dwUnionChoice == MSSIP_ADDINFO_CATMEMBER) &&
  59. (pSI->psCatMember->cbStruct == sizeof(MS_ADDINFO_CATALOGMEMBER)))
  60. {
  61. if (!(pSI->psCatMember->pMember) ||
  62. (pSI->psCatMember->pMember->cbStruct != sizeof(CRYPTCATMEMBER)) ||
  63. !(pSI->psCatMember->pMember->pIndirectData))
  64. {
  65. if (this->FileHandleFromSubject(pSI)) // if the file exists, set bad parameter!
  66. {
  67. SetLastError((DWORD)ERROR_INVALID_PARAMETER);
  68. }
  69. return(FALSE);
  70. }
  71. pInd = pSI->psCatMember->pMember->pIndirectData;
  72. }
  73. else
  74. {
  75. SetLastError((DWORD)ERROR_INVALID_PARAMETER);
  76. return(FALSE);
  77. }
  78. if (this->FileHandleFromSubject(pSI))
  79. {
  80. DWORD cbDigest;
  81. BYTE *pbDigest;
  82. if (!(pbDigest = this->DigestFile( pSI->hProv,
  83. 0,
  84. pInd->DigestAlgorithm.pszObjId,
  85. &cbDigest)))
  86. {
  87. return(FALSE);
  88. }
  89. if ((cbDigest != pInd->Digest.cbData) ||
  90. (memcmp(pbDigest, pInd->Digest.pbData, cbDigest) != 0))
  91. {
  92. delete pbDigest;
  93. SetLastError(TRUST_E_BAD_DIGEST);
  94. return(FALSE);
  95. }
  96. delete pbDigest;
  97. return(TRUE);
  98. }
  99. return(FALSE);
  100. }
  101. ////////////////////////////////////////////////////////////////////////////
  102. //
  103. // protected:
  104. //
  105. BOOL SIPObjectFlat_::GetDigestStream(DIGEST_DATA *pDigestData,
  106. DIGEST_FUNCTION pfnCallBack, DWORD dwFlags)
  107. {
  108. __try {
  109. if ((this->pbFileMap) && (this->cbFileMap > 0))
  110. {
  111. return(pfnCallBack((HSPCDIGESTDATA)pDigestData, this->pbFileMap, this->cbFileMap));
  112. }
  113. }
  114. __except(EXCEPTION_EXECUTE_HANDLER) {
  115. SetLastError(GetExceptionCode());
  116. }
  117. return(FALSE);
  118. }