Commit 105d96e7 authored by Sergey Abbakumov's avatar Sergey Abbakumov Committed by Commit Bot

Fix compilation errors on MSVC for x64

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/1071287Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562023}
parent 0b128880
...@@ -129,7 +129,8 @@ TEST_F(CencDecryptorTest, OneBlock) { ...@@ -129,7 +129,8 @@ TEST_F(CencDecryptorTest, OneBlock) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_); auto encrypted_block = Encrypt(one_block_, *key_, iv_);
// Only 1 subsample, all encrypted data. // 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 = auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples); CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
...@@ -140,7 +141,8 @@ TEST_F(CencDecryptorTest, ExtraData) { ...@@ -140,7 +141,8 @@ TEST_F(CencDecryptorTest, ExtraData) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_); auto encrypted_block = Encrypt(one_block_, *key_, iv_);
// Only 1 subsample, all encrypted data. // 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 = auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples); CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
...@@ -179,7 +181,8 @@ TEST_F(CencDecryptorTest, BadSubsamples) { ...@@ -179,7 +181,8 @@ TEST_F(CencDecryptorTest, BadSubsamples) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_); auto encrypted_block = Encrypt(one_block_, *key_, iv_);
// Subsample size > data size. // 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 = auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples); CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
...@@ -189,7 +192,8 @@ TEST_F(CencDecryptorTest, BadSubsamples) { ...@@ -189,7 +192,8 @@ TEST_F(CencDecryptorTest, BadSubsamples) {
TEST_F(CencDecryptorTest, InvalidIv) { TEST_F(CencDecryptorTest, InvalidIv) {
auto encrypted_block = Encrypt(one_block_, *key_, iv_); 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 // Use an invalid IV for decryption. Call should succeed, but return
// something other than the original data. // something other than the original data.
...@@ -204,7 +208,8 @@ TEST_F(CencDecryptorTest, InvalidKey) { ...@@ -204,7 +208,8 @@ TEST_F(CencDecryptorTest, InvalidKey) {
crypto::SymmetricKey::AES, std::string(arraysize(kKey), 'b')); crypto::SymmetricKey::AES, std::string(arraysize(kKey), 'b'));
auto encrypted_block = Encrypt(one_block_, *key_, iv_); 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 // Use a different key for decryption. Call should succeed, but return
// something other than the original data. // something other than the original data.
...@@ -217,7 +222,8 @@ TEST_F(CencDecryptorTest, PartialBlock) { ...@@ -217,7 +222,8 @@ TEST_F(CencDecryptorTest, PartialBlock) {
auto encrypted_block = Encrypt(partial_block_, *key_, iv_); auto encrypted_block = Encrypt(partial_block_, *key_, iv_);
// Only 1 subsample, all encrypted data. // 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 = auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples); CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
...@@ -230,7 +236,9 @@ TEST_F(CencDecryptorTest, MultipleSubsamples) { ...@@ -230,7 +236,9 @@ TEST_F(CencDecryptorTest, MultipleSubsamples) {
// Treat as 3 subsamples. // Treat as 3 subsamples.
std::vector<SubsampleEntry> 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 = auto encrypted_buffer =
CreateEncryptedBuffer(encrypted_block, iv_, subsamples); CreateEncryptedBuffer(encrypted_block, iv_, subsamples);
...@@ -258,9 +266,11 @@ TEST_F(CencDecryptorTest, MultipleSubsamplesWithClearBytes) { ...@@ -258,9 +266,11 @@ TEST_F(CencDecryptorTest, MultipleSubsamplesWithClearBytes) {
auto expected_result = Combine( auto expected_result = Combine(
{one_block_, partial_block_, partial_block_, one_block_, partial_block_}); {one_block_, partial_block_, partial_block_, one_block_, partial_block_});
std::vector<SubsampleEntry> subsamples = { std::vector<SubsampleEntry> subsamples = {
{one_block_.size(), partial_block_.size()}, {static_cast<uint32_t>(one_block_.size()),
{partial_block_.size(), one_block_.size()}, static_cast<uint32_t>(partial_block_.size())},
{partial_block_.size(), 0}}; {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); auto encrypted_buffer = CreateEncryptedBuffer(input_data, iv_, subsamples);
EXPECT_EQ(expected_result, DecryptWithKey(encrypted_buffer, *key_)); EXPECT_EQ(expected_result, DecryptWithKey(encrypted_buffer, *key_));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment