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

Side by Side Diff: content/child/webcrypto/test/aes_gcm_unittest.cc

Issue 512023002: Refactor the interface for generating keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 "base/stl_util.h" 5 #include "base/stl_util.h"
6 #include "content/child/webcrypto/algorithm_dispatch.h" 6 #include "content/child/webcrypto/algorithm_dispatch.h"
7 #include "content/child/webcrypto/crypto_data.h" 7 #include "content/child/webcrypto/crypto_data.h"
8 #include "content/child/webcrypto/status.h" 8 #include "content/child/webcrypto/status.h"
9 #include "content/child/webcrypto/test/test_helpers.h" 9 #include "content/child/webcrypto/test/test_helpers.h"
10 #include "content/child/webcrypto/webcrypto_util.h" 10 #include "content/child/webcrypto/webcrypto_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 TEST(WebCryptoAesGcmTest, GenerateKeyBadLength) { 105 TEST(WebCryptoAesGcmTest, GenerateKeyBadLength) {
106 if (!SupportsAesGcm()) { 106 if (!SupportsAesGcm()) {
107 LOG(WARNING) << "AES GCM not supported, skipping tests"; 107 LOG(WARNING) << "AES GCM not supported, skipping tests";
108 return; 108 return;
109 } 109 }
110 110
111 const unsigned short kKeyLen[] = {0, 127, 257}; 111 const unsigned short kKeyLen[] = {0, 127, 257};
112 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 112 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
113 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) { 113 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) {
114 SCOPED_TRACE(i); 114 SCOPED_TRACE(i);
115 EXPECT_EQ(Status::ErrorGenerateKeyLength(), 115 EXPECT_EQ(
116 GenerateSecretKey( 116 Status::ErrorGenerateKeyLength(),
117 CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); 117 GenerateKey(
118 CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 0, NULL, &key));
118 } 119 }
119 } 120 }
120 121
121 TEST(WebCryptoAesGcmTest, ImportExportJwk) { 122 TEST(WebCryptoAesGcmTest, ImportExportJwk) {
122 // Some Linux test runners may not have a new enough version of NSS. 123 // Some Linux test runners may not have a new enough version of NSS.
123 if (!SupportsAesGcm()) { 124 if (!SupportsAesGcm()) {
124 LOG(WARNING) << "AES GCM not supported, skipping tests"; 125 LOG(WARNING) << "AES GCM not supported, skipping tests";
125 return; 126 return;
126 } 127 }
127 128
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 &plain_text)); 262 &plain_text));
262 } 263 }
263 } 264 }
264 } 265 }
265 266
266 } // namespace 267 } // namespace
267 268
268 } // namespace webcrypto 269 } // namespace webcrypto
269 270
270 } // namespace content 271 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698