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

Side by Side Diff: crypto/p224_spake.cc

Issue 889663003: Renamed GetMessage into GetNextMessage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/p224_spake.h ('k') | crypto/p224_spake_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This code implements SPAKE2, a variant of EKE: 5 // This code implements SPAKE2, a variant of EKE:
6 // http://www.di.ens.fr/~pointche/pub.php?reference=AbPo04 6 // http://www.di.ens.fr/~pointche/pub.php?reference=AbPo04
7 7
8 #include <crypto/p224_spake.h> 8 #include <crypto/p224_spake.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 p224::Point MNpw; 124 p224::Point MNpw;
125 p224::ScalarMult(is_server_ ? kN : kM, pw_, &MNpw); 125 p224::ScalarMult(is_server_ ? kN : kM, pw_, &MNpw);
126 126
127 // X* = X + (N|M)**pw 127 // X* = X + (N|M)**pw
128 p224::Point Xstar; 128 p224::Point Xstar;
129 p224::Add(X, MNpw, &Xstar); 129 p224::Add(X, MNpw, &Xstar);
130 130
131 next_message_ = Xstar.ToString(); 131 next_message_ = Xstar.ToString();
132 } 132 }
133 133
134 const std::string& P224EncryptedKeyExchange::GetMessage() { 134 const std::string& P224EncryptedKeyExchange::GetNextMessage() {
135 if (state_ == kStateInitial) { 135 if (state_ == kStateInitial) {
136 state_ = kStateRecvDH; 136 state_ = kStateRecvDH;
137 return next_message_; 137 return next_message_;
138 } else if (state_ == kStateSendHash) { 138 } else if (state_ == kStateSendHash) {
139 state_ = kStateRecvHash; 139 state_ = kStateRecvHash;
140 return next_message_; 140 return next_message_;
141 } 141 }
142 142
143 LOG(FATAL) << "P224EncryptedKeyExchange::GetMessage called in" 143 LOG(FATAL) << "P224EncryptedKeyExchange::GetNextMessage called in"
144 " bad state " << state_; 144 " bad state " << state_;
145 next_message_ = ""; 145 next_message_ = "";
146 return next_message_; 146 return next_message_;
147 } 147 }
148 148
149 P224EncryptedKeyExchange::Result P224EncryptedKeyExchange::ProcessMessage( 149 P224EncryptedKeyExchange::Result P224EncryptedKeyExchange::ProcessMessage(
150 const base::StringPiece& message) { 150 const base::StringPiece& message) {
151 if (state_ == kStateRecvHash) { 151 if (state_ == kStateRecvHash) {
152 // This is the final state of the protocol: we are reading the peer's 152 // This is the final state of the protocol: we are reading the peer's
153 // authentication hash and checking that it matches the one that we expect. 153 // authentication hash and checking that it matches the one that we expect.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return key_; 259 return key_;
260 } 260 }
261 261
262 void P224EncryptedKeyExchange::SetXForTesting(const std::string& x) { 262 void P224EncryptedKeyExchange::SetXForTesting(const std::string& x) {
263 memset(&x_, 0, sizeof(x_)); 263 memset(&x_, 0, sizeof(x_));
264 memcpy(&x_, x.data(), std::min(x.size(), sizeof(x_))); 264 memcpy(&x_, x.data(), std::min(x.size(), sizeof(x_)));
265 Init(); 265 Init();
266 } 266 }
267 267
268 } // namespace crypto 268 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/p224_spake.h ('k') | crypto/p224_spake_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698