Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Unified Diff: media/cdm/aes_decryptor.cc

Issue 77413005: Remove support for non-JSON keys in AesDecryptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/crypto/proxy_decryptor.cc ('k') | media/cdm/aes_decryptor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/aes_decryptor.cc
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index 2d84b321c16876a064eb70df08eee135ed44d958..7d2dd1e909fa563582298ef5350d8a1c21fc6566 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -301,58 +301,29 @@ void AesDecryptor::AddKey(uint32 reference_id,
CHECK(key);
CHECK_GT(key_length, 0);
+ // Since |key| represents valid JSON, init_data must be empty.
ddorwin 2013/11/22 04:38:26 You can probably remove this comment now.
jrummell 2013/11/22 18:53:11 Done.
+ DCHECK(!init_data);
+ DCHECK_EQ(init_data_length, 0);
+
// AddKey() is called from update(), where the key(s) are passed as a JSON
// Web Key (JWK) set. Each JWK needs to be a symmetric key ('kty' = "oct"),
// with 'kid' being the base64-encoded key id, and 'k' being the
// base64-encoded key.
- //
- // For backwards compatibility with v0.1b of the spec (where |key| is the raw
- // key and |init_data| is the key id), if |key| is not valid JSON, then
- // attempt to process it as a raw key.
-
std::string key_string(reinterpret_cast<const char*>(key), key_length);
JWKKeys jwk_keys;
- if (ExtractJWKKeys(key_string, &jwk_keys)) {
- // Since |key| represents valid JSON, init_data must be empty.
- DCHECK(!init_data);
- DCHECK_EQ(init_data_length, 0);
-
- // Make sure that at least one key was extracted.
- if (jwk_keys.empty()) {
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
- return;
- }
- for (JWKKeys::iterator it = jwk_keys.begin() ; it != jwk_keys.end(); ++it) {
- if (!AddDecryptionKey(it->first, it->second)) {
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
- return;
- }
- }
- } else {
- // v0.1b backwards compatibility support.
- // TODO(jrummell): Remove this code once v0.1b no longer supported.
-
- if (key_string.length() !=
- static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) {
ddorwin 2013/11/22 04:38:26 Are we checking the key size anywhere? I think the
jrummell 2013/11/22 18:53:11 There is (AesDecryptorTest.WrongSizedKey). Interes
ddorwin 2013/11/22 20:17:12 Maybe we check the kid size too somewhere? We shou
- DVLOG(1) << "Invalid key length: " << key_string.length();
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
- return;
- }
+ if (!ExtractJWKKeys(key_string, &jwk_keys)) {
+ key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ return;
+ }
- // TODO(xhwang): Fix the decryptor to accept no |init_data|. See
- // http://crbug.com/123265. Until then, ensure a non-empty value is passed.
- static const uint8 kDummyInitData[1] = {0};
- if (!init_data) {
- init_data = kDummyInitData;
- init_data_length = arraysize(kDummyInitData);
- }
+ // Make sure that at least one key was extracted.
+ if (jwk_keys.empty()) {
+ key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ return;
+ }
- // TODO(xhwang): For now, use |init_data| for key ID. Make this more spec
- // compliant later (http://crbug.com/123262, http://crbug.com/123265).
- std::string key_id_string(reinterpret_cast<const char*>(init_data),
- init_data_length);
- if (!AddDecryptionKey(key_id_string, key_string)) {
- // Error logged in AddDecryptionKey()
+ for (JWKKeys::iterator it = jwk_keys.begin() ; it != jwk_keys.end(); ++it) {
+ if (!AddDecryptionKey(it->first, it->second)) {
key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
return;
}
« no previous file with comments | « content/renderer/media/crypto/proxy_decryptor.cc ('k') | media/cdm/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698