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.

127 lines
3.3 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: Algorithm.h
  4. Content: Declaration of the CAlgorithm.
  5. History: 11-15-99 dsie created
  6. ------------------------------------------------------------------------------*/
  7. #ifndef __ALGORITHM_H_
  8. #define __ALGORITHM_H_
  9. #include "Resource.h"
  10. #include "Lock.h"
  11. #include "Error.h"
  12. #include "Debug.h"
  13. ////////////////////////////////////////////////////////////////////////////////
  14. //
  15. // Exported functions.
  16. //
  17. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18. Function : CreateAlgorithmObject
  19. Synopsis : Create an IAlgorithm object.
  20. Parameter: BOOL bReadOnly - TRUE if read-only, else FASLE.
  21. BOOL bAESAllowed - TRUE if AES algorithm is allowed.
  22. IAlgorithm ** ppIAlgorithm - Pointer to pointer to IAlgorithm
  23. to receive the interface pointer.
  24. Remark :
  25. ------------------------------------------------------------------------------*/
  26. HRESULT CreateAlgorithmObject (BOOL bReadOnly,
  27. BOOL bAESAllowed,
  28. IAlgorithm ** ppIAlgorithm);
  29. ////////////////////////////////////////////////////////////////////////////////
  30. //
  31. // CAlgorithm
  32. //
  33. class ATL_NO_VTABLE CAlgorithm :
  34. public CComObjectRootEx<CComMultiThreadModel>,
  35. public CComCoClass<CAlgorithm, &CLSID_Algorithm>,
  36. public ICAPICOMError<CAlgorithm, &IID_IAlgorithm>,
  37. public IDispatchImpl<IAlgorithm, &IID_IAlgorithm, &LIBID_CAPICOM,
  38. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  39. {
  40. public:
  41. CAlgorithm()
  42. {
  43. }
  44. DECLARE_NO_REGISTRY()
  45. DECLARE_GET_CONTROLLING_UNKNOWN()
  46. DECLARE_PROTECT_FINAL_CONSTRUCT()
  47. BEGIN_COM_MAP(CAlgorithm)
  48. COM_INTERFACE_ENTRY(IAlgorithm)
  49. COM_INTERFACE_ENTRY(IDispatch)
  50. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  51. END_COM_MAP()
  52. BEGIN_CATEGORY_MAP(CAlgorithm)
  53. END_CATEGORY_MAP()
  54. HRESULT FinalConstruct()
  55. {
  56. HRESULT hr;
  57. if (FAILED(hr = m_Lock.Initialized()))
  58. {
  59. DebugTrace("Error [%#x]: Critical section could not be created for Algorithm object.\n", hr);
  60. return hr;
  61. }
  62. m_bReadOnly = FALSE;
  63. m_bAESAllowed = FALSE;
  64. m_Name = CAPICOM_ENCRYPTION_ALGORITHM_RC2;
  65. m_KeyLength = CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM;
  66. return S_OK;
  67. }
  68. //
  69. // IAlgorithm
  70. //
  71. public:
  72. STDMETHOD(get_KeyLength)
  73. (/*[out, retval]*/ CAPICOM_ENCRYPTION_KEY_LENGTH * pVal);
  74. STDMETHOD(put_KeyLength)
  75. (/*[in]*/ CAPICOM_ENCRYPTION_KEY_LENGTH newVal);
  76. STDMETHOD(get_Name)
  77. (/*[out, retval]*/ CAPICOM_ENCRYPTION_ALGORITHM * pVal);
  78. STDMETHOD(put_Name)
  79. (/*[in]*/ CAPICOM_ENCRYPTION_ALGORITHM newVal);
  80. //
  81. // C++ member function needed to initialize the object.
  82. //
  83. STDMETHOD(Init)
  84. (BOOL bReadOnly,
  85. BOOL bAESAllowed);
  86. private:
  87. CLock m_Lock;
  88. BOOL m_bReadOnly;
  89. BOOL m_bAESAllowed;
  90. CAPICOM_ENCRYPTION_ALGORITHM m_Name;
  91. CAPICOM_ENCRYPTION_KEY_LENGTH m_KeyLength;
  92. };
  93. #endif //__ALGORITHM_H_