OLD | NEW |
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> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 static const unsigned kIterations = 40; | 120 static const unsigned kIterations = 40; |
121 | 121 |
122 for (unsigned i = 0; i < kIterations; i++) { | 122 for (unsigned i = 0; i < kIterations; i++) { |
123 P224EncryptedKeyExchange client( | 123 P224EncryptedKeyExchange client( |
124 P224EncryptedKeyExchange::kPeerTypeClient, kPassword); | 124 P224EncryptedKeyExchange::kPeerTypeClient, kPassword); |
125 P224EncryptedKeyExchange server( | 125 P224EncryptedKeyExchange server( |
126 P224EncryptedKeyExchange::kPeerTypeServer, kPassword); | 126 P224EncryptedKeyExchange::kPeerTypeServer, kPassword); |
127 | 127 |
128 // 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 |
129 // 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 |
130 // FNV, 32-bit prime, producing a poor-man's PRNG. | 130 // FNV, 32-bit prime, producing a simplistic PRNG. |
131 const uint32_t rand = i * 16777619; | 131 const uint32_t rand = i * 16777619; |
132 | 132 |
133 for (unsigned round = 0;; round++) { | 133 for (unsigned round = 0;; round++) { |
134 std::string client_message, server_message; | 134 std::string client_message, server_message; |
135 client_message = client.GetNextMessage(); | 135 client_message = client.GetNextMessage(); |
136 server_message = server.GetNextMessage(); | 136 server_message = server.GetNextMessage(); |
137 | 137 |
138 if ((rand & 1) == round) { | 138 if ((rand & 1) == round) { |
139 const bool server_or_client = rand & 2; | 139 const bool server_or_client = rand & 2; |
140 std::string* m = server_or_client ? &server_message : &client_message; | 140 std::string* m = server_or_client ? &server_message : &client_message; |
(...skipping 27 matching lines...) Expand all Loading... |
168 | 168 |
169 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending, | 169 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending, |
170 client_result); | 170 client_result); |
171 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending, | 171 ASSERT_EQ(P224EncryptedKeyExchange::kResultPending, |
172 server_result); | 172 server_result); |
173 } | 173 } |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 } // namespace crypto | 177 } // namespace crypto |
OLD | NEW |