| Index: crypto/p224_spake.cc
|
| diff --git a/crypto/p224_spake.cc b/crypto/p224_spake.cc
|
| index f20b10c5ec6f0f78cf14f0e55fa52eea8cf8155f..05fe68cd05bd1a385148223996d3434e32141c6e 100644
|
| --- a/crypto/p224_spake.cc
|
| +++ b/crypto/p224_spake.cc
|
| @@ -7,6 +7,8 @@
|
|
|
| #include <crypto/p224_spake.h>
|
|
|
| +#include <algorithm>
|
| +
|
| #include <base/logging.h>
|
| #include <crypto/p224.h>
|
| #include <crypto/random.h>
|
| @@ -105,14 +107,18 @@ P224EncryptedKeyExchange::P224EncryptedKeyExchange(
|
| // x_ is a random scalar.
|
| RandBytes(x_, sizeof(x_));
|
|
|
| - // X = g**x_
|
| - p224::Point X;
|
| - p224::ScalarBaseMult(x_, &X);
|
| -
|
| // Calculate |password| hash to get SPAKE password value.
|
| SHA256HashString(std::string(password.data(), password.length()),
|
| pw_, sizeof(pw_));
|
|
|
| + Init();
|
| +}
|
| +
|
| +void P224EncryptedKeyExchange::Init() {
|
| + // X = g**x_
|
| + p224::Point X;
|
| + p224::ScalarBaseMult(x_, &X);
|
| +
|
| // The client masks the Diffie-Hellman value, X, by adding M**pw and the
|
| // server uses N**pw.
|
| p224::Point MNpw;
|
| @@ -253,4 +259,10 @@ const std::string& P224EncryptedKeyExchange::GetUnverifiedKey() const {
|
| return key_;
|
| }
|
|
|
| +void P224EncryptedKeyExchange::SetXForTesting(const std::string& x) {
|
| + memset(&x_, 0, sizeof(x_));
|
| + memcpy(&x_, x.data(), std::min(x.size(), sizeof(x_)));
|
| + Init();
|
| +}
|
| +
|
| } // namespace crypto
|
|
|