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

Side by Side Diff: components/webcrypto/algorithms/aes_ctr_unittest.cc

Issue 2160943003: Transfer WebCrypto databuffers across the Blink API using blink::WebVector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "components/webcrypto/algorithm_dispatch.h" 10 #include "components/webcrypto/algorithm_dispatch.h"
11 #include "components/webcrypto/algorithms/test_helpers.h" 11 #include "components/webcrypto/algorithms/test_helpers.h"
12 #include "components/webcrypto/crypto_data.h" 12 #include "components/webcrypto/crypto_data.h"
13 #include "components/webcrypto/status.h" 13 #include "components/webcrypto/status.h"
14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
16 16
17 namespace webcrypto { 17 namespace webcrypto {
18 18
19 namespace { 19 namespace {
20 20
21 // Creates an AES-CTR algorithm for encryption/decryption. 21 // Creates an AES-CTR algorithm for encryption/decryption.
22 blink::WebCryptoAlgorithm CreateAesCtrAlgorithm( 22 blink::WebCryptoAlgorithm CreateAesCtrAlgorithm(
23 const std::vector<uint8_t>& counter, 23 const std::vector<uint8_t>& counter,
24 uint8_t length_bits) { 24 uint8_t length_bits) {
25 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 25 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
26 blink::WebCryptoAlgorithmIdAesCtr, 26 blink::WebCryptoAlgorithmIdAesCtr,
27 new blink::WebCryptoAesCtrParams( 27 new blink::WebCryptoAesCtrParams(length_bits, counter));
28 length_bits, counter.data(),
29 static_cast<unsigned int>(counter.size())));
30 } 28 }
31 29
32 class WebCryptoAesCtrTest : public WebCryptoTestBase {}; 30 class WebCryptoAesCtrTest : public WebCryptoTestBase {};
33 31
34 TEST_F(WebCryptoAesCtrTest, EncryptDecryptKnownAnswer) { 32 TEST_F(WebCryptoAesCtrTest, EncryptDecryptKnownAnswer) {
35 std::unique_ptr<base::ListValue> tests; 33 std::unique_ptr<base::ListValue> tests;
36 ASSERT_TRUE(ReadJsonTestFileToList("aes_ctr.json", &tests)); 34 ASSERT_TRUE(ReadJsonTestFileToList("aes_ctr.json", &tests));
37 35
38 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) { 36 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) {
39 SCOPED_TRACE(test_index); 37 SCOPED_TRACE(test_index);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 input_17, &output)); 162 input_17, &output));
165 EXPECT_EQ(Status::ErrorAesCtrInputTooLongCounterRepeated(), 163 EXPECT_EQ(Status::ErrorAesCtrInputTooLongCounterRepeated(),
166 Decrypt(CreateAesCtrAlgorithm(counter, kCounterLengthBits), key, 164 Decrypt(CreateAesCtrAlgorithm(counter, kCounterLengthBits), key,
167 input_17, &output)); 165 input_17, &output));
168 } 166 }
169 } 167 }
170 168
171 } // namespace 169 } // namespace
172 170
173 } // namespace webcrypto 171 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/aes_cbc_unittest.cc ('k') | components/webcrypto/algorithms/aes_gcm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698