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.

136 lines
3.6 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: EnvelopedData.h
  4. Content: Declaration of the CEnvelopedData.
  5. History: 11-15-99 dsie created
  6. ------------------------------------------------------------------------------*/
  7. #ifndef __ENVELOPEDDATA_H_
  8. #define __ENVELOPEDDATA_H_
  9. #include "Resource.h"
  10. #include "Lock.h"
  11. #include "Error.h"
  12. #include "Debug.h"
  13. #include "Certificate.h"
  14. #include "Recipients.h"
  15. #include "Algorithm.h"
  16. #include "DialogUI.h"
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //
  19. // CEnvelopedData
  20. //
  21. class ATL_NO_VTABLE CEnvelopedData :
  22. public CComObjectRootEx<CComMultiThreadModel>,
  23. public CComCoClass<CEnvelopedData, &CLSID_EnvelopedData>,
  24. public ICAPICOMError<CEnvelopedData, &IID_IEnvelopedData>,
  25. public IPromptUser<CEnvelopedData>,
  26. public IDispatchImpl<IEnvelopedData, &IID_IEnvelopedData, &LIBID_CAPICOM,
  27. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>,
  28. public IObjectSafetyImpl<CEnvelopedData, INTERFACESAFE_FOR_UNTRUSTED_CALLER |
  29. INTERFACESAFE_FOR_UNTRUSTED_DATA>
  30. {
  31. public:
  32. CEnvelopedData()
  33. {
  34. }
  35. DECLARE_REGISTRY_RESOURCEID(IDR_ENVELOPEDDATA)
  36. DECLARE_GET_CONTROLLING_UNKNOWN()
  37. DECLARE_PROTECT_FINAL_CONSTRUCT()
  38. BEGIN_COM_MAP(CEnvelopedData)
  39. COM_INTERFACE_ENTRY(IEnvelopedData)
  40. COM_INTERFACE_ENTRY(IDispatch)
  41. COM_INTERFACE_ENTRY(IObjectSafety)
  42. COM_INTERFACE_ENTRY(IObjectWithSite)
  43. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  44. END_COM_MAP()
  45. BEGIN_CATEGORY_MAP(CEnvelopedData)
  46. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  47. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  48. END_CATEGORY_MAP()
  49. HRESULT FinalConstruct()
  50. {
  51. HRESULT hr;
  52. if (FAILED(hr = m_Lock.Initialized()))
  53. {
  54. DebugTrace("Error [%#x]: Critical section could not be created for EnvelopedData object.\n", hr);
  55. return hr;
  56. }
  57. if (FAILED(hr = Init()))
  58. {
  59. DebugTrace("Error [%#x]: CEnvelopedData::Init() failed inside CEnvelopedData::FinalConstruct().\n", hr);
  60. return hr;
  61. }
  62. return S_OK;
  63. }
  64. void FinalRelease()
  65. {
  66. if (m_ContentBlob.pbData)
  67. {
  68. ::CoTaskMemFree(m_ContentBlob.pbData);
  69. }
  70. m_pIAlgorithm.Release();
  71. m_pIRecipients.Release();
  72. }
  73. //
  74. // IEnvelopedData
  75. //
  76. public:
  77. STDMETHOD(Decrypt)
  78. (/*[in]*/ BSTR EnvelopedMessage);
  79. STDMETHOD(Encrypt)
  80. (/*[in, defaultvalue(CAPICOM_BASE64_ENCODE)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  81. /*[out, retval]*/ BSTR * pVal);
  82. STDMETHOD(get_Recipients)
  83. (/*[out, retval]*/ IRecipients ** pVal);
  84. STDMETHOD(get_Algorithm)
  85. (/*[out, retval]*/ IAlgorithm ** pVal);
  86. STDMETHOD(get_Content)
  87. (/*[out, retval]*/ BSTR * pVal);
  88. STDMETHOD(put_Content)
  89. (/*[in]*/ BSTR newVal);
  90. private:
  91. CLock m_Lock;
  92. BOOL m_bEnveloped;
  93. DATA_BLOB m_ContentBlob;
  94. CComPtr<IAlgorithm> m_pIAlgorithm;
  95. CComPtr<IRecipients> m_pIRecipients;
  96. STDMETHOD(Init)();
  97. STDMETHOD(OpenToEncode)
  98. (HCRYPTMSG * phMsg,
  99. HCRYPTPROV * hCryptProv);
  100. STDMETHOD(OpenToDecode)
  101. (HCRYPTPROV hCryptProv,
  102. BSTR EnvelopedMessage,
  103. HCRYPTMSG * phMsg);
  104. };
  105. #endif //__ENVELOPEDDATA_H_