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

Side by Side Diff: content/child/webcrypto/test/aes_kw_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 11 matching lines...) Expand all
22 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesKw, 22 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesKw,
23 key_length_bits); 23 key_length_bits);
24 } 24 }
25 25
26 TEST(WebCryptoAesKwTest, GenerateKeyBadLength) { 26 TEST(WebCryptoAesKwTest, GenerateKeyBadLength) {
27 const unsigned short kKeyLen[] = {0, 127, 257}; 27 const unsigned short kKeyLen[] = {0, 127, 257};
28 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 28 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
29 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) { 29 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) {
30 SCOPED_TRACE(i); 30 SCOPED_TRACE(i);
31 EXPECT_EQ(Status::ErrorGenerateKeyLength(), 31 EXPECT_EQ(Status::ErrorGenerateKeyLength(),
32 GenerateSecretKey( 32 GenerateKey(
33 CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); 33 CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, NULL, &key));
34 } 34 }
35 } 35 }
36 36
37 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { 37 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) {
38 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 38 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
39 base::DictionaryValue dict; 39 base::DictionaryValue dict;
40 dict.SetString("kty", "oct"); 40 dict.SetString("kty", "oct");
41 dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg=="); 41 dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg==");
42 base::ListValue* key_ops = new base::ListValue; 42 base::ListValue* key_ops = new base::ListValue;
43 dict.Set("key_ops", key_ops); // Takes ownership. 43 dict.Set("key_ops", key_ops); // Takes ownership.
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 bad_usages[i], 598 bad_usages[i],
599 &key)); 599 &key));
600 } 600 }
601 } 601 }
602 602
603 } // namespace 603 } // namespace
604 604
605 } // namespace webcrypto 605 } // namespace webcrypto
606 606
607 } // namespace content 607 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698