OLD | NEW |
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 <base/logging.h> | 10 #include <base/logging.h> |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 std::string(reinterpret_cast<const char *>(pw_), sizeof(pw_)); | 233 std::string(reinterpret_cast<const char *>(pw_), sizeof(pw_)); |
234 hash_contents += k; | 234 hash_contents += k; |
235 | 235 |
236 SHA256HashString(hash_contents, out_digest, kSHA256Length); | 236 SHA256HashString(hash_contents, out_digest, kSHA256Length); |
237 } | 237 } |
238 | 238 |
239 const std::string& P224EncryptedKeyExchange::error() const { | 239 const std::string& P224EncryptedKeyExchange::error() const { |
240 return error_; | 240 return error_; |
241 } | 241 } |
242 | 242 |
243 const std::string& P224EncryptedKeyExchange::GetKey() { | 243 const std::string& P224EncryptedKeyExchange::GetKey() const { |
244 DCHECK_EQ(state_, kStateDone); | 244 DCHECK_EQ(state_, kStateDone); |
| 245 return GetUnverifiedKey(); |
| 246 } |
| 247 |
| 248 const std::string& P224EncryptedKeyExchange::GetUnverifiedKey() const { |
| 249 // Key is already final when state is kStateSendHash. Subsequent states are |
| 250 // used only for verification of the key. Some users may combine verification |
| 251 // with sending verifiable data instead of |expected_authenticator_|. |
| 252 DCHECK_GE(state_, kStateSendHash); |
245 return key_; | 253 return key_; |
246 } | 254 } |
247 | 255 |
248 } // namespace crypto | 256 } // namespace crypto |
OLD | NEW |