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.

77 lines
1.8 KiB

  1. #include "stdafx.h"
  2. #include "mswmdm.h"
  3. #include "loghelp.h"
  4. #include "scpinfo.h"
  5. // We don't want to dll's using our lib to link to drmutil2.lib.
  6. // So disable DRM logging.
  7. #define DISABLE_DRM_LOG
  8. #include "drmerr.h"
  9. #include "key.h"
  10. #include "wmsstd.h"
  11. #define MIN_SCP_APPSEC 1000
  12. CSCPInfo::CSCPInfo() : m_pSCP(NULL), m_pSCClient(NULL)
  13. {
  14. m_pSCClient = new CSecureChannelClient();
  15. }
  16. CSCPInfo::~CSCPInfo()
  17. {
  18. SAFE_DELETE(m_pSCClient);
  19. SAFE_RELEASE(m_pSCP);
  20. }
  21. HRESULT CSCPInfo::hrInitialize(LPWSTR pwszProgID)
  22. {
  23. HRESULT hr;
  24. CLSID clsid;
  25. IComponentAuthenticate *pAuth = NULL;
  26. DWORD dwLocalAppSec = 0;
  27. DWORD dwRemoteAppSec = 0;
  28. if (!m_pSCClient)
  29. {
  30. hr = E_FAIL;
  31. goto Error;
  32. }
  33. CORg( m_pSCClient->SetCertificate(SAC_CERT_V1, (BYTE*)g_abAppCert, sizeof(g_abAppCert), (BYTE*)g_abPriv, sizeof(g_abPriv)) );
  34. CORg( CLSIDFromProgID(pwszProgID, &clsid) );
  35. CORg( CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IComponentAuthenticate, (void**)&pAuth) );
  36. m_pSCClient->SetInterface(pAuth);
  37. CORg( m_pSCClient->Authenticate(SAC_PROTOCOL_V1) );
  38. CORg( m_pSCClient->GetAppSec( &dwLocalAppSec, &dwRemoteAppSec ) );
  39. // Only use SCP if appsec >= 1000
  40. if( dwRemoteAppSec < MIN_SCP_APPSEC )
  41. {
  42. hrLogString( "Ignoring SCP with AppSec < 1000", S_FALSE );
  43. hr = E_FAIL;
  44. goto Error;
  45. }
  46. CORg( pAuth->QueryInterface(IID_ISCPSecureAuthenticate, (void**)&m_pSCP) );
  47. Error:
  48. if (pAuth)
  49. pAuth->Release();
  50. hrLogDWORD("CSCPInfo::hrInitialize returned 0x%08lx", hr, hr);
  51. return hr;
  52. }
  53. HRESULT CSCPInfo::hrGetInterface(ISCPSecureAuthenticate **ppSCP)
  54. {
  55. m_pSCP->AddRef();
  56. *ppSCP = m_pSCP;
  57. return S_OK;
  58. }
  59. void CSCPInfo::GetSCClient(CSecureChannelClient **ppSCClient)
  60. {
  61. *ppSCClient = m_pSCClient;
  62. }