Bug 1308076 - Rename CLEARKEY_KEY_LEN to CENC_KEY_LEN. r=jwwang
This better reflects that it's used for all CENC keys, not just ClearKey keys.
MozReview-Commit-ID: 9uCzDKVDLjc
--- a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
@@ -200,17 +200,17 @@ ClearKeyDecryptor::Decrypt(uint8_t* aBuf
tmp.resize((size_t)(iter - &tmp[0]));
} else {
memcpy(&tmp[0], aBuffer, aBufferSize);
}
assert(aMetadata.mIV.size() == 8 || aMetadata.mIV.size() == 16);
std::vector<uint8_t> iv(aMetadata.mIV);
- iv.insert(iv.end(), CLEARKEY_KEY_LEN - aMetadata.mIV.size(), 0);
+ iv.insert(iv.end(), CENC_KEY_LEN - aMetadata.mIV.size(), 0);
ClearKeyUtils::DecryptAES(mKey, tmp, iv);
if (aMetadata.NumSubsamples()) {
// Take the decrypted buffer, split up into subsamples, and insert those
// subsamples back into their original position in the original buffer.
uint8_t* data = aBuffer;
uint8_t* iter = &tmp[0];
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
@@ -152,40 +152,40 @@ ClearKeySessionManager::PersistentSessio
uint32_t aPromiseId,
const string& aSessionId,
const uint8_t* aKeyData,
uint32_t aKeyDataSize)
{
CK_LOGD("ClearKeySessionManager::PersistentSessionDataLoaded");
if (GMP_FAILED(aStatus) ||
Contains(mSessions, aSessionId) ||
- (aKeyDataSize % (2 * CLEARKEY_KEY_LEN)) != 0) {
+ (aKeyDataSize % (2 * CENC_KEY_LEN)) != 0) {
mCallback->ResolveLoadSessionPromise(aPromiseId, false);
return;
}
ClearKeySession* session = new ClearKeySession(aSessionId,
mCallback,
kGMPPersistentSession);
mSessions[aSessionId] = session;
- uint32_t numKeys = aKeyDataSize / (2 * CLEARKEY_KEY_LEN);
+ uint32_t numKeys = aKeyDataSize / (2 * CENC_KEY_LEN);
vector<GMPMediaKeyInfo> key_infos;
vector<KeyIdPair> keyPairs;
for (uint32_t i = 0; i < numKeys; i ++) {
- const uint8_t* base = aKeyData + 2 * CLEARKEY_KEY_LEN * i;
+ const uint8_t* base = aKeyData + 2 * CENC_KEY_LEN * i;
KeyIdPair keyPair;
- keyPair.mKeyId = KeyId(base, base + CLEARKEY_KEY_LEN);
- assert(keyPair.mKeyId.size() == CLEARKEY_KEY_LEN);
+ keyPair.mKeyId = KeyId(base, base + CENC_KEY_LEN);
+ assert(keyPair.mKeyId.size() == CENC_KEY_LEN);
- keyPair.mKey = Key(base + CLEARKEY_KEY_LEN, base + 2 * CLEARKEY_KEY_LEN);
- assert(keyPair.mKey.size() == CLEARKEY_KEY_LEN);
+ keyPair.mKey = Key(base + CENC_KEY_LEN, base + 2 * CENC_KEY_LEN);
+ assert(keyPair.mKey.size() == CENC_KEY_LEN);
session->AddKeyId(keyPair.mKeyId);
mDecryptionManager->ExpectKeyId(keyPair.mKeyId);
mDecryptionManager->InitKey(keyPair.mKeyId, keyPair.mKey);
mKeyIds.insert(keyPair.mKey);
keyPairs.push_back(keyPair);
@@ -262,20 +262,20 @@ ClearKeySessionManager::Serialize(const
std::vector<uint8_t>& aOutKeyData)
{
const std::vector<KeyId>& keyIds = aSession->GetKeyIds();
for (size_t i = 0; i < keyIds.size(); i++) {
const KeyId& keyId = keyIds[i];
if (!mDecryptionManager->HasKeyForKeyId(keyId)) {
continue;
}
- assert(keyId.size() == CLEARKEY_KEY_LEN);
+ assert(keyId.size() == CENC_KEY_LEN);
aOutKeyData.insert(aOutKeyData.end(), keyId.begin(), keyId.end());
const Key& key = mDecryptionManager->GetDecryptionKey(keyId);
- assert(key.size() == CLEARKEY_KEY_LEN);
+ assert(key.size() == CENC_KEY_LEN);
aOutKeyData.insert(aOutKeyData.end(), key.begin(), key.end());
}
}
void
ClearKeySessionManager::CloseSession(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength)
--- a/media/gmp-clearkey/0.1/ClearKeyUtils.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyUtils.cpp
@@ -50,32 +50,32 @@ IncrementIV(vector<uint8_t>& aIV) {
assert(aIV.size() == 16);
BigEndian::writeUint64(&aIV[8], BigEndian::readUint64(&aIV[8]) + 1);
}
/* static */ void
ClearKeyUtils::DecryptAES(const vector<uint8_t>& aKey,
vector<uint8_t>& aData, vector<uint8_t>& aIV)
{
- assert(aIV.size() == CLEARKEY_KEY_LEN);
- assert(aKey.size() == CLEARKEY_KEY_LEN);
+ assert(aIV.size() == CENC_KEY_LEN);
+ assert(aKey.size() == CENC_KEY_LEN);
OAES_CTX* aes = oaes_alloc();
oaes_key_import_data(aes, &aKey[0], aKey.size());
oaes_set_option(aes, OAES_OPTION_ECB, nullptr);
- for (size_t i = 0; i < aData.size(); i += CLEARKEY_KEY_LEN) {
+ for (size_t i = 0; i < aData.size(); i += CENC_KEY_LEN) {
size_t encLen;
- oaes_encrypt(aes, &aIV[0], CLEARKEY_KEY_LEN, nullptr, &encLen);
+ oaes_encrypt(aes, &aIV[0], CENC_KEY_LEN, nullptr, &encLen);
vector<uint8_t> enc(encLen);
- oaes_encrypt(aes, &aIV[0], CLEARKEY_KEY_LEN, &enc[0], &encLen);
+ oaes_encrypt(aes, &aIV[0], CENC_KEY_LEN, &enc[0], &encLen);
- assert(encLen >= 2 * OAES_BLOCK_SIZE + CLEARKEY_KEY_LEN);
- size_t blockLen = min(aData.size() - i, CLEARKEY_KEY_LEN);
+ assert(encLen >= 2 * OAES_BLOCK_SIZE + CENC_KEY_LEN);
+ size_t blockLen = min(aData.size() - i, CENC_KEY_LEN);
for (size_t j = 0; j < blockLen; j++) {
aData[i + j] ^= enc[2 * OAES_BLOCK_SIZE + j];
}
IncrementIV(aIV);
}
oaes_free(&aes);
}
--- a/media/psshparser/PsshParser.cpp
+++ b/media/psshparser/PsshParser.cpp
@@ -162,22 +162,22 @@ ParseCENCInitData(const uint8_t* aInitDa
}
if (!reader.CanRead32()) {
return false;
}
uint32_t kidCount = reader.ReadU32();
for (uint32_t i = 0; i < kidCount; i++) {
- if (reader.Remaining() < CLEARKEY_KEY_LEN) {
+ if (reader.Remaining() < CENC_KEY_LEN) {
// Not enough remaining to read key.
return false;
}
- const uint8_t* kid = reader.Read(CLEARKEY_KEY_LEN);
- aOutKeyIds.push_back(std::vector<uint8_t>(kid, kid + CLEARKEY_KEY_LEN));
+ const uint8_t* kid = reader.Read(CENC_KEY_LEN);
+ aOutKeyIds.push_back(std::vector<uint8_t>(kid, kid + CENC_KEY_LEN));
}
// Size of extra data. EME CENC format spec says datasize should
// always be 0. We explicitly read the datasize, in case the box
// size was 0, so that we get to the end of the box.
if (!reader.CanRead32()) {
return false;
}
--- a/media/psshparser/PsshParser.h
+++ b/media/psshparser/PsshParser.h
@@ -15,16 +15,16 @@
*/
#ifndef __ClearKeyCencParser_h__
#define __ClearKeyCencParser_h__
#include <stdint.h>
#include <vector>
-#define CLEARKEY_KEY_LEN ((size_t)16)
+#define CENC_KEY_LEN ((size_t)16)
bool
ParseCENCInitData(const uint8_t* aInitData,
uint32_t aInitDataSize,
std::vector<std::vector<uint8_t>>& aOutKeyIds);
#endif