summaryrefslogtreecommitdiffstats
path: root/media/webm
diff options
context:
space:
mode:
authorjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 04:05:31 +0000
committerjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 04:05:31 +0000
commit108c4926024c1901bd66f54115ec9dbe216baed1 (patch)
tree9df382ae57fb917fb47ee81d1f70d421b813b753 /media/webm
parentbd4c0d288bb658922ffde085030d3ce4ca7bd057 (diff)
downloadchromium_src-108c4926024c1901bd66f54115ec9dbe216baed1.zip
chromium_src-108c4926024c1901bd66f54115ec9dbe216baed1.tar.gz
chromium_src-108c4926024c1901bd66f54115ec9dbe216baed1.tar.bz2
Revert 147169 - Add support for encrypted WebM files as defined in the RFC.
The WebM parser now reads the HMAC and IV from every encrypted Block and stores that information in the DecryptorConfig object. Added two new elements ContentEncAESSettings and AESSettingsCipherMode used by encrypted WebM files. BUG=119845 TEST=media_unittests --gtest_filter=HmacAesDecryptorTest Review URL: https://chromiumcodereview.appspot.com/10535029 TBR=fgalligan@chromium.org Review URL: https://chromiumcodereview.appspot.com/10807003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147172 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/webm')
-rw-r--r--media/webm/webm_cluster_parser.cc43
-rw-r--r--media/webm/webm_cluster_parser.h4
-rw-r--r--media/webm/webm_constants.h7
-rw-r--r--media/webm/webm_content_encodings.cc3
-rw-r--r--media/webm/webm_content_encodings.h9
-rw-r--r--media/webm/webm_content_encodings_client.cc29
-rw-r--r--media/webm/webm_parser.cc9
-rw-r--r--media/webm/webm_stream_parser.cc1
8 files changed, 4 insertions, 101 deletions
diff --git a/media/webm/webm_cluster_parser.cc b/media/webm/webm_cluster_parser.cc
index 20d131e..c5a2fdc 100644
--- a/media/webm/webm_cluster_parser.cc
+++ b/media/webm/webm_cluster_parser.cc
@@ -5,31 +5,12 @@
#include "media/webm/webm_cluster_parser.h"
#include "base/logging.h"
-#include "base/sys_byteorder.h"
#include "media/base/data_buffer.h"
#include "media/base/decrypt_config.h"
#include "media/webm/webm_constants.h"
namespace media {
-// Generates a 16 byte CTR counter block. The CTR counter block format is a
-// CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV.
-// Always returns a valid pointer to a buffer of kDecryptionKeySize bytes.
-static scoped_array<uint8> GenerateCounterBlock(uint64 iv) {
- scoped_array<uint8> counter_block_data(
- new uint8[DecryptConfig::kDecryptionKeySize]);
-
- // Set the IV.
- memcpy(counter_block_data.get(), &iv, sizeof(iv));
-
- // Set block counter to all 0's.
- memset(counter_block_data.get() + sizeof(iv),
- 0,
- DecryptConfig::kDecryptionKeySize - sizeof(iv));
-
- return counter_block_data.Pass();
-}
-
WebMClusterParser::WebMClusterParser(int64 timecode_scale,
int audio_track_num,
int video_track_num,
@@ -212,33 +193,15 @@ bool WebMClusterParser::OnBlock(int track_num, int timecode,
base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
(cluster_timecode_ + timecode) * timecode_multiplier_);
- // Every encrypted Block has an HMAC and IV prepended to it. Current encrypted
- // WebM request for comments specification is here
- // http://wiki.webmproject.org/encryption/webm-encryption-rfc
- bool encrypted = track_num == video_.track_num() &&
- video_encryption_key_id_.get();
- // If encrypted skip past the HMAC. Encrypted buffers must include the IV and
- // the encrypted frame because the decryptor will verify this data before
- // decryption. The HMAC and IV will be copied into DecryptConfig.
- int offset = (encrypted) ? kWebMHmacSize : 0;
-
// The first bit of the flags is set when the block contains only keyframes.
// http://www.matroska.org/technical/specs/index.html
bool is_keyframe = (flags & 0x80) != 0;
scoped_refptr<StreamParserBuffer> buffer =
- StreamParserBuffer::CopyFrom(data + offset, size - offset, is_keyframe);
-
- if (encrypted) {
- uint64 network_iv;
- memcpy(&network_iv, data + kWebMHmacSize, sizeof(network_iv));
- const uint64 iv = base::NetToHost64(network_iv);
+ StreamParserBuffer::CopyFrom(data, size, is_keyframe);
- scoped_array<uint8> counter_block(GenerateCounterBlock(iv));
+ if (track_num == video_.track_num() && video_encryption_key_id_.get()) {
buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig(
- video_encryption_key_id_.get(), video_encryption_key_id_size_,
- counter_block.get(), DecryptConfig::kDecryptionKeySize,
- data, kWebMHmacSize,
- sizeof(iv))));
+ video_encryption_key_id_.get(), video_encryption_key_id_size_)));
}
buffer->SetTimestamp(timestamp);
diff --git a/media/webm/webm_cluster_parser.h b/media/webm/webm_cluster_parser.h
index 2bdb1e7..0af0361 100644
--- a/media/webm/webm_cluster_parser.h
+++ b/media/webm/webm_cluster_parser.h
@@ -19,10 +19,6 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient {
public:
typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
- // Size is defined by the WebM encryption specification.
- // http://wiki.webmproject.org/encryption/webm-encryption-rfc
- static const int kIvSize = 8;
-
WebMClusterParser(int64 timecode_scale,
int audio_track_num,
int video_track_num,
diff --git a/media/webm/webm_constants.h b/media/webm/webm_constants.h
index 93041b2..b6ba0a2 100644
--- a/media/webm/webm_constants.h
+++ b/media/webm/webm_constants.h
@@ -12,7 +12,6 @@ namespace media {
// WebM element IDs.
// This is a subset of the IDs in the Matroska spec.
// http://www.matroska.org/technical/specs/index.html
-const int kWebMIdAESSettingsCipherMode = 0x47E8;
const int kWebMIdAspectRatioType = 0x54B3;
const int kWebMIdAttachedFile = 0x61A7;
const int kWebMIdAttachmentLink = 0x7446;
@@ -63,7 +62,6 @@ const int kWebMIdColorSpace = 0x2EB524;
const int kWebMIdContentCompAlgo = 0x4254;
const int kWebMIdContentCompression = 0x5034;
const int kWebMIdContentCompSettings = 0x4255;
-const int kWebMIdContentEncAESSettings = 0x47E7;
const int kWebMIdContentEncAlgo = 0x47E1;
const int kWebMIdContentEncKeyID = 0x47E2;
const int kWebMIdContentEncoding = 0x6240;
@@ -199,11 +197,6 @@ const int64 kWebMUnknownSize = GG_LONGLONG(0x00FFFFFFFFFFFFFF);
const uint8 kWebMFlagKeyframe = 0x80;
-// The size is from the WebM encrypted specification. Current encrypted WebM
-// request for comments specification is here
-// http://wiki.webmproject.org/encryption/webm-encryption-rfc
-const int kWebMHmacSize = 12;
-
} // namespace media
#endif // MEDIA_WEBM_WEBM_CONSTANTS_H_
diff --git a/media/webm/webm_content_encodings.cc b/media/webm/webm_content_encodings.cc
index 540ac99..a5b7bfe 100644
--- a/media/webm/webm_content_encodings.cc
+++ b/media/webm/webm_content_encodings.cc
@@ -12,8 +12,7 @@ ContentEncoding::ContentEncoding()
scope_(kScopeInvalid),
type_(kTypeInvalid),
encryption_algo_(kEncAlgoInvalid),
- encryption_key_id_size_(0),
- cipher_mode_(kCipherModeInvalid) {
+ encryption_key_id_size_(0) {
}
ContentEncoding::~ContentEncoding() {}
diff --git a/media/webm/webm_content_encodings.h b/media/webm/webm_content_encodings.h
index ea903d8..2947a26 100644
--- a/media/webm/webm_content_encodings.h
+++ b/media/webm/webm_content_encodings.h
@@ -42,11 +42,6 @@ class MEDIA_EXPORT ContentEncoding {
kEncAlgoAes = 5,
};
- enum CipherMode {
- kCipherModeInvalid = 0,
- kCipherModeCtr = 1,
- };
-
ContentEncoding();
~ContentEncoding();
@@ -69,9 +64,6 @@ class MEDIA_EXPORT ContentEncoding {
void SetEncryptionKeyId(const uint8* encryption_key_id, int size);
- CipherMode cipher_mode() const { return cipher_mode_; }
- void set_cipher_mode(CipherMode mode) { cipher_mode_ = mode; }
-
private:
int64 order_;
Scope scope_;
@@ -79,7 +71,6 @@ class MEDIA_EXPORT ContentEncoding {
EncryptionAlgo encryption_algo_;
scoped_array<uint8> encryption_key_id_;
int encryption_key_id_size_;
- CipherMode cipher_mode_;
DISALLOW_COPY_AND_ASSIGN(ContentEncoding);
};
diff --git a/media/webm/webm_content_encodings_client.cc b/media/webm/webm_content_encodings_client.cc
index a24b4bf..086f85b 100644
--- a/media/webm/webm_content_encodings_client.cc
+++ b/media/webm/webm_content_encodings_client.cc
@@ -50,11 +50,6 @@ WebMParserClient* WebMContentEncodingsClient::OnListStart(int id) {
return this;
}
- if (id == kWebMIdContentEncAESSettings) {
- DCHECK(cur_content_encoding_.get());
- return this;
- }
-
// This should not happen if WebMListParser is working properly.
DCHECK(false);
return NULL;
@@ -126,13 +121,6 @@ bool WebMContentEncodingsClient::OnListEnd(int id) {
return true;
}
- if (id == kWebMIdContentEncAESSettings) {
- if (cur_content_encoding_->cipher_mode() ==
- ContentEncoding::kCipherModeInvalid)
- cur_content_encoding_->set_cipher_mode(ContentEncoding::kCipherModeCtr);
- return true;
- }
-
// This should not happen if WebMListParser is working properly.
DCHECK(false);
return false;
@@ -218,23 +206,6 @@ bool WebMContentEncodingsClient::OnUInt(int id, int64 val) {
return true;
}
- if (id == kWebMIdAESSettingsCipherMode) {
- if (cur_content_encoding_->cipher_mode() !=
- ContentEncoding::kCipherModeInvalid) {
- DVLOG(1) << "Unexpected multiple AESSettingsCipherMode.";
- return false;
- }
-
- if (val != ContentEncoding::kCipherModeCtr) {
- DVLOG(1) << "Unexpected AESSettingsCipherMode " << val << ".";
- return false;
- }
-
- cur_content_encoding_->set_cipher_mode(
- static_cast<ContentEncoding::CipherMode>(val));
- return true;
- }
-
// This should not happen if WebMListParser is working properly.
DCHECK(false);
return false;
diff --git a/media/webm/webm_parser.cc b/media/webm/webm_parser.cc
index 9952efa..28c847b 100644
--- a/media/webm/webm_parser.cc
+++ b/media/webm/webm_parser.cc
@@ -7,9 +7,6 @@
// This file contains code to parse WebM file elements. It was created
// from information in the Matroska spec.
// http://www.matroska.org/technical/specs/index.html
-// This file contains code for encrypted WebM. Current WebM
-// encrypted request for comments specification is here
-// http://wiki.webmproject.org/encryption/webm-encryption-rfc
#include <iomanip>
@@ -235,7 +232,6 @@ static const ElementIdInfo kContentCompressionIds[] = {
};
static const ElementIdInfo kContentEncryptionIds[] = {
- {LIST, kWebMIdContentEncAESSettings},
{UINT, kWebMIdContentEncAlgo},
{BINARY, kWebMIdContentEncKeyID},
{BINARY, kWebMIdContentSignature},
@@ -244,10 +240,6 @@ static const ElementIdInfo kContentEncryptionIds[] = {
{UINT, kWebMIdContentSigHashAlgo},
};
-static const ElementIdInfo kContentEncAESSettingsIds[] = {
- {UINT, kWebMIdAESSettingsCipherMode},
-};
-
static const ElementIdInfo kCuesIds[] = {
{LIST, kWebMIdCuePoint},
};
@@ -384,7 +376,6 @@ static const ListElementInfo kListElementInfo[] = {
LIST_ELEMENT_INFO(kWebMIdContentEncoding, 4, kContentEncodingIds),
LIST_ELEMENT_INFO(kWebMIdContentCompression, 5, kContentCompressionIds),
LIST_ELEMENT_INFO(kWebMIdContentEncryption, 5, kContentEncryptionIds),
- LIST_ELEMENT_INFO(kWebMIdContentEncAESSettings, 6, kContentEncAESSettingsIds),
LIST_ELEMENT_INFO(kWebMIdCues, 1, kCuesIds),
LIST_ELEMENT_INFO(kWebMIdCuePoint, 2, kCuePointIds),
LIST_ELEMENT_INFO(kWebMIdCueTrackPositions, 3, kCueTrackPositionsIds),
diff --git a/media/webm/webm_stream_parser.cc b/media/webm/webm_stream_parser.cc
index d141bfd..602d227 100644
--- a/media/webm/webm_stream_parser.cc
+++ b/media/webm/webm_stream_parser.cc
@@ -352,7 +352,6 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
if (tracks_parser.video_encryption_key_id()) {
int key_id_size = tracks_parser.video_encryption_key_id_size();
CHECK_GT(key_id_size, 0);
- CHECK_LT(key_id_size, 2048);
scoped_array<uint8> key_id(new uint8[key_id_size]);
memcpy(key_id.get(), tracks_parser.video_encryption_key_id(), key_id_size);
need_key_cb_.Run(key_id.Pass(), key_id_size);