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

Side by Side Diff: media/webm/webm_crypto_helpers.cc

Issue 119203003: Drop DecryptConfig::data_offset_. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 11 months 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/webm/webm_crypto_helpers.h" 5 #include "media/webm/webm_crypto_helpers.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_byteorder.h" 8 #include "base/sys_byteorder.h"
9 #include "media/base/decrypt_config.h" 9 #include "media/base/decrypt_config.h"
10 #include "media/webm/webm_constants.h" 10 #include "media/webm/webm_constants.h"
11 11
12 namespace media { 12 namespace media {
13 namespace { 13 namespace {
14 14
15 // Generates a 16 byte CTR counter block. The CTR counter block format is a 15 // Generates a 16 byte CTR counter block. The CTR counter block format is a
16 // CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV. 16 // CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV.
17 // |iv_size| is the size of |iv| in btyes. Returns a string of 17 // |iv_size| is the size of |iv| in btyes. Returns a string of
18 // kDecryptionKeySize bytes. 18 // kDecryptionKeySize bytes.
19 std::string GenerateWebMCounterBlock(const uint8* iv, int iv_size) { 19 std::string GenerateWebMCounterBlock(const uint8* iv, int iv_size) {
20 std::string counter_block(reinterpret_cast<const char*>(iv), iv_size); 20 std::string counter_block(reinterpret_cast<const char*>(iv), iv_size);
21 counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0); 21 counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0);
22 return counter_block; 22 return counter_block;
23 } 23 }
24 24
25 } // namespace anonymous 25 } // namespace anonymous
26 26
27 scoped_ptr<DecryptConfig> WebMCreateDecryptConfig( 27 bool WebMCreateDecryptConfig(const uint8* data, int data_size,
28 const uint8* data, int data_size, 28 const uint8* key_id, int key_id_size,
29 const uint8* key_id, int key_id_size) { 29 scoped_ptr<DecryptConfig>* decrypt_config,
DaleCurtis 2014/01/02 19:31:09 Just make it a regular pointer? This method should
xhwang 2014/01/08 00:43:36 Hmm, we have "new" on l.53. If we return a regular
30 int* data_offset) {
30 if (data_size < kWebMSignalByteSize) { 31 if (data_size < kWebMSignalByteSize) {
31 DVLOG(1) << "Got a block from an encrypted stream with no data."; 32 DVLOG(1) << "Got a block from an encrypted stream with no data.";
32 return scoped_ptr<DecryptConfig>(); 33 return false;
33 } 34 }
34 35
35 uint8 signal_byte = data[0]; 36 uint8 signal_byte = data[0];
36 int frame_offset = sizeof(signal_byte); 37 int frame_offset = sizeof(signal_byte);
37 38
38 // Setting the DecryptConfig object of the buffer while leaving the 39 // Setting the DecryptConfig object of the buffer while leaving the
39 // initialization vector empty will tell the decryptor that the frame is 40 // initialization vector empty will tell the decryptor that the frame is
40 // unencrypted. 41 // unencrypted.
41 std::string counter_block; 42 std::string counter_block;
42 43
43 if (signal_byte & kWebMFlagEncryptedFrame) { 44 if (signal_byte & kWebMFlagEncryptedFrame) {
44 if (data_size < kWebMSignalByteSize + kWebMIvSize) { 45 if (data_size < kWebMSignalByteSize + kWebMIvSize) {
45 DVLOG(1) << "Got an encrypted block with not enough data " << data_size; 46 DVLOG(1) << "Got an encrypted block with not enough data " << data_size;
46 return scoped_ptr<DecryptConfig>(); 47 return false;
47 } 48 }
48 counter_block = GenerateWebMCounterBlock(data + frame_offset, kWebMIvSize); 49 counter_block = GenerateWebMCounterBlock(data + frame_offset, kWebMIvSize);
49 frame_offset += kWebMIvSize; 50 frame_offset += kWebMIvSize;
50 } 51 }
51 52
52 scoped_ptr<DecryptConfig> config(new DecryptConfig( 53 decrypt_config->reset(new DecryptConfig(
53 std::string(reinterpret_cast<const char*>(key_id), key_id_size), 54 std::string(reinterpret_cast<const char*>(key_id), key_id_size),
54 counter_block, 55 counter_block,
55 frame_offset,
56 std::vector<SubsampleEntry>())); 56 std::vector<SubsampleEntry>()));
57 return config.Pass(); 57 *data_offset = frame_offset;
58
59 return true;
58 } 60 }
59 61
60 } // namespace media 62 } // namespace media
OLDNEW
« media/webm/webm_cluster_parser.cc ('K') | « media/webm/webm_crypto_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698