Reject session clobbering and namespace fixes
* Reject session clobbering. [ Merge of http://go/wvgerrit/14634 ] This fixes a bug in I17de92b3e682c9c731f755e69466bdae7f560393 in which sessions can be clobbered by a forced session ID. This bug manifested in subtle test failures which involved repeatedly creating sessions. This was traced to OEMCrypto not being terminated, then upward to a leaked CryptoSession and CdmSession, and then finally to clobbered session IDs. To avoid the bug in future, first, reject duplicate session IDs. Second, change the OpenSession API to make forced IDs explicit. * Fix unit test namespaces. [ Merge of http://go/wvgerrit/14622 ] This fixes some odd errors that occur when linking multiple test suites into one executable. When two object files both contain a definition of wvcdm::MockCryptoSession, for example, one will win silently and cause the other's tests to misbehave and/or crash. The solution is to put all mocks into an anonymous namespace, since each wvcdm::(anonymous)::MockCryptoSession is separate. In order to avoid lots of repetitions of wvcdm:: in the anonymous namespaces, all anonymous namespaces in unit tests now live inside or the wvcdm namespace. This has been done even for tests which are not currently using mocks. * Move timer and timer_unittest to Android. [ Merge of http://go/wvgerrit/14619 ] These are not used anywhere else. Change-Id: I234f31e9b5c79061205728783596ebaff65e0aff
This commit is contained in:
@@ -12,26 +12,28 @@
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
namespace {
|
||||
|
||||
const uint32_t kAesBlockSize = 16;
|
||||
const std::string kAesKey = wvcdm::a2bs_hex("000102030405060708090a0b0c0d0e0f");
|
||||
const std::string kAesIv = wvcdm::a2bs_hex("000102030405060708090a0b0c0d0e0f");
|
||||
const std::string kCencInitDataHdr = wvcdm::a2bs_hex(
|
||||
const std::string kAesKey = a2bs_hex("000102030405060708090a0b0c0d0e0f");
|
||||
const std::string kAesIv = a2bs_hex("000102030405060708090a0b0c0d0e0f");
|
||||
const std::string kCencInitDataHdr = a2bs_hex(
|
||||
"00000042" // blob size
|
||||
"70737368" // "pssh"
|
||||
"00000000" // flags
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||
"00000022"); // pssh data size
|
||||
const std::string kCencPssh = wvcdm::a2bs_hex(
|
||||
const std::string kCencPssh = a2bs_hex(
|
||||
"08011a0d7769646576696e655f74657374220f73747265616d696e675f636c697031");
|
||||
const std::string kCdmSessionId = "sid2";
|
||||
const std::string kCryptoSessionId = "id2";
|
||||
const std::string kCryptoRequestId = wvcdm::a2bs_hex(
|
||||
const std::string kCryptoRequestId = a2bs_hex(
|
||||
"4341444542353737444337393044394330313030303030303030303030303030");
|
||||
const uint32_t kNonce = 0x49e81305;
|
||||
const int64_t kLicenseStartTime = 1413517500; // ~ 01/01/2013
|
||||
const std::string kToken = wvcdm::a2bs_hex(
|
||||
const std::string kToken = a2bs_hex(
|
||||
"0AAE02080212107E0A892DEEB021E7AF696B938BB1D5B1188B85AD9D05228E023082010A02"
|
||||
"82010100DBEDF2BFB0EC98213766E65049B9AB176FA4B1FBFBB2A0C96C87D9F2B895E0ED77"
|
||||
"93BDA057E6BC3E0CA2348BC6831E03609445CA4D418CB98EAC98FFC87AB2364CE76BA26BEE"
|
||||
@@ -67,7 +69,7 @@ const std::string kToken = wvcdm::a2bs_hex(
|
||||
"8CD5A9DF6E3D3A99B806F6D60991358C5BE77117D4F3168F3348E9A048539F892F4D783152"
|
||||
"C7A8095224AA56B78C5CF7BD1AB1B179C0C0D11E3C3BAC84C141A00191321E3ACC17242E68"
|
||||
"3C");
|
||||
const std::string kLicenseRequestSignature = wvcdm::a2bs_hex(
|
||||
const std::string kLicenseRequestSignature = a2bs_hex(
|
||||
"4A560ACFED04787BE0D29D7396234FA2E11D6DD0B22F87FD77AEAEDAA6C8FE54AD9859AE4E"
|
||||
"C9F12BCB947892D906DAEC1AD78CABD6F9D479CCF91AF5587DB6FC29CBEBF9C338BAF17790"
|
||||
"90980B1F3333BC901CDBF877490C7B85DB2BF9BC559C98450C6F1E8B2E192959F59CC53BD4"
|
||||
@@ -75,22 +77,6 @@ const std::string kLicenseRequestSignature = wvcdm::a2bs_hex(
|
||||
"8D24103EB15C63C227A0D57A9D90F5A409D2D55147EE10A35AE291D2D725C7F161FF827221"
|
||||
"9AE18B91516E0CDD0B581590DDDEA2A2527E2C9ABA273629B586A9D22D451A827E332CFC3E"
|
||||
"9BEDB6CF3D8713F9E11675DF1F5DB9038DBBECAB9D1683F8722CAF6E18EC8C04AEE5");
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
// Protobuf generated classes
|
||||
using video_widevine_server::sdk::LicenseRequest_ContentIdentification;
|
||||
using video_widevine_server::sdk::ClientIdentification;
|
||||
using video_widevine_server::sdk::LicenseRequest;
|
||||
using video_widevine_server::sdk::SignedMessage;
|
||||
|
||||
// gmock methods
|
||||
using ::testing::_;
|
||||
using ::testing::Eq;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::Return;
|
||||
using ::testing::SetArgPointee;
|
||||
|
||||
class MockCryptoSession : public CryptoSession {
|
||||
public:
|
||||
@@ -122,6 +108,21 @@ class MockInitializationData : public InitializationData {
|
||||
MOCK_METHOD0(is_cenc, bool());
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// Protobuf generated classes
|
||||
using video_widevine_server::sdk::LicenseRequest_ContentIdentification;
|
||||
using video_widevine_server::sdk::ClientIdentification;
|
||||
using video_widevine_server::sdk::LicenseRequest;
|
||||
using video_widevine_server::sdk::SignedMessage;
|
||||
|
||||
// gmock methods
|
||||
using ::testing::_;
|
||||
using ::testing::Eq;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::Return;
|
||||
using ::testing::SetArgPointee;
|
||||
|
||||
class CdmLicenseTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
@@ -281,4 +282,5 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
|
||||
license_request.protocol_version());
|
||||
EXPECT_EQ(kNonce, license_request.key_control_nonce());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user