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.

160 lines
4.4 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: SignedData.h
  4. Content: Declaration of the CSignedData.
  5. History: 11-15-99 dsie created
  6. ------------------------------------------------------------------------------*/
  7. #ifndef __SIGNEDDATA_H_
  8. #define __SIGNEDDATA_H_
  9. #include "Resource.h"
  10. #include "Error.h"
  11. #include "Lock.h"
  12. #include "Debug.h"
  13. #include "DialogUI.h"
  14. ///////////////////////////////////////////////////////////////////////////////
  15. //
  16. // CSignedData
  17. //
  18. class ATL_NO_VTABLE CSignedData :
  19. public CComObjectRootEx<CComMultiThreadModel>,
  20. public CComCoClass<CSignedData, &CLSID_SignedData>,
  21. public ICAPICOMError<CSignedData, &IID_ISignedData>,
  22. public IPromptUser<CSignedData>,
  23. public IDispatchImpl<ISignedData, &IID_ISignedData, &LIBID_CAPICOM,
  24. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>,
  25. public IObjectSafetyImpl<CSignedData, INTERFACESAFE_FOR_UNTRUSTED_CALLER |
  26. INTERFACESAFE_FOR_UNTRUSTED_DATA>
  27. {
  28. public:
  29. CSignedData()
  30. {
  31. }
  32. DECLARE_REGISTRY_RESOURCEID(IDR_SIGNEDDATA)
  33. DECLARE_GET_CONTROLLING_UNKNOWN()
  34. DECLARE_PROTECT_FINAL_CONSTRUCT()
  35. BEGIN_COM_MAP(CSignedData)
  36. COM_INTERFACE_ENTRY(ISignedData)
  37. COM_INTERFACE_ENTRY(IDispatch)
  38. COM_INTERFACE_ENTRY(IObjectSafety)
  39. COM_INTERFACE_ENTRY(IObjectWithSite)
  40. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  41. END_COM_MAP()
  42. BEGIN_CATEGORY_MAP(CSignedData)
  43. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  44. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  45. END_CATEGORY_MAP()
  46. HRESULT FinalConstruct()
  47. {
  48. HRESULT hr;
  49. if (FAILED(hr = m_Lock.Initialized()))
  50. {
  51. DebugTrace("Error [%#x]: Critical section could not be created for SignedData object.\n", hr);
  52. return hr;
  53. }
  54. m_bSigned = FALSE;
  55. m_bDetached = VARIANT_FALSE;
  56. m_ContentBlob.cbData = 0;
  57. m_ContentBlob.pbData = NULL;
  58. m_MessageBlob.cbData = 0;
  59. m_MessageBlob.pbData = NULL;
  60. return S_OK;
  61. }
  62. void FinalRelease()
  63. {
  64. if (m_ContentBlob.pbData)
  65. {
  66. ::CoTaskMemFree(m_ContentBlob.pbData);
  67. }
  68. if (m_MessageBlob.pbData)
  69. {
  70. ::CoTaskMemFree(m_MessageBlob.pbData);
  71. }
  72. }
  73. //
  74. // ISignedData
  75. //
  76. public:
  77. STDMETHOD(Verify)
  78. (/*[in]*/ BSTR SignedMessage,
  79. /*[in, defaultvalue(0)]*/ VARIANT_BOOL bDetached,
  80. /*[in, defaultvalue(CAPICOM_VERIFY_SIGNATURE_AND_CERTIFICATE)]*/ CAPICOM_SIGNED_DATA_VERIFY_FLAG VerifyFlag);
  81. STDMETHOD(CoSign)
  82. (/*[in, defaultvalue(NULL)]*/ ISigner * pSigner,
  83. /*[in, defaultvalue(CAPICOM_BASE64_ENCODE)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  84. /*[out, retval]*/ BSTR * pVal);
  85. STDMETHOD(Sign)
  86. (/*[in, defaultvalue(NULL)]*/ ISigner * pSigner,
  87. /*[in, defaultvalue(0)]*/ VARIANT_BOOL bDetached,
  88. /*[in, defaultvalue(CAPICOM_BASE64_ENCODE)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  89. /*[out, retval]*/ BSTR * pVal);
  90. STDMETHOD(get_Certificates)
  91. (/*[out, retval]*/ ICertificates ** pVal);
  92. STDMETHOD(get_Signers)
  93. (/*[out, retval]*/ ISigners ** pVal);
  94. STDMETHOD(get_Content)
  95. (/*[out, retval]*/ BSTR * pVal);
  96. STDMETHOD(put_Content)
  97. (/*[in]*/ BSTR newVal);
  98. private:
  99. CLock m_Lock;
  100. BOOL m_bSigned;
  101. VARIANT_BOOL m_bDetached;
  102. DATA_BLOB m_ContentBlob;
  103. DATA_BLOB m_MessageBlob;
  104. STDMETHOD(OpenToEncode)
  105. (CMSG_SIGNER_ENCODE_INFO * pSignerEncodeInfo,
  106. DATA_BLOB * pChainBlob,
  107. CAPICOM_CERTIFICATE_INCLUDE_OPTION IncludeOption,
  108. HCRYPTMSG * phMsg);
  109. STDMETHOD(OpenToDecode)
  110. (HCRYPTPROV hCryptProv,
  111. HCRYPTMSG * phMsg);
  112. STDMETHOD(SignContent)
  113. (ISigner2 * pISigner2,
  114. CMSG_SIGNER_ENCODE_INFO * pSignerEncodeInfo,
  115. DATA_BLOB * pChainBlob,
  116. VARIANT_BOOL bDetached,
  117. CAPICOM_ENCODING_TYPE EncodingType,
  118. BSTR * pVal);
  119. STDMETHOD(CoSignContent)
  120. (ISigner2 * pISigner2,
  121. CMSG_SIGNER_ENCODE_INFO * pSignerEncodeInfo,
  122. DATA_BLOB * pChainBlob,
  123. CAPICOM_ENCODING_TYPE EncodingType,
  124. BSTR * pVal);
  125. };
  126. #endif //__SIGNEDDATA_H_