summaryrefslogtreecommitdiffstats
path: root/base/hmac.h
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 13:58:10 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 13:58:10 +0000
commitfbcfafe4cd6d4f69ad0e1e3d921fb05bb5fcadfd (patch)
tree546a86df37312e589e6a9c0da1e94a42b40b0e36 /base/hmac.h
parent9795ec11c994c7750a19aeab79cbf094df0d90dd (diff)
downloadchromium_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.h')
-rw-r--r--base/hmac.h31
1 files changed, 4 insertions, 27 deletions
diff --git a/base/hmac.h b/base/hmac.h
index f9c0e604..ac48ec07 100644
--- a/base/hmac.h
+++ b/base/hmac.h
@@ -8,19 +8,15 @@
#ifndef BASE_HMAC_H_
#define BASE_HMAC_H_
-#include "build/build_config.h"
-
-#if defined(OS_WIN)
-#include <windows.h>
-#include <wincrypt.h>
-#endif
-
#include <string>
#include "base/basictypes.h"
namespace base {
+// Simplify the interface and reduce includes by abstracting out the internals.
+struct HMACPlatformData;
+
class HMAC {
public:
// The set of supported hash functions. Extend as required.
@@ -37,27 +33,8 @@ class HMAC {
bool Sign(const std::string& data, unsigned char* digest, int digest_length);
private:
-#if defined(OS_POSIX)
HashAlgorithm hash_alg_;
- std::string key_;
-#elif defined(OS_WIN)
- // Import the key so that we don't have to store it ourself.
- void ImportKey(const unsigned char* key, int key_length);
-
- // Returns the SHA1 hash of 'data' and 'key' in 'digest'. If there was any
- // error in the calculation, this method returns false, otherwise true.
- bool SignWithSHA1(const std::string& data,
- unsigned char* digest,
- int digest_length);
-
- // The hash algorithm to use.
- HashAlgorithm hash_alg_;
-
- // Windows Crypt API resources.
- HCRYPTPROV provider_;
- HCRYPTHASH hash_;
- HCRYPTKEY hkey_;
-#endif // OS_WIN
+ HMACPlatformData* plat_;
DISALLOW_COPY_AND_ASSIGN(HMAC);
};