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

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

Issue 745443002: Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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; 112 blink::WebCryptoKey key;
113 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { 113 for (size_t i = 0; i < arraysize(kKeyLen); ++i) {
114 SCOPED_TRACE(i); 114 SCOPED_TRACE(i);
115 EXPECT_EQ(Status::ErrorGenerateKeyLength(), 115 EXPECT_EQ(Status::ErrorGenerateKeyLength(),
116 GenerateSecretKey( 116 GenerateSecretKey(CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true,
117 CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); 117 blink::WebCryptoKeyUsageDecrypt, &key));
118 } 118 }
119 } 119 }
120 120
121 TEST(WebCryptoAesGcmTest, GenerateKeyEmptyUsage) {
122 if (!SupportsAesGcm()) {
123 LOG(WARNING) << "AES GCM not supported, skipping tests";
124 return;
125 }
126
127 blink::WebCryptoKey key;
128 EXPECT_EQ(Status::ErrorCreateKeyEmptyUsages(),
129 GenerateSecretKey(CreateAesGcmKeyGenAlgorithm(256), true, 0, &key));
130 }
131
121 TEST(WebCryptoAesGcmTest, ImportExportJwk) { 132 TEST(WebCryptoAesGcmTest, ImportExportJwk) {
122 // Some Linux test runners may not have a new enough version of NSS. 133 // Some Linux test runners may not have a new enough version of NSS.
123 if (!SupportsAesGcm()) { 134 if (!SupportsAesGcm()) {
124 LOG(WARNING) << "AES GCM not supported, skipping tests"; 135 LOG(WARNING) << "AES GCM not supported, skipping tests";
125 return; 136 return;
126 } 137 }
127 138
128 const blink::WebCryptoAlgorithm algorithm = 139 const blink::WebCryptoAlgorithm algorithm =
129 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm); 140 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm);
130 141
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 &plain_text)); 272 &plain_text));
262 } 273 }
263 } 274 }
264 } 275 }
265 276
266 } // namespace 277 } // namespace
267 278
268 } // namespace webcrypto 279 } // namespace webcrypto
269 280
270 } // namespace content 281 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/test/aes_cbc_unittest.cc ('k') | content/child/webcrypto/test/aes_kw_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698