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

Side by Side Diff: media/crypto/aes_decryptor.cc

Issue 11434025: Encrypted Media: Handle empty init_data in AesDecryptor::GenerateKeyRequest(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/crypto/aes_decryptor.h" 5 #include "media/crypto/aes_decryptor.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 AesDecryptor::~AesDecryptor() { 132 AesDecryptor::~AesDecryptor() {
133 STLDeleteValues(&key_map_); 133 STLDeleteValues(&key_map_);
134 } 134 }
135 135
136 bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, 136 bool AesDecryptor::GenerateKeyRequest(const std::string& key_system,
137 const std::string& type, 137 const std::string& type,
138 const uint8* init_data, 138 const uint8* init_data,
139 int init_data_length) { 139 int init_data_length) {
140 std::string session_id_string(base::UintToString(next_session_id_++)); 140 std::string session_id_string(base::UintToString(next_session_id_++));
141 141
142 if (!init_data || !init_data_length) {
143 DVLOG(1) << "Could not generate key request with empty init_data.";
ddorwin 2012/11/29 17:55:08 nit: How about "init_data required to generate a k
xhwang 2012/11/29 20:34:37 Done.
144 client_->KeyError(key_system, "", Decryptor::kUnknownError, 0);
145 return false;
ddorwin 2012/11/29 17:55:08 Is false going to cause some error to be reported
xhwang 2012/11/29 20:34:37 We discussed offline that decryptors other than Pr
ddorwin 2012/11/29 22:19:01 No, I don't think we should do that. Let's file a
146 }
147
142 // For now, the AesDecryptor does not care about |key_system| and |type|; 148 // For now, the AesDecryptor does not care about |key_system| and |type|;
143 // just fire the event with the |init_data| as the request. 149 // just fire the event with the |init_data| as the request.
144 int message_length = init_data_length; 150 int message_length = init_data_length;
145 scoped_array<uint8> message(new uint8[message_length]); 151 scoped_array<uint8> message(new uint8[message_length]);
146 memcpy(message.get(), init_data, message_length); 152 memcpy(message.get(), init_data, message_length);
147 153
148 client_->KeyMessage(key_system, session_id_string, 154 client_->KeyMessage(key_system, session_id_string,
149 message.Pass(), message_length, ""); 155 message.Pass(), message_length, "");
150 return true; 156 return true;
151 } 157 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 bool AesDecryptor::DecryptionKey::Init() { 328 bool AesDecryptor::DecryptionKey::Init() {
323 CHECK(!secret_.empty()); 329 CHECK(!secret_.empty());
324 decryption_key_.reset(crypto::SymmetricKey::Import( 330 decryption_key_.reset(crypto::SymmetricKey::Import(
325 crypto::SymmetricKey::AES, secret_)); 331 crypto::SymmetricKey::AES, secret_));
326 if (!decryption_key_.get()) 332 if (!decryption_key_.get())
327 return false; 333 return false;
328 return true; 334 return true;
329 } 335 }
330 336
331 } // namespace media 337 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698