| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "crypto/hmac.h" | 5 #include "crypto/hmac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "crypto/secure_util.h" | 10 #include "crypto/secure_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 return VerifyTruncated(data, digest); | 40 return VerifyTruncated(data, digest); |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool HMAC::VerifyTruncated(const base::StringPiece& data, | 43 bool HMAC::VerifyTruncated(const base::StringPiece& data, |
| 44 const base::StringPiece& digest) const { | 44 const base::StringPiece& digest) const { |
| 45 if (digest.empty()) | 45 if (digest.empty()) |
| 46 return false; | 46 return false; |
| 47 size_t digest_length = DigestLength(); | 47 size_t digest_length = DigestLength(); |
| 48 scoped_array<unsigned char> computed_digest( | 48 scoped_array<unsigned char> computed_digest( |
| 49 new unsigned char[digest_length]); | 49 new unsigned char[digest_length]); |
| 50 if (!Sign(data, computed_digest.get(), static_cast<int>(digest_length))) | 50 if (!Sign(data, computed_digest.get(), digest_length)) |
| 51 return false; | 51 return false; |
| 52 | 52 |
| 53 return SecureMemEqual(digest.data(), computed_digest.get(), | 53 return SecureMemEqual(digest.data(), computed_digest.get(), |
| 54 std::min(digest.size(), digest_length)); | 54 std::min(digest.size(), digest_length)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace crypto | 57 } // namespace crypto |
| OLD | NEW |