| Index: crypto/hmac.cc
|
| diff --git a/crypto/hmac.cc b/crypto/hmac.cc
|
| index 9131313d9e0514d4a4794c40427213862dcd0104..cfa395837dc3df9d3713e0e866c9c55d53558e9a 100644
|
| --- a/crypto/hmac.cc
|
| +++ b/crypto/hmac.cc
|
| @@ -8,9 +8,23 @@
|
|
|
| #include "base/logging.h"
|
| #include "crypto/secure_util.h"
|
| +#include "crypto/symmetric_key.h"
|
|
|
| namespace crypto {
|
|
|
| +bool HMAC::Init(SymmetricKey* key) {
|
| + std::string raw_key;
|
| + bool result = key->GetRawKey(&raw_key) && Init(raw_key);
|
| + // Zero out key copy. This probably just gets optimized away,
|
| + // but one can hope. Using std::string to store key info at all is a larger
|
| + // problem. This trys to keep the fill call from being optimized away by
|
| + // creating an alias to internal data with a volatile.
|
| + volatile char *optimization_blocker = const_cast<char*>(raw_key.data());
|
| + std::fill(raw_key.begin(), raw_key.end(), 0);
|
| + optimization_blocker = NULL;
|
| + return result;
|
| +}
|
| +
|
| size_t HMAC::DigestLength() const {
|
| switch (hash_alg_) {
|
| case SHA1:
|
|
|