OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <CommonCrypto/CommonDigest.h> |
| 6 #include <CommonCrypto/CommonHMAC.h> |
| 7 #include <string> |
| 8 |
5 #include "base/hmac.h" | 9 #include "base/hmac.h" |
6 | |
7 #include <CommonCrypto/CommonHMAC.h> | |
8 | |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/scoped_ptr.h" |
10 | 12 |
11 namespace base { | 13 namespace base { |
12 | 14 |
13 struct HMACPlatformData { | 15 struct HMACPlatformData { |
14 std::string key_; | 16 std::string key_; |
15 }; | 17 }; |
16 | 18 |
17 HMAC::HMAC(HashAlgorithm hash_alg) | 19 HMAC::HMAC(HashAlgorithm hash_alg) |
18 : hash_alg_(hash_alg), plat_(new HMACPlatformData()) { | 20 : hash_alg_(hash_alg), plat_(new HMACPlatformData()) { |
19 // Only SHA-1 and SHA-256 hash algorithms are supported now. | 21 // Only SHA-1 and SHA-256 hash algorithms are supported now. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 66 } |
65 | 67 |
66 CCHmac(algorithm, | 68 CCHmac(algorithm, |
67 plat_->key_.data(), plat_->key_.length(), data.data(), data.length(), | 69 plat_->key_.data(), plat_->key_.length(), data.data(), data.length(), |
68 digest); | 70 digest); |
69 | 71 |
70 return true; | 72 return true; |
71 } | 73 } |
72 | 74 |
73 } // namespace base | 75 } // namespace base |
OLD | NEW |