Merge MaxNumberOfSessions changes from CDM

Bug: 18377675

Implement new OEMCrypto function to get max number of sessions
https://widevine-internal-review.googlesource.com/#/c/12980/

Add oemcrypto static adapter for v9
https://widevine-internal-review.googlesource.com/#/c/13022/

Support new property to query MaxNumberOfSessions in CDM
https://widevine-internal-review.googlesource.com/#/c/13020/

Fix GetHdcpCapabilities incorrect return if not initialized
https://widevine-internal-review.googlesource.com/#/c/13210/

Change-Id: I02738c543cedd6e38d8826f845fec6cb2b1ede3c
This commit is contained in:
KongQun Yang
2015-02-19 16:52:23 -08:00
committed by John "Juce" Bruce
parent 891bd057f4
commit 23c95a1251
11 changed files with 199 additions and 74 deletions

View File

@@ -274,6 +274,7 @@ typedef enum RSA_Padding_Scheme {
#define OEMCrypto_DeleteUsageTable _oecc34
#define OEMCrypto_LoadKeys _oecc35
#define OEMCrypto_GenerateRSASignature _oecc36
#define OEMCrypto_GetMaxNumberOfSessions _oecc37
/*
* OEMCrypto_Initialize
@@ -1993,6 +1994,30 @@ OEMCryptoResult OEMCrypto_DeleteUsageEntry(OEMCrypto_SESSION session,
*/
OEMCryptoResult OEMCrypto_DeleteUsageTable();
/*
* OEMCRYPTO_GetMaxNumberOfSessions()
*
* Description:
* Returns the maximum number of concurrent OEMCrypto sessions supported by
* the device. The CDM and OEMCrypto consumers can query this value so they
* can use resources more effectively.
*
* Parameters:
* maximum (out) - the maximum number of OEMCrypto sessions supported by the
* device.
*
* Threading:
* This function may be called simultaneously with any other functions.
*
* Returns:
* OEMCrypto_SUCCESS
* OEMCrypto_ERROR_UNKNOWN_FAILURE
*
* Version:
* This method is added in API version 10.
*/
OEMCryptoResult OEMCrypto_GetMaxNumberOfSessions(size_t *max);
#ifdef __cplusplus
}
#endif

View File

@@ -50,6 +50,7 @@ namespace wvoec3 {
#define Level3_ReportUsage _lcc32
#define Level3_DeleteUsageEntry _lcc33
#define Level3_DeleteUsageTable _lcc34
#define Level3_GetMaxNumberOfSessions _lcc37
extern "C" {
@@ -185,6 +186,7 @@ OEMCryptoResult Level3_DeleteUsageEntry(OEMCrypto_SESSION session,
const uint8_t *signature,
size_t signature_length);
OEMCryptoResult Level3_DeleteUsageTable();
OEMCryptoResult Level3_GetMaxNumberOfSessions(size_t *maximum);
};
}
#endif // LEVEL3_OEMCRYPTO_H_

View File

@@ -1291,4 +1291,15 @@ OEMCryptoResult OEMCrypto_DeleteUsageTable() {
return OEMCrypto_SUCCESS;
}
extern "C"
OEMCryptoResult OEMCrypto_GetMaxNumberOfSessions(size_t *maximum) {
if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) {
LOGI("-- OEMCryptoResult OEMCrypto_GetMaxNumberOfSessions(%p)\n", maximum);
}
if (maximum == NULL) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
const size_t kMaxSupportedOEMCryptoSessions = 64;
*maximum = kMaxSupportedOEMCryptoSessions;
return OEMCrypto_SUCCESS;
}
} // namespace wvoec_mock

View File

@@ -1597,7 +1597,7 @@ TEST_F(OEMCryptoClientTest, VersionNumber) {
uint32_t version = OEMCrypto_APIVersion();
cout << " OEMCrypto API version is " << version << endl;
ASSERT_LE(8, version);
ASSERT_GE(9, version);
ASSERT_GE(10, version);
}
TEST_F(OEMCryptoClientTest, NormalGetKeyData) {
@@ -1650,6 +1650,13 @@ TEST_F(OEMCryptoClientTest, CheckHDCPCapability) {
HDCPCapabilityAsString(maximum));
}
TEST_F(OEMCryptoClientTest, CheckMaxNumberOfOEMCryptoSessions) {
size_t maximum;
OEMCryptoResult sts = OEMCrypto_GetMaxNumberOfSessions(&maximum);
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
printf(" Max Number of Sessions: %zu.\n", maximum);
}
TEST_F(OEMCryptoClientTest, KeyboxValid) {
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_IsKeyboxValid());
}
@@ -1732,19 +1739,23 @@ TEST_F(OEMCryptoClientTest, TwoSessionsOpenClose) {
ASSERT_FALSE(s2.isOpen());
}
TEST_F(OEMCryptoClientTest, EightSessionsOpenClose) {
Session s[8];
for (int i = 0; i < 8; i++) {
TEST_F(OEMCryptoClientTest, MaxSessionsOpenClose) {
size_t max_sessions;
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_GetMaxNumberOfSessions(&max_sessions));
ASSERT_GT(max_sessions, 0);
vector<Session> s(max_sessions);
for (int i = 0; i < s.size(); i++) {
s[i].open();
ASSERT_EQ(OEMCrypto_SUCCESS, s[i].getStatus());
ASSERT_TRUE(s[i].isOpen());
}
for (int i = 0; i < 8; i++) {
for (int i = 0; i < s.size(); i++) {
s[i].close();
ASSERT_EQ(OEMCrypto_SUCCESS, s[i].getStatus());
ASSERT_FALSE(s[i].isOpen());
}
}
// TODO(kqyang): Add more tests exercising multiple sessions.
TEST_F(OEMCryptoClientTest, GenerateNonce) {
Session s;