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