Skip to content

Commit

Permalink
Fix compilation errors on MSVC for x64
Browse files Browse the repository at this point in the history
With these gn args:
is_clang = false
target_cpu = "x64"

the file fails to compile due to uint64 -> uint32_t conversion.

Change-Id: I76126e6d170f01eedcccfd3a17f6aa4184753fe9
Reviewed-on: https://chromium-review.googlesource.com/1071287
Reviewed-by: John Rummell <jrummell@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562023}
  • Loading branch information
taop1 authored and Commit Bot committed May 25, 2018
1 parent 0b12888 commit 105d96e
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions media/cdm/cenc_decryptor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ TEST_F(CencDecryptorTest, OneBlock) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_);

// Only 1 subsample, all encrypted data.
std::vector<SubsampleEntry> subsamples = {{0, encrypted_block.size()}};
std::vector<SubsampleEntry> subsamples = {
{0, static_cast<uint32_t>(encrypted_block.size())}};

auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
Expand All @@ -140,7 +141,8 @@ TEST_F(CencDecryptorTest, ExtraData) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_);

// Only 1 subsample, all encrypted data.
std::vector<SubsampleEntry> subsamples = {{0, encrypted_block.size()}};
std::vector<SubsampleEntry> subsamples = {
{0, static_cast<uint32_t>(encrypted_block.size())}};

auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
Expand Down Expand Up @@ -179,7 +181,8 @@ TEST_F(CencDecryptorTest, BadSubsamples) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_);

// Subsample size > data size.
std::vector<SubsampleEntry> subsamples = {{0, encrypted_block.size() + 1}};
std::vector<SubsampleEntry> subsamples = {
{0, static_cast<uint32_t>(encrypted_block.size() + 1)}};

auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
Expand All @@ -189,7 +192,8 @@ TEST_F(CencDecryptorTest, BadSubsamples) {
TEST_F(CencDecryptorTest, InvalidIv) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_);

std::vector<SubsampleEntry> subsamples = {{0, encrypted_block.size()}};
std::vector<SubsampleEntry> subsamples = {
{0, static_cast<uint32_t>(encrypted_block.size())}};

// Use an invalid IV for decryption. Call should succeed, but return
// something other than the original data.
Expand All @@ -204,7 +208,8 @@ TEST_F(CencDecryptorTest, InvalidKey) {
crypto::SymmetricKey::AES, std::string(arraysize(kKey), 'b'));
auto encrypted_block = Encrypt(one_block_, *key_, iv_);

std::vector<SubsampleEntry> subsamples = {{0, encrypted_block.size()}};
std::vector<SubsampleEntry> subsamples = {
{0, static_cast<uint32_t>(encrypted_block.size())}};

// Use a different key for decryption. Call should succeed, but return
// something other than the original data.
Expand All @@ -217,7 +222,8 @@ TEST_F(CencDecryptorTest, PartialBlock) {
auto encrypted_block = Encrypt(partial_block_, *key_, iv_);

// Only 1 subsample, all encrypted data.
std::vector<SubsampleEntry> subsamples = {{0, encrypted_block.size()}};
std::vector<SubsampleEntry> subsamples = {
{0, static_cast<uint32_t>(encrypted_block.size())}};

auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
Expand All @@ -230,7 +236,9 @@ TEST_F(CencDecryptorTest, MultipleSubsamples) {

// Treat as 3 subsamples.
std::vector<SubsampleEntry> subsamples = {
{0, one_block_.size()}, {0, one_block_.size()}, {0, one_block_.size()}};
{0, static_cast<uint32_t>(one_block_.size())},
{0, static_cast<uint32_t>(one_block_.size())},
{0, static_cast<uint32_t>(one_block_.size())}};

auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
Expand Down Expand Up @@ -258,9 +266,11 @@ TEST_F(CencDecryptorTest, MultipleSubsamplesWithClearBytes) {
auto expected_result = Combine(
{one_block_, partial_block_, partial_block_, one_block_, partial_block_});
std::vector<SubsampleEntry> subsamples = {
{one_block_.size(), partial_block_.size()},
{partial_block_.size(), one_block_.size()},
{partial_block_.size(), 0}};
{static_cast<uint32_t>(one_block_.size()),
static_cast<uint32_t>(partial_block_.size())},
{static_cast<uint32_t>(partial_block_.size()),
static_cast<uint32_t>(one_block_.size())},
{static_cast<uint32_t>(partial_block_.size()), 0}};

auto encrypted_buffer = CreateEncryptedBuffer(input_data, iv_, subsamples);
EXPECT_EQ(expected_result, DecryptWithKey(encrypted_buffer, *key_));
Expand Down

0 comments on commit 105d96e

Please sign in to comment.