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.

140 lines
3.6 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: KeyUsage.h
  5. Content: Declaration of the CKeyUsage.
  6. History: 11-15-99 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __KEYUSAGE_H_
  9. #define __KEYUSAGE_H_
  10. #include "Resource.h"
  11. #include "Lock.h"
  12. #include "Error.h"
  13. #include "Debug.h"
  14. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  15. Function : CreateKeyUsageObject
  16. Synopsis : Create a IKeyUsage object and populate the porperties with
  17. data from the key usage extension of the specified certificate.
  18. Parameter: PCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT to be used
  19. to initialize the IKeyUsage object.
  20. IKeyUsage ** ppIKeyUsage - Pointer to pointer IKeyUsage object.
  21. Remark :
  22. ------------------------------------------------------------------------------*/
  23. HRESULT CreateKeyUsageObject (PCCERT_CONTEXT pCertContext, IKeyUsage ** ppIKeyUsage);
  24. ////////////////////////////////////////////////////////////////////////////////
  25. //
  26. // CKeyUsage
  27. //
  28. class ATL_NO_VTABLE CKeyUsage :
  29. public CComObjectRootEx<CComMultiThreadModel>,
  30. public CComCoClass<CKeyUsage, &CLSID_KeyUsage>,
  31. public ICAPICOMError<CKeyUsage, &IID_IKeyUsage>,
  32. public IDispatchImpl<IKeyUsage, &IID_IKeyUsage, &LIBID_CAPICOM,
  33. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  34. {
  35. public:
  36. CKeyUsage()
  37. {
  38. }
  39. DECLARE_NO_REGISTRY()
  40. DECLARE_GET_CONTROLLING_UNKNOWN()
  41. DECLARE_PROTECT_FINAL_CONSTRUCT()
  42. BEGIN_COM_MAP(CKeyUsage)
  43. COM_INTERFACE_ENTRY(IKeyUsage)
  44. COM_INTERFACE_ENTRY(IDispatch)
  45. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  46. END_COM_MAP()
  47. BEGIN_CATEGORY_MAP(CKeyUsage)
  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 KeyUsage object.\n", hr);
  55. return hr;
  56. }
  57. m_dwKeyUsages = 0;
  58. m_bIsPresent = VARIANT_FALSE;
  59. m_bIsCritical = VARIANT_FALSE;
  60. return S_OK;
  61. }
  62. //
  63. // IKeyUsage
  64. //
  65. public:
  66. STDMETHOD(get_IsDecipherOnlyEnabled)
  67. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  68. STDMETHOD(get_IsEncipherOnlyEnabled)
  69. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  70. STDMETHOD(get_IsCRLSignEnabled)
  71. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  72. STDMETHOD(get_IsKeyCertSignEnabled)
  73. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  74. STDMETHOD(get_IsKeyAgreementEnabled)
  75. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  76. STDMETHOD(get_IsDataEnciphermentEnabled)
  77. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  78. STDMETHOD(get_IsKeyEnciphermentEnabled)
  79. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  80. STDMETHOD(get_IsNonRepudiationEnabled)
  81. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  82. STDMETHOD(get_IsDigitalSignatureEnabled)
  83. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  84. STDMETHOD(get_IsCritical)
  85. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  86. STDMETHOD(get_IsPresent)
  87. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  88. //
  89. // None COM functions.
  90. //
  91. STDMETHOD(Init)
  92. (PCCERT_CONTEXT pCertContext);
  93. private:
  94. CLock m_Lock;
  95. DWORD m_dwKeyUsages;
  96. VARIANT_BOOL m_bIsPresent;
  97. VARIANT_BOOL m_bIsCritical;
  98. };
  99. #endif //__KEYUSAGE_H_