[Test] Rotate key_ids in PSSH as well for key rotation
Note that fixed key / raw key rotation should not be used in production. Change-Id: I87fca41ebd00f3cadbf157ff129b8e6a9ca04e7c
This commit is contained in:
parent
ae17159b73
commit
0861452932
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -62,13 +62,25 @@ Status FixedKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index,
|
||||||
key->key.begin() + (crypto_period_index % key->key.size()),
|
key->key.begin() + (crypto_period_index % key->key.size()),
|
||||||
key->key.end());
|
key->key.end());
|
||||||
|
|
||||||
for (size_t i = 0; i < key->key_system_info.size(); i++) {
|
for (auto& key_system : key->key_system_info) {
|
||||||
std::vector<uint8_t> pssh_data = key->key_system_info[i].pssh_data();
|
std::vector<uint8_t> pssh_data = key_system.pssh_data();
|
||||||
if (!pssh_data.empty()) {
|
if (!pssh_data.empty()) {
|
||||||
std::rotate(pssh_data.begin(),
|
std::rotate(pssh_data.begin(),
|
||||||
pssh_data.begin() + (crypto_period_index % pssh_data.size()),
|
pssh_data.begin() + (crypto_period_index % pssh_data.size()),
|
||||||
pssh_data.end());
|
pssh_data.end());
|
||||||
key->key_system_info[i].set_pssh_data(pssh_data);
|
key_system.set_pssh_data(pssh_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rotate the key_ids in pssh as well if exists.
|
||||||
|
// Save a local copy of the key ids before clearing the key ids in
|
||||||
|
// |key_system|. The key ids will be updated and added back later.
|
||||||
|
std::vector<std::vector<uint8_t>> key_ids_copy = key_system.key_ids();
|
||||||
|
key_system.clear_key_ids();
|
||||||
|
for (std::vector<uint8_t>& key_id : key_ids_copy) {
|
||||||
|
std::rotate(key_id.begin(),
|
||||||
|
key_id.begin() + (crypto_period_index % key_id.size()),
|
||||||
|
key_id.end());
|
||||||
|
key_system.add_key_id(key_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue