Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #1697

Closed
wants to merge 2 commits into from
Closed

test #1697

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA(
std::string fileName =
STRING::ToUpper(DRM::KeySystemToUUIDstr(m_cdmAdapter->GetKeySystem())) + ".init";
std::string debugFilePath = FILESYS::PathCombine(m_cdmAdapter->GetLibraryPath(), fileName);
std::string data{reinterpret_cast<const char*>(m_pssh.data()), m_pssh.size()};
FILESYS::SaveFile(debugFilePath, data, true);
FILESYS::SaveFile(debugFilePath, {m_pssh.cbegin(), m_pssh.cend()}, true);
}

m_initialPssh = m_pssh;
Expand Down Expand Up @@ -342,7 +341,7 @@ bool CWVCencSingleSampleDecrypterA::SendSessionMessage(const std::vector<uint8_t
std::string fileName =
STRING::ToUpper(DRM::KeySystemToUUIDstr(m_cdmAdapter->GetKeySystem())) + ".challenge";
std::string debugFilePath = FILESYS::PathCombine(m_cdmAdapter->GetLibraryPath(), fileName);
UTILS::FILESYS::SaveFile(debugFilePath, reinterpret_cast<const char*>(challenge.data()), true);
UTILS::FILESYS::SaveFile(debugFilePath, {challenge.cbegin(), challenge.cend()}, true);
}

const DRM::Config drmCfg = m_cdmAdapter->GetConfig();
Expand Down Expand Up @@ -417,26 +416,26 @@ bool CWVCencSingleSampleDecrypterA::SendSessionMessage(const std::vector<uint8_t
// The first request could be the license certificate request
// this request is done by sending a challenge of 2 bytes, 0x08 0x04 (CAQ=)
const bool isCertRequest = challenge.size() == 2 && challenge[0] == 0x08 && challenge[1] == 0x04;
LOG::LogF(LOGDEBUG, "IS CERT REQ? %i", isCertRequest);

int hdcpLimit{0};

if (!isCertRequest)
if (!licConfig.unwrapper.empty() && m_cdmAdapter->GetKeySystem() == DRM::KS_WIDEVINE)
{
// Unwrap license response
if (m_cdmAdapter->GetKeySystem() == DRM::KS_WIDEVINE)
std::string unwrappedData;
// Some services have a customized license server that require data to be wrapped with their formats (e.g. JSON).
// Here we provide a built-in way to unwrap the license data received, this avoid force add-ons to integrate
// a HTTP server proxy to manage the license data request/response, and so use Kodi properties to set wrappers.
if (!DRM::WvUnwrapLicense(licConfig.unwrapper, licConfig.unwrapperParams, respContentType,
respData, unwrappedData, hdcpLimit))
{
std::string unwrappedData;
// Some services have a customized license server that require data to be wrapped with their formats (e.g. JSON).
// Here we provide a built-in way to unwrap the license data received, this avoid force add-ons to integrate
// a HTTP server proxy to manage the license data request/response, and so use Kodi properties to set wrappers.
if (!DRM::WvUnwrapLicense(licConfig.unwrapper, licConfig.unwrapperParams, respContentType,
respData, unwrappedData, hdcpLimit))
{
return false;
}
respData = unwrappedData;
return false;
}

respData = unwrappedData;
}
if (!isCertRequest)
{
if (m_cdmAdapter->GetKeySystem() == DRM::KS_PLAYREADY &&
respData.find("<LicenseNonce>") == std::string::npos)
{
Expand All @@ -453,6 +452,13 @@ bool CWVCencSingleSampleDecrypterA::SendSessionMessage(const std::vector<uint8_t
}
}

if (isCertRequest && CSrvBroker::GetSettings().IsDebugLicense())
{
std::string fileName =
STRING::ToUpper(DRM::KeySystemToUUIDstr(m_cdmAdapter->GetKeySystem())) + ".response.cert";
std::string debugFilePath = FILESYS::PathCombine(m_cdmAdapter->GetLibraryPath(), fileName);
FILESYS::SaveFile(debugFilePath, respData, true);
}
if (!isCertRequest && CSrvBroker::GetSettings().IsDebugLicense())
{
std::string fileName =
Expand Down