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

Side by Side Diff: components/webcrypto/algorithms/aes_gcm_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 "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
16 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 16 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
17 17
18 namespace webcrypto { 18 namespace webcrypto {
19 19
20 namespace { 20 namespace {
21 21
22 // Creates an AES-GCM algorithm. 22 // Creates an AES-GCM algorithm.
23 blink::WebCryptoAlgorithm CreateAesGcmAlgorithm( 23 blink::WebCryptoAlgorithm CreateAesGcmAlgorithm(
24 const std::vector<uint8_t>& iv, 24 const std::vector<uint8_t>& iv,
25 const std::vector<uint8_t>& additional_data, 25 const std::vector<uint8_t>& additional_data,
26 unsigned int tag_length_bits) { 26 unsigned int tag_length_bits) {
27 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 27 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
28 blink::WebCryptoAlgorithmIdAesGcm, 28 blink::WebCryptoAlgorithmIdAesGcm,
29 new blink::WebCryptoAesGcmParams( 29 new blink::WebCryptoAesGcmParams(iv, true, additional_data, true,
30 iv.data(), static_cast<unsigned int>(iv.size()), true, 30 tag_length_bits));
31 additional_data.data(),
32 static_cast<unsigned int>(additional_data.size()), true,
33 tag_length_bits));
34 } 31 }
35 32
36 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( 33 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(
37 unsigned short key_length_bits) { 34 unsigned short key_length_bits) {
38 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, 35 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm,
39 key_length_bits); 36 key_length_bits);
40 } 37 }
41 38
42 Status AesGcmEncrypt(const blink::WebCryptoKey& key, 39 Status AesGcmEncrypt(const blink::WebCryptoKey& key,
43 const std::vector<uint8_t>& iv, 40 const std::vector<uint8_t>& iv,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 AesGcmDecrypt(key, test_iv, test_additional_data, 213 AesGcmDecrypt(key, test_iv, test_additional_data,
217 wrong_tag_size_bits, test_cipher_text, 214 wrong_tag_size_bits, test_cipher_text,
218 test_authentication_tag, &plain_text)); 215 test_authentication_tag, &plain_text));
219 } 216 }
220 } 217 }
221 } 218 }
222 219
223 } // namespace 220 } // namespace
224 221
225 } // namespace webcrypto 222 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/aes_ctr_unittest.cc ('k') | components/webcrypto/algorithms/rsa_oaep_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698