OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/webm/webm_crypt_helpers.h" | |
xhwang
2012/08/29 05:08:14
How about rename this to "webm_crypto_helpers.h",
ddorwin
2012/09/01 16:46:41
Agreed. Is there a reason you chose "crypt"?
fgalligan1
2013/03/09 01:10:59
Done.
fgalligan1
2013/03/09 01:10:59
Done.
| |
6 | |
7 #include "base/logging.h" | |
ddorwin
2012/09/01 16:46:41
Not needed?
| |
8 #include "base/sys_byteorder.h" | |
9 #include "media/base/decrypt_config.h" | |
10 #include "media/crypto/decryptor_helpers.h" | |
11 #include "media/webm/webm_constants.h" | |
12 | |
13 namespace media { | |
14 | |
15 scoped_refptr<DecoderBuffer> WebMCopyBufferCheckIfEncrypted( | |
ddorwin
2012/09/01 16:46:41
This function does not "check if encrypted". So, i
fgalligan1
2013/03/09 01:10:59
Renamed.
| |
16 const uint8* data, int data_size, | |
17 const uint8* key_id, int key_id_size) { | |
18 scoped_refptr<DecoderBuffer> encrypted_buffer = DecoderBuffer::CopyFrom( | |
19 data + kWebMHmacSize, data_size - kWebMHmacSize); | |
ddorwin
2012/09/01 16:46:41
line breaks and alignment seem questionable.
fgalligan1
2013/03/09 01:10:59
Removed.
| |
20 CHECK(encrypted_buffer); | |
21 | |
22 uint8 signal_byte = data[kWebMHmacSize]; | |
23 int data_offset = sizeof(signal_byte); | |
ddorwin
2012/09/01 16:46:41
const int kDataOffset?
"data_offset" is not direct
fgalligan1
2013/03/09 01:10:59
Changed to frame_offset.
| |
24 | |
25 // Setting the DecryptConfig object of the buffer while leaving the | |
26 // initialization vector empty will tell the decryptor that the frame is | |
27 // unencrypted but integrity should still be checked. | |
28 std::string counter_block_str; | |
29 | |
30 if (signal_byte & kWebMFlagEncryptedFrame) { | |
31 uint64 network_iv; | |
ddorwin
2012/09/01 16:46:41
Might comment "IV is only present for encrypted fr
fgalligan1
2013/03/09 01:10:59
Done.
| |
32 memcpy(&network_iv, data + kWebMHmacSize + data_offset, sizeof(network_iv)); | |
33 const uint64 iv = base::NetToHost64(network_iv); | |
34 counter_block_str = | |
35 GenerateCounterBlock(iv); | |
ddorwin
2012/09/01 16:46:41
on same line as above
| |
36 data_offset += sizeof(iv); | |
37 } | |
38 | |
39 encrypted_buffer->SetDecryptConfig( | |
40 scoped_ptr<DecryptConfig>(new DecryptConfig( | |
41 std::string(reinterpret_cast<const char*>(key_id), key_id_size), | |
42 counter_block_str, | |
43 std::string(reinterpret_cast<const char*>(data), kWebMHmacSize), | |
44 data_offset, | |
45 std::vector<SubsampleEntry>()))); | |
46 return encrypted_buffer; | |
47 } | |
48 | |
49 } // media | |
xhwang
2012/08/29 05:08:14
// namespace media
fgalligan1
2013/03/09 01:10:59
Done.
| |
OLD | NEW |