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.

106 lines
2.9 KiB

  1. /**********************************************************************/
  2. /** Microsoft Passport **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 2001 **/
  4. /**********************************************************************/
  5. /*
  6. PassportCrypt.h
  7. defines the crypt object in passport manager
  8. FILE HISTORY:
  9. */
  10. // PassportCrypt.h : Declaration of the CCrypt
  11. #ifndef __CRYPT_H_
  12. #define __CRYPT_H_
  13. #include "resource.h" // main symbols
  14. #include "CoCrypt.h" // Added by ClassView
  15. #include "passportservice.h"
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CCrypt
  18. class ATL_NO_VTABLE CCrypt :
  19. public CComObjectRootEx<CComMultiThreadModel>,
  20. public CComCoClass<CCrypt, &CLSID_Crypt>,
  21. public ISupportErrorInfo,
  22. public IPassportService,
  23. public IDispatchImpl<IPassportCrypt, &IID_IPassportCrypt, &LIBID_PASSPORTLib>
  24. {
  25. public:
  26. CCrypt();
  27. ~CCrypt()
  28. {
  29. Cleanup();
  30. if( m_crypt )
  31. delete m_crypt;
  32. }
  33. public:
  34. DECLARE_REGISTRY_RESOURCEID(IDR_CRYPT)
  35. DECLARE_PROTECT_FINAL_CONSTRUCT()
  36. DECLARE_GET_CONTROLLING_UNKNOWN()
  37. BEGIN_COM_MAP(CCrypt)
  38. COM_INTERFACE_ENTRY(IPassportCrypt)
  39. COM_INTERFACE_ENTRY(IDispatch)
  40. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  41. COM_INTERFACE_ENTRY(IPassportService)
  42. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  43. END_COM_MAP()
  44. HRESULT FinalConstruct()
  45. {
  46. return CoCreateFreeThreadedMarshaler(
  47. GetControllingUnknown(), &m_pUnkMarshaler.p);
  48. }
  49. void FinalRelease()
  50. {
  51. m_pUnkMarshaler.Release();
  52. }
  53. CComPtr<IUnknown> m_pUnkMarshaler;
  54. // ISupportsErrorInfo
  55. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  56. // IPassportCrypt
  57. public:
  58. STDMETHOD(put_keyMaterial)(/*[in]*/ BSTR newVal);
  59. STDMETHOD(get_keyVersion)(/*[out, retval]*/ int *pVal);
  60. STDMETHOD(put_keyVersion)(/*[in]*/ int newVal);
  61. STDMETHOD(OnStartPage)(/*[in]*/ IUnknown* piUnk);
  62. STDMETHOD(Decrypt)(/*[in]*/ BSTR rawData, /*[out,retval]*/ BSTR *pUnencrypted);
  63. STDMETHOD(Encrypt)(/*[in]*/ BSTR rawData, /*[out,retval]*/ BSTR *pEncrypted);
  64. STDMETHOD(get_IsValid)(/*[out,retval]*/VARIANT_BOOL *pVal);
  65. STDMETHOD(Compress)(/*[in]*/ BSTR bstrIn, /*[out,retval]*/ BSTR *pbstrOut);
  66. STDMETHOD(Decompress)(/*[in]*/ BSTR bstrIn, /*[out,retval]*/ BSTR *pbstrOut);
  67. STDMETHOD(put_site)(/*[in]*/ BSTR bstrSiteName);
  68. STDMETHOD(put_host)(/*[in]*/ BSTR bstrHostName);
  69. // IPassportService
  70. public:
  71. STDMETHOD(Initialize)(BSTR, IServiceProvider*);
  72. STDMETHOD(Shutdown)();
  73. STDMETHOD(ReloadState)(IServiceProvider*);
  74. STDMETHOD(CommitState)(IServiceProvider*);
  75. STDMETHOD(DumpState)( BSTR* );
  76. protected:
  77. void Cleanup();
  78. CRegistryConfig* ObtainCRC();
  79. int m_keyVersion;
  80. time_t m_validUntil;
  81. CCoCrypt* m_crypt;
  82. LPSTR m_szSiteName;
  83. LPSTR m_szHostName;
  84. };
  85. #endif //__CRYPT_H_