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

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

Issue 757873003: Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix bad merges 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 LOG(WARNING) << "AES GCM not supported, skipping tests"; 104 LOG(WARNING) << "AES GCM not supported, skipping tests";
105 return; 105 return;
106 } 106 }
107 107
108 const unsigned short kKeyLen[] = {0, 127, 257}; 108 const unsigned short kKeyLen[] = {0, 127, 257};
109 blink::WebCryptoKey key; 109 blink::WebCryptoKey key;
110 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { 110 for (size_t i = 0; i < arraysize(kKeyLen); ++i) {
111 SCOPED_TRACE(i); 111 SCOPED_TRACE(i);
112 EXPECT_EQ(Status::ErrorGenerateAesKeyLength(), 112 EXPECT_EQ(Status::ErrorGenerateAesKeyLength(),
113 GenerateSecretKey(CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 113 GenerateSecretKey(CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true,
114 0, &key)); 114 blink::WebCryptoKeyUsageDecrypt, &key));
115 } 115 }
116 } 116 }
117 117
118 TEST(WebCryptoAesGcmTest, GenerateKeyEmptyUsage) {
119 if (!SupportsAesGcm()) {
120 LOG(WARNING) << "AES GCM not supported, skipping tests";
121 return;
122 }
123
124 blink::WebCryptoKey key;
125 EXPECT_EQ(Status::ErrorCreateKeyEmptyUsages(),
126 GenerateSecretKey(CreateAesGcmKeyGenAlgorithm(256), true, 0, &key));
127 }
128
118 TEST(WebCryptoAesGcmTest, ImportExportJwk) { 129 TEST(WebCryptoAesGcmTest, ImportExportJwk) {
119 // Some Linux test runners may not have a new enough version of NSS. 130 // Some Linux test runners may not have a new enough version of NSS.
120 if (!SupportsAesGcm()) { 131 if (!SupportsAesGcm()) {
121 LOG(WARNING) << "AES GCM not supported, skipping tests"; 132 LOG(WARNING) << "AES GCM not supported, skipping tests";
122 return; 133 return;
123 } 134 }
124 135
125 const blink::WebCryptoAlgorithm algorithm = 136 const blink::WebCryptoAlgorithm algorithm =
126 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm); 137 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm);
127 138
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 test_authentication_tag, &plain_text)); 239 test_authentication_tag, &plain_text));
229 } 240 }
230 } 241 }
231 } 242 }
232 243
233 } // namespace 244 } // namespace
234 245
235 } // namespace webcrypto 246 } // namespace webcrypto
236 247
237 } // namespace content 248 } // 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