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

Side by Side Diff: crypto/p224_spake_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 5 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
« no previous file with comments | « crypto/p224_spake.cc ('k') | crypto/p224_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/p224_spake.h" 5 #include "crypto/p224_spake.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <string> 10 #include <string>
8 11
9 #include "base/logging.h" 12 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 namespace crypto { 16 namespace crypto {
14 17
15 namespace { 18 namespace {
16 19
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 121
119 for (unsigned i = 0; i < kIterations; i++) { 122 for (unsigned i = 0; i < kIterations; i++) {
120 P224EncryptedKeyExchange client( 123 P224EncryptedKeyExchange client(
121 P224EncryptedKeyExchange::kPeerTypeClient, kPassword); 124 P224EncryptedKeyExchange::kPeerTypeClient, kPassword);
122 P224EncryptedKeyExchange server( 125 P224EncryptedKeyExchange server(
123 P224EncryptedKeyExchange::kPeerTypeServer, kPassword); 126 P224EncryptedKeyExchange::kPeerTypeServer, kPassword);
124 127
125 // We'll only be testing small values of i, but we don't want that to bias 128 // We'll only be testing small values of i, but we don't want that to bias
126 // the test coverage. So we disperse the value of i by multiplying by the 129 // the test coverage. So we disperse the value of i by multiplying by the
127 // FNV, 32-bit prime, producing a poor-man's PRNG. 130 // FNV, 32-bit prime, producing a poor-man's PRNG.
128 const uint32 rand = i * 16777619; 131 const uint32_t rand = i * 16777619;
129 132
130 for (unsigned round = 0;; round++) { 133 for (unsigned round = 0;; round++) {
131 std::string client_message, server_message; 134 std::string client_message, server_message;
132 client_message = client.GetNextMessage(); 135 client_message = client.GetNextMessage();
133 server_message = server.GetNextMessage(); 136 server_message = server.GetNextMessage();
134 137
135 if ((rand & 1) == round) { 138 if ((rand & 1) == round) {
136 const bool server_or_client = rand & 2; 139 const bool server_or_client = rand & 2;
137 std::string* m = server_or_client ? &server_message : &client_message; 140 std::string* m = server_or_client ? &server_message : &client_message;
138 if (rand & 4) { 141 if (rand & 4) {
(...skipping 26 matching lines...) Expand all
165 168
166 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending, 169 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending,
167 client_result); 170 client_result);
168 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending, 171 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending,
169 server_result); 172 server_result);
170 } 173 }
171 } 174 }
172 } 175 }
173 176
174 } // namespace crypto 177 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/p224_spake.cc ('k') | crypto/p224_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698