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

Side by Side Diff: crypto/hkdf_unittest.cc

Issue 1539353003: Switch to standard integer types in crypto/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
« no previous file with comments | « crypto/hkdf.cc ('k') | crypto/hmac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "crypto/hkdf.h" 5 #include "crypto/hkdf.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <string> 10 #include <string>
8 11
12 #include "base/macros.h"
9 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
11 15
12 using crypto::HKDF; 16 using crypto::HKDF;
13 17
14 namespace test { 18 namespace test {
15 namespace { 19 namespace {
16 20
17 struct HKDFTest { 21 struct HKDFTest {
18 const char* key_hex; 22 const char* key_hex;
(...skipping 30 matching lines...) Expand all
49 "8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395fa" 53 "8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395fa"
50 "a4b61a96c8", 54 "a4b61a96c8",
51 }, 55 },
52 }; 56 };
53 57
54 TEST(HKDFTest, HKDF) { 58 TEST(HKDFTest, HKDF) {
55 for (size_t i = 0; i < arraysize(kHKDFTests); i++) { 59 for (size_t i = 0; i < arraysize(kHKDFTests); i++) {
56 const HKDFTest& test(kHKDFTests[i]); 60 const HKDFTest& test(kHKDFTests[i]);
57 SCOPED_TRACE(i); 61 SCOPED_TRACE(i);
58 62
59 std::vector<uint8> data; 63 std::vector<uint8_t> data;
60 ASSERT_TRUE(base::HexStringToBytes(test.key_hex, &data)); 64 ASSERT_TRUE(base::HexStringToBytes(test.key_hex, &data));
61 const std::string key(reinterpret_cast<char*>(&data[0]), data.size()); 65 const std::string key(reinterpret_cast<char*>(&data[0]), data.size());
62 66
63 data.clear(); 67 data.clear();
64 // |salt_hex| is optional and may be empty. 68 // |salt_hex| is optional and may be empty.
65 std::string salt(test.salt_hex); 69 std::string salt(test.salt_hex);
66 if (!salt.empty()) { 70 if (!salt.empty()) {
67 ASSERT_TRUE(base::HexStringToBytes(salt, &data)); 71 ASSERT_TRUE(base::HexStringToBytes(salt, &data));
68 salt.assign(reinterpret_cast<char*>(&data[0]), data.size()); 72 salt.assign(reinterpret_cast<char*>(&data[0]), data.size());
69 } 73 }
(...skipping 15 matching lines...) Expand all
85 HKDF hkdf(key, salt, info, expected.size(), 0, 0); 89 HKDF hkdf(key, salt, info, expected.size(), 0, 0);
86 90
87 ASSERT_EQ(expected.size(), hkdf.client_write_key().size()); 91 ASSERT_EQ(expected.size(), hkdf.client_write_key().size());
88 EXPECT_EQ(0, memcmp(expected.data(), hkdf.client_write_key().data(), 92 EXPECT_EQ(0, memcmp(expected.data(), hkdf.client_write_key().data(),
89 expected.size())); 93 expected.size()));
90 } 94 }
91 } 95 }
92 96
93 } // namespace 97 } // namespace
94 } // namespace test 98 } // namespace test
OLDNEW
« no previous file with comments | « crypto/hkdf.cc ('k') | crypto/hmac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698