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

Side by Side Diff: content/renderer/webcrypto/webcrypto_impl_unittest.cc

Issue 53533004: [webcrypto] Remove the TODO for NullKey(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webcrypto_impl.h" 5 #include "webcrypto_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool extractable = true; 107 bool extractable = true;
108 EXPECT_TRUE(crypto_.ImportKeyInternal(WebKit::WebCryptoKeyFormatRaw, 108 EXPECT_TRUE(crypto_.ImportKeyInternal(WebKit::WebCryptoKeyFormatRaw,
109 Start(key_raw), 109 Start(key_raw),
110 key_raw.size(), 110 key_raw.size(),
111 algorithm, 111 algorithm,
112 extractable, 112 extractable,
113 usage, 113 usage,
114 &key)); 114 &key));
115 115
116 EXPECT_EQ(WebKit::WebCryptoKeyTypeSecret, key.type()); 116 EXPECT_EQ(WebKit::WebCryptoKeyTypeSecret, key.type());
117 EXPECT_FALSE(key.isNull());
117 EXPECT_TRUE(key.handle()); 118 EXPECT_TRUE(key.handle());
118 return key; 119 return key;
119 } 120 }
120 121
121 // Forwarding methods to gain access to protected methods of 122 // Forwarding methods to gain access to protected methods of
122 // WebCryptoImpl. 123 // WebCryptoImpl.
123 124
124 bool DigestInternal( 125 bool DigestInternal(
125 const WebKit::WebCryptoAlgorithm& algorithm, 126 const WebKit::WebCryptoAlgorithm& algorithm,
126 const std::vector<uint8>& data, 127 const std::vector<uint8>& data,
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 WebKit::WebCryptoKey key = WebKit::WebCryptoKey::createNull(); 652 WebKit::WebCryptoKey key = WebKit::WebCryptoKey::createNull();
652 EXPECT_FALSE(GenerateKeyInternal(CreateAesCbcAlgorithm(0), &key)); 653 EXPECT_FALSE(GenerateKeyInternal(CreateAesCbcAlgorithm(0), &key));
653 EXPECT_FALSE(GenerateKeyInternal(CreateAesCbcAlgorithm(129), &key)); 654 EXPECT_FALSE(GenerateKeyInternal(CreateAesCbcAlgorithm(129), &key));
654 } 655 }
655 656
656 TEST_F(WebCryptoImplTest, GenerateKeyHmac) { 657 TEST_F(WebCryptoImplTest, GenerateKeyHmac) {
657 WebKit::WebCryptoKey key = WebKit::WebCryptoKey::createNull(); 658 WebKit::WebCryptoKey key = WebKit::WebCryptoKey::createNull();
658 WebKit::WebCryptoAlgorithm algorithm = 659 WebKit::WebCryptoAlgorithm algorithm =
659 CreateHmacKeyAlgorithm(WebKit::WebCryptoAlgorithmIdSha1, 128); 660 CreateHmacKeyAlgorithm(WebKit::WebCryptoAlgorithmIdSha1, 128);
660 ASSERT_TRUE(GenerateKeyInternal(algorithm, &key)); 661 ASSERT_TRUE(GenerateKeyInternal(algorithm, &key));
662 EXPECT_FALSE(key.isNull());
661 EXPECT_TRUE(key.handle()); 663 EXPECT_TRUE(key.handle());
662 EXPECT_EQ(WebKit::WebCryptoKeyTypeSecret, key.type()); 664 EXPECT_EQ(WebKit::WebCryptoKeyTypeSecret, key.type());
663 } 665 }
664 666
665 TEST_F(WebCryptoImplTest, GenerateKeyHmacNoLength) { 667 TEST_F(WebCryptoImplTest, GenerateKeyHmacNoLength) {
666 WebKit::WebCryptoKey key = WebKit::WebCryptoKey::createNull(); 668 WebKit::WebCryptoKey key = WebKit::WebCryptoKey::createNull();
667 WebKit::WebCryptoAlgorithm algorithm = 669 WebKit::WebCryptoAlgorithm algorithm =
668 CreateHmacKeyAlgorithm(WebKit::WebCryptoAlgorithmIdSha1, 0); 670 CreateHmacKeyAlgorithm(WebKit::WebCryptoAlgorithmIdSha1, 0);
669 ASSERT_TRUE(GenerateKeyInternal(algorithm, &key)); 671 ASSERT_TRUE(GenerateKeyInternal(algorithm, &key));
670 EXPECT_TRUE(key.handle()); 672 EXPECT_TRUE(key.handle());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 EXPECT_EQ(WebKit::WebCryptoKeyTypePrivate, private_key.type()); 788 EXPECT_EQ(WebKit::WebCryptoKeyTypePrivate, private_key.type());
787 EXPECT_EQ(extractable, public_key.extractable()); 789 EXPECT_EQ(extractable, public_key.extractable());
788 EXPECT_EQ(extractable, private_key.extractable()); 790 EXPECT_EQ(extractable, private_key.extractable());
789 EXPECT_EQ(usage_mask, public_key.usages()); 791 EXPECT_EQ(usage_mask, public_key.usages());
790 EXPECT_EQ(usage_mask, private_key.usages()); 792 EXPECT_EQ(usage_mask, private_key.usages());
791 } 793 }
792 794
793 #endif // #if !defined(USE_OPENSSL) 795 #endif // #if !defined(USE_OPENSSL)
794 796
795 } // namespace content 797 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698