diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-08 13:58:10 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-08 13:58:10 +0000 |
commit | fbcfafe4cd6d4f69ad0e1e3d921fb05bb5fcadfd (patch) | |
tree | 546a86df37312e589e6a9c0da1e94a42b40b0e36 /base/hmac_mac.cc | |
parent | 9795ec11c994c7750a19aeab79cbf094df0d90dd (diff) | |
download | chromium_src-fbcfafe4cd6d4f69ad0e1e3d921fb05bb5fcadfd.zip chromium_src-fbcfafe4cd6d4f69ad0e1e3d921fb05bb5fcadfd.tar.gz chromium_src-fbcfafe4cd6d4f69ad0e1e3d921fb05bb5fcadfd.tar.bz2 |
Remove the ifdef platform jungle from hmac.h, abstracting the platform specific data into a platform specific heap-allocated structure.
Review URL: http://codereview.chromium.org/1614
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/hmac_mac.cc')
-rw-r--r-- | base/hmac_mac.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/base/hmac_mac.cc b/base/hmac_mac.cc index 0542a70..b2d0a33 100644 --- a/base/hmac_mac.cc +++ b/base/hmac_mac.cc @@ -10,16 +10,22 @@ namespace base { +struct HMACPlatformData { + std::string key_; +}; + HMAC::HMAC(HashAlgorithm hash_alg, const unsigned char* key, int key_length) - : hash_alg_(hash_alg), - key_(reinterpret_cast<const char*>(key), key_length) { + : hash_alg_(hash_alg), plat_(new HMACPlatformData()) { + plat_->key_.assign(reinterpret_cast<const char*>(key), key_length); } HMAC::~HMAC() { // Zero out key copy. - key_.assign(key_.length(), std::string::value_type()); - key_.clear(); - key_.reserve(0); + plat_->key_.assign(plat_->key_.length(), std::string::value_type()); + plat_->key_.clear(); + plat_->key_.reserve(0); + + delete plat_; } bool HMAC::Sign(const std::string& data, @@ -43,7 +49,7 @@ bool HMAC::Sign(const std::string& data, } CCHmac(algorithm, - key_.data(), key_.length(), data.data(), data.length(), + plat_->key_.data(), plat_->key_.length(), data.data(), data.length(), digest); return true; |