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.

157 lines
3.9 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: PublicKey.h
  5. Content: Declaration of CPublicKey.
  6. History: 06-15-2001 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __PUBLICKEY_H_
  9. #define __PUBLICKEY_H_
  10. #include "Resource.h"
  11. #include "Error.h"
  12. #include "Lock.h"
  13. #include "Debug.h"
  14. #if (0)
  15. typedef struct PublicKeyValues
  16. {
  17. PUBLICKEYSTRUC pks;
  18. RSAPUBKEY rsapubkey;
  19. BYTE modulus[1];
  20. } PUBLIC_KEY_VALUES, * PPUBLIC_KEY_VALUES;
  21. #endif
  22. ////////////////////////////////////////////////////////////////////////////////
  23. //
  24. // Exported functions.
  25. //
  26. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  27. Function : CreatePublicKeyObject
  28. Synopsis : Create and initialize an CPublicKey object.
  29. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT to be used
  30. to initialize the IPublicKey object.
  31. IPublicKey ** ppIPublicKey - Pointer to pointer IPublicKey object.
  32. Remark :
  33. ------------------------------------------------------------------------------*/
  34. HRESULT CreatePublicKeyObject (PCCERT_CONTEXT pCertContext,
  35. IPublicKey ** ppIPublicKey);
  36. ////////////////////////////////////////////////////////////////////////////////
  37. //
  38. // CPublicKey
  39. //
  40. class ATL_NO_VTABLE CPublicKey :
  41. public CComObjectRootEx<CComMultiThreadModel>,
  42. public CComCoClass<CPublicKey, &CLSID_PublicKey>,
  43. public ICAPICOMError<CPublicKey, &IID_IPublicKey>,
  44. public IDispatchImpl<IPublicKey, &IID_IPublicKey, &LIBID_CAPICOM,
  45. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  46. {
  47. public:
  48. CPublicKey()
  49. {
  50. }
  51. DECLARE_NO_REGISTRY()
  52. DECLARE_PROTECT_FINAL_CONSTRUCT()
  53. BEGIN_COM_MAP(CPublicKey)
  54. COM_INTERFACE_ENTRY(IPublicKey)
  55. COM_INTERFACE_ENTRY(IDispatch)
  56. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  57. END_COM_MAP()
  58. BEGIN_CATEGORY_MAP(CPublicKey)
  59. END_CATEGORY_MAP()
  60. HRESULT FinalConstruct()
  61. {
  62. HRESULT hr;
  63. if (FAILED(hr = m_Lock.Initialized()))
  64. {
  65. DebugTrace("Error [%#x]: Critical section could not be created for PublicKey object.\n", hr);
  66. return hr;
  67. }
  68. m_dwKeyLength = 0;
  69. // m_pPublicKeyValues = NULL;
  70. m_pIOID = NULL;
  71. m_pIEncodedKey = NULL;
  72. m_pIEncodedParams = NULL;
  73. return S_OK;
  74. }
  75. void FinalRelease()
  76. {
  77. #if (0)
  78. if (m_pPublicKeyValues)
  79. {
  80. ::CoTaskMemFree((LPVOID) m_pPublicKeyValues);
  81. }
  82. #endif
  83. m_pIOID.Release();
  84. m_pIEncodedKey.Release();
  85. m_pIEncodedParams.Release();
  86. }
  87. //
  88. // IPublicKey
  89. //
  90. public:
  91. STDMETHOD(get_Algorithm)
  92. (/*[out, retval]*/ IOID ** pVal);
  93. STDMETHOD(get_Length)
  94. (/*[out, retval]*/ long * pVal);
  95. #if (0)
  96. STDMETHOD(get_Exponent)
  97. (/*[out, retval]*/ long * pVal);
  98. STDMETHOD(get_Modulus)
  99. (/*[in, defaultvalue(CAPICOM_ENCODE_BASE64)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  100. /*[out, retval]*/ BSTR * pVal);
  101. #endif
  102. STDMETHOD(get_EncodedKey)
  103. (/*[out, retval]*/ IEncodedData ** pVal);
  104. STDMETHOD(get_EncodedParameters)
  105. (/*[out, retval]*/ IEncodedData ** pVal);
  106. //
  107. // None COM functions.
  108. //
  109. STDMETHOD(Init)
  110. (PCCERT_CONTEXT pCertContext);
  111. private:
  112. CLock m_Lock;
  113. DWORD m_dwKeyLength;
  114. // PPUBLIC_KEY_VALUES m_pPublicKeyValues;
  115. CComPtr<IOID> m_pIOID;
  116. CComPtr<IEncodedData> m_pIEncodedKey;
  117. CComPtr<IEncodedData> m_pIEncodedParams;
  118. };
  119. #endif //__PUBLICKEY_H_