| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Utility class for calculating the HMAC for a given message. We currently | 5 // Utility class for calculating the HMAC for a given message. We currently |
| 6 // only support SHA1 for the hash algorithm, but this can be extended easily. | 6 // only support SHA1 for the hash algorithm, but this can be extended easily. |
| 7 | 7 |
| 8 #ifndef BASE_HMAC_H_ | 8 #ifndef CRYPTO_HMAC_H_ |
| 9 #define BASE_HMAC_H_ | 9 #define CRYPTO_HMAC_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/base_api.h" | |
| 15 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 16 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 17 | 16 |
| 18 namespace base { | 17 namespace crypto { |
| 19 | 18 |
| 20 // Simplify the interface and reduce includes by abstracting out the internals. | 19 // Simplify the interface and reduce includes by abstracting out the internals. |
| 21 struct HMACPlatformData; | 20 struct HMACPlatformData; |
| 22 | 21 |
| 23 class BASE_API HMAC { | 22 class HMAC { |
| 24 public: | 23 public: |
| 25 // The set of supported hash functions. Extend as required. | 24 // The set of supported hash functions. Extend as required. |
| 26 enum HashAlgorithm { | 25 enum HashAlgorithm { |
| 27 SHA1, | 26 SHA1, |
| 28 SHA256, | 27 SHA256, |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 explicit HMAC(HashAlgorithm hash_alg); | 30 explicit HMAC(HashAlgorithm hash_alg); |
| 32 ~HMAC(); | 31 ~HMAC(); |
| 33 | 32 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 | 48 |
| 50 // TODO(albertb): Add a Verify method. | 49 // TODO(albertb): Add a Verify method. |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 HashAlgorithm hash_alg_; | 52 HashAlgorithm hash_alg_; |
| 54 scoped_ptr<HMACPlatformData> plat_; | 53 scoped_ptr<HMACPlatformData> plat_; |
| 55 | 54 |
| 56 DISALLOW_COPY_AND_ASSIGN(HMAC); | 55 DISALLOW_COPY_AND_ASSIGN(HMAC); |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 } // namespace base | 58 } // namespace crypto |
| 60 | 59 |
| 61 #endif // BASE_HMAC_H_ | 60 #endif // CRYPTO_HMAC_H_ |
| OLD | NEW |