(This is a merge of http://go/wvgerrit/76063)
Now that we have C++11, many places that do string formatting or parsing
can be replaced with std::to_string() or one of the std::sto*() family
of functions. This patch updates places that do simple stringifying or
parsing to use these functions. Some parts of the code are left
untouched because they were using StringStream to do more complex
actions, such as constructing more complex output or checking the status
of the parsing.
Bug: 120599938
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I482dc234ecd7c6014fa9b6874387ff51e04b772f
Merge from Widevine repo of http://go/wvgerrit/73383
Partners have been requesting more explanation for what each test is
doing. This is an attempt to clarify some of the tests.
Bug: 119640588
Test: unit tests
Change-Id: I270203b4e8fa7e65abb55297788e4d55856e7dcd
(This is a merge of http://go/wvgerrit/70303)
This adds a platform.h file to abstract some of the differences
between Windows and POSIX platforms. This includes ntohl, setenv,
and ssize_t.
Bug: 122953649
Test: Android Unit Tests
Change-Id: I3235f3f284b53d24d7365ff3f4a06dcd9b403697
Bug: b/119881112
Merge of http://go/wvgerrit/68983
Test: Android + Linux tests for ref and L3
This CL removes tests from OEMCrypto that test shared license
functionality and code in the ref and L3 that handle shared licenses.
Change-Id: Ia11510d8db3fa6e471a4ebbdb371fd76b0812984
Merge from Widevine repo of http://go/wvgerrit/68464
The Full Decrypt Path Testing design has changed to remove
OEMCrypto_InitializeDecryptHash. This CL updates the unit tests and
reference code.
Bug: 120795057
Test: unit tests
Change-Id: Iee28fa9034dc21cee81c5b894c192e260375eeee
Merge of http://go/wvgerrit/68187
This adds a unit test to verify that OEMCrypto_DeactivateUsageEntry
may be called several times without an error or changing the entry's
state.
Bug: 80540710
Test: unit tests
Change-Id: I594594bfde75c3e38a3b9efc51a667613a5da6ed
[ Merge of http://go/wvgerrit/67985 ]
Now that we can use C++11, we should use the cross-platform types for
clocks instead of the platform-specific versions.
Test: WV unit/integration tests.
Change-Id: I50318e3d1caf9e814f33f497f83c19c9f3c154a1
[ Merge of http://go/wvgerrit/67984 ]
Getting the address of the first element is invalid when the size is
0. Calling data() is valid when the size is zero so long as we
don't use the resulting pointer. This is important when we pass the
pointer to low-level functions like memcpy.
Also, MSVC is stricter about this and doesn't allow indexing the 0-th
element when it is empty. But GCC/Clang seem to be fine with it so
long as the object isn't used.
Test: WV unit/integration tests
Change-Id: Ic5d11da41dd3a185a63f86a6ea91e9b954fd699a
* changes:
Changes to adapter + gyp to support v15
Add full decrypt path testing functionality to Level 3
Update pointers to substrings in Level 3
Update level 3 reference API for v15
Bug: b/117558570
Test: Android, CE CDM, and Linux tests
Merge of http://go/wvgerrit/67566
This CL adds changes to support the Level 3 upgrade to v15 with both the
dynamic and static adapters. It also rearranges the wvcrc.cpp files so
that the tests have their own copy and Level 3 can just use the one in
ref/src.
Change-Id: Ieee2859601881aa1800622454e6ce0345eb94aa7
(This is a merge of http://go/wvgerrit/66625)
Google C++ Style dictates that methods which override base class or
interface methods should be declared "override" but not "virtual". Since
our codebase has not had access to "override" until now, many of our
classes do not follow this rule. I've updated as many places as I could
find to follow Google C++ Style, which should hopefully help us catch
errors better in the future.
Bug: 111851141
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: Ic23e2e482e967256da306791532b5fec7b81b2f2
Merge from Widevine repo of http://go/wvgerrit/66865
This CL updates the comments for the code that uses
InstallKeyboxOrCert to install a keybox or oem cert at runtime. There
is also a new unit test for the device id. There are not many unit
tests because we don't want to accidentally overwrite the production
keybox or cert on a device when running tests.
bug: 111725154
test: unit tests
Change-Id: Ide9b3d4732f3f96a723a128907babe7e59c02ffc
Merge from Widevine repo of http://go/wvgerrit/66708
This adds a unit test to verify that LoadKeys still works if the message is not
word alligned.
Test: unit tests on desktop and taimen (x86 and arm)
Bug: 68783727
Change-Id: Ib081a2c21af710b294772513c2c777ef1ac0daf0
Merge from master branch of Widevine repo of http://go/wvgerrit/66081
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/65962
This CL changes function names in the v14 level 3 libraries to work with
the dynamic adapter. I also excluded several OEMCrypto unit tests from
running with a v14 oemcrypto because they require error code changes
introduced in v15.
Bug: 117888897 Fix backwards compatibility
Bug: 119313532 Integration test failing
Test: unit tests on taimen. Play Movies, ExoPlayer, Netflix play on taimen.
Some unit tests do not pass because Taimen uses a v13 oemcrypto. Most pass.
Change-Id: Ib8eb8a89591fdba3055064c4bdf90523b01309a8
Merge from master branch of Widevine repo of http://go/wvgerrit/66080
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64002
This CL updates OEMCrypto reference code and unit tests to support full decrypt
path testing.
Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 34078913
Change-Id: Ia67374599d6619698a336f41513068ad04294e7f
Merge from master branch of Widevine repo of http://go/wvgerrit/66078
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64022
This CL updates OEMCrypto ref code, unit tests, and core code for
setting the sandbox id before initializing OEMCrypto.
Test: unit tests only
Test: tested as part of http://go/ag/5501993
Bug: 115834255
Change-Id: Id9831680fe4db1c69413815931cae4bc80df0c01
Merge from master branch of Widevine repo of http://go/wvgerrit/66076
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64743http://go/wvgerrit/64083 had some refactorings that weren't completely
accurate or slightly changed the meaning of some tests. This CL is an
addendum to that CL to fix those refactorings.
Test: tested as part of http://go/ag/5501993
Bug: 115874964
Change-Id: I37766a4c34de737eb9ca94ef781805435ee30dfd
Merge from master branch of Widevine repo of http://go/wvgerrit/66075
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64702
Bug: 118172995
Tests OEMCrypto_LoadKeys when given a KeyObject with NULL KeyControl or
KeyControl iv.
Test: tested as part of http://go/ag/5501993
Change-Id: I1a5d26b1e2ff395fbd5ef7769af1165222c1877e
Merge from master branch of Widevine repo of http://go/wvgerrit/66073
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64083
As part of the update to v15, LoadKeys, RefreshKeys, and
LoadEntitledContentKeys should all use offsets and lengths into the
message rather than a pointer for its parameters. The CDM, tests,
adapters, and OEMCrypto implementations are changed to reflect this.
Test: tested as part of http://go/ag/5501993
Bug: 115874964
Change-Id: I981fa322dec7c565066fd163ca5775dbff71fccf
Merge from master branch of Widevine repo of http://go/wvgerrit/66072
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63764
This adds the function OEMCrypto_ResourceRatingTier to the oemcrypto referenece
code, dynamic adapter, and unit tests.
Bug: 117110800
Test: tested as part of http://go/ag/5501993
Change-Id: Idf47af405f0c69601108b75c788a97b30abdb39d
Merge from master branch of Widevine repo of http://go/wvgerrit/66071
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63842
OEMCrypto tests log the HDCP value. This CL updates those logs to include logs
for HDCP 2.3.
Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 78773763
Change-Id: I7a3003e081c3c848b5d595ac241a0b546dacb747
Merge from master branch of Widevine repo of http://go/wvgerrit/66070
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63662
To make the threading model more clear, CopyBuffer is now a session function.
This means we need to pass in which session the current thread locks.
Test: unit tests.
Test: tested as part of http://go/ag/5501993
Bug: 113680369
Change-Id: I2fdd2cfcaab99f3793950b3845941463675f5e4c
Merge from master branch of Widevine repo of http://go/wvgerrit/66066
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63628
The error code OEMCrypto_KEY_NOT_LOADED is redundant with
OEMCrypto_ERROR_NO_CONTENT_KEY and OEMCrypto_KEY_NOT_ENTITLED. The
function LoadEntitledContentKey should return KEY_NOT_ENTITLED if it
does not find the corresponding entitlement key in its key table. All
other functions that do not find a key id in the key table should
return OEMCrypto_ERROR_NO_CONTENT_KEY. This includes QueryKeyControl,
SelectKey, and RefreshKeys.
Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 115574797
Change-Id: Ida2111f32e331b99f3f0c77fa404a42654d0870c
Merge from master branch of Widevine repo of http://go/wvgerrit/66065
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63080
This is for the reference code, the unit tests, and the oemcrypto adapter.
Bug: 116414218
Test: unit tests
Test: tested as part of http://go/ag/5501993
Change-Id: I05a631f6cfcf1584a748b3a0c9ae48633893589f
Merge from master branch of Widevine repo of http://go/wvgerrit/66064
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63063
This is in the reference code for OEMCrypto, and in the unit tetss.
Bug: 111939411
Test: unit tests
Test: tested as part of http://go/ag/5501993
Change-Id: I2cc2e7028f62d1c375eb632452eef94566fa9ae3
Merge from Widevine repo of http://go/wvgerrit/62782
There were still some old test keyboxes in the unit tests for older devices and
in the mod mock. These are removed. Also, the cert with system id 7346 has
been removed.
The new test keybox has system ID 7912.
The new test cert has system id 7913.
bug: 76435251
Test: unit tests (unit tests do not pass on v13 oemcrypto)
Test: tested as part of http://go/ag/5501993
Change-Id: I6007b6650162d9dc9d01384faaafc87acdf8ebd7
Merge from Widevine repo of http://go/wvgerrit/55460
This test ensures that different oemcrypto sessions can use different RSA keys.
bug: 110319198 Test concurrent sessions can use different DRM certificates
test: unit tests on taimen
Change-Id: Id75eedea347d453987dfe42894a8a7301e345674
Merge from Widevine repo of http://go/wvgerrit/57640
Add a unit test for OEMCrypto to handle a small buffer.
Test: unit tests
bug: 78233951
Change-Id: I5efe088705e2d248ab9ea45d8576daf69ad8bcdb
Merge from Widevine repo of http://go/wvgerrit/55461
This CL allows provisioning 3.0 devices to install their OEM certs
from an initialization partition. This method is already used for
keyboxes on Android -- we are just adding the ability to use it for
OEM certs, also.
Also, for v15, we require OEMCrypto to report a valid certificate in
the unit tests.
bug: 111725154
test: unit tests
Change-Id: I142c84a1a67bdb4cee943cfd12a632421901eb24
Merge from Widevine repo of http://go/wvgerrit/56526
This CL removes the test keybox from OEMCrypto reference code.
Test: unit tests
Bug: 76393338 split mock into ref and testbed
Change-Id: I4bf0eb777c6851191d0ac9ccf8e2b42c55c8f6b9
Merge from Widevine repo of http://go/wvgerrit/56520
This CL adds a test base that installs a test keybox and catches nonce
flood errors for all CDM tests.
In order to do this, a new class is added called a
CryptoSessionFactory. The default factory just creates a new
CryptoSession. All places in the code that create a new CryptoSession
now call the static method MakeCryptoSession, which uses the current
factory to create a CryptoSession. If MakeCryptoSession is called and
there is no current factory, a default factory is created.
The CryptoSession constructor is now private, so that we do not
accidentally try to create one without using the factory.
For the new test base, we first create a special test
CryptoSessionFactory that creates a TestCryptoSession. The test
factory catches the first call to MakeCryptoSession and injects an
installation of the test keybox after OEMCrypto_Initialize is called.
The TestCryptoSession injects a sleep statement and a retry whenever
it detects a nonce flood.
Test: current unit tests still pass.
bug: 72354901 Fix Generic Crypto tests.
bug: 111361440 Remove #ifdef from unit tests
Change-Id: I248e7f3c53721c04d2af412ef835e19bb4d15d9a
Merge from widevine of http://go/wvgerrit/48885
iOS prohibits using clock_settime. In order to make the test consistent,
we set time using settimeofday instead.
Test: tested as part of http://go/ag/4674759
Change-Id: I8812b9b099fa8160591fafece070c34afeed82fa
Merge from Widevine repo of http://go/wvgerrit/46204
Refactor utility code - split the mock, step 1
Merge from Widevine repo of http://go/wvgerrit/46205
Move some OEMCrypto types to common header - split the mock, step 2
Merge from Widevine repo of http://go/wvgerrit/46206
Split mock into two -- step 3
Merge from Widevine repo of http://go/wvgerrit/47460
Split the mock into two -- step 3.5
The CL moves several files used by oemcrypto and cdm into a common
subdirectory, so that it may more easily be shared with partners.
The CORE_DISALLOW_COPY_AND_ASSIGN macro was moved to its own header in
the util/include directory.
This CL removes some references to the mock from other code, and puts
some constants and types, such as the definition of the keybox, into a
header in oemcrypto.
Test: tested as part of http://go/ag/4674759
bug: 76393338
Change-Id: I75b4bde7062ed8ee572c97ebc2f4da018f4be0c9
Merge from Widevine repo of http://go/wvgerrit/58440
This CL modifies the oemcrypto test TwoHundredEntries so that it
attempts to create more than 200 entries. A device is allowed to fail
when such an attempt is made, but it must return an insufficient
resources error.
The test then verifies that each of the entries that were succesfully
created can be used to reload its license and the keys can be used for
decryption.
It then shrinks the usage table header, and verifies that the
remaining licenses can still be used for decryption.
bug: 112486006
test: unit tests (test code only)
Change-Id: I6e6edfb00f0553724e0f99fb4e5ea5c817450937
To be compatible with latest googletest.
Test: compile
Change-Id: I15d857ce7b9b28ba5f75c84c61f1c6a970012ca7
Merged-In: I15d857ce7b9b28ba5f75c84c61f1c6a970012ca7
Merge from Widevine repo of http://go/wvgerrit/50600
The entry count was really 201 -- it should be 200.
test: This code is unit tests only -- no production code.
bug: 79875327
Change-Id: Ib81253ce9d51a7157ea0a64cddeb6cc266b3e25e
Merge from Widevine repo of http://go/wvgerrit/50422
This CL adds unit tests to verify that a usage report can have the status
kInactiveUnused.
bug: 79556142
test: unit test code only
Change-Id: I10f71ac2e585ef33727aa8f80d867d80fe156ab8
Merge from Widevine repo of http://go/wvgerrit/49302
This CL adds some unit tests to verify that several OEMCrypto sessions
do not share nonce tables.
bug: 64850992
test: unit tests run on sailfish, taimen, and walleye.
Change-Id: I06cf3fdafb84f8b09cf2f0e58c1866bac511a293
Merge from http://go/wvgerrit/47640
Test: unit/integration tests
Bug: b/62058202
The usage table keeps track of license duration by using the current
system time. However, if a user were to rollback the time, they can
effectively continue offline playback indefinitely. This changes the way
we compute time by computing offsets by which the user rollbacked the
time and adding it to the current time. This change also includes a test
to verify protection against rollback for usage entries that is only run
when the user is root.
Change-Id: I97c430e1443747b0f9759ae5390b8f5d06bdebf1
Merge from Widevine repo of http://go/wvgerrit/47860
This CL updates the copyright notice to indicate that files
shared with partners are shared under the Widevine Master
License Agreement.
bug: 77926774
test: comment change only
Change-Id: I0423668111578b80fb39a932d763df2827e2dfc3
Merge of http://go/wvgerrit/45521/
Bug: b/73818548
Test: request_license_tests and GTS tests on sailfish and taimen
This change loads the mac keys into the session to be used in
GenerateSignature from the last call to one of: DeriveKeysFromSessionKey,
GenerateDerivedKeys, LoadKeys, and LoadUsageEntry. OEMCrypto tests are
changed to reflect this as well (specifically the order in which we call
the above methods).
Merge from Widevine repo of http://go/wvgerrit/43721
This CL allows the tester to change the nonce flood rate from the
default of 20. A tester would want this value to be larger to make
tests run more quickly.
Setting the rate to 1 makes every other nonce request a flood error.
A tester wants to do this in order to verify cdm code responds to
nonce flood correctly. Several failing oemcrypto tests have also been
corrected.
This CL changes test code only.
bug: 73607610
test: unit tests
Change-Id: I3f52ff7ea9bcc1db7bc0e010da0b64a12d3b4dd3
Merge from Widevine repo of http://go/wvgerrit/42403
This CL changes the names of some unit tests so that they don't run
when testing an older version of oemcrypto.
bug: 68275290
test: ran unit tests against v8-v14 oemcrypto.
Change-Id: I773350adf4df3f3b310478400cd4d4e85789fc37
Merge from Widevine repo of http://go/wvgerrit/42064
This adds a unit test to verify that OEMCrypto can load a certificate
with an RSA private key generated using the Carmichael Totient.
bug: 67309725
test: No new failures. This code is part of unit tests only.
Change-Id: I492cf6bcff0ac2d1a838e7aa334c4b2b580ac5c7
Merge from Widevine repo of http://go/wvgerrit/41662
This CL updates oemcrypto unit tests to use the new test keybox.
bug: 69552641 Update OEMCrypto_LoadTestKeybox
test: Unit tests compile and run -- many tests won't pass until merged
with vendor code
Change-Id: I73bdca3958b2c985d4c61801aa95807a2e6d4299