| 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 #include "crypto/hmac.h" | 5 #include "crypto/hmac.h" |
| 6 | 6 |
| 7 #include <openssl/hmac.h> | 7 #include <openssl/hmac.h> |
| 8 #include <stddef.h> |
| 8 | 9 |
| 9 #include <algorithm> | 10 #include <algorithm> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "crypto/openssl_util.h" | 16 #include "crypto/openssl_util.h" |
| 16 | 17 |
| 17 namespace crypto { | 18 namespace crypto { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 47 DCHECK(plat_); // Init must be called before Sign. | 48 DCHECK(plat_); // Init must be called before Sign. |
| 48 | 49 |
| 49 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length); | 50 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length); |
| 50 return !!::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(), | 51 return !!::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(), |
| 51 plat_->key.data(), plat_->key.size(), | 52 plat_->key.data(), plat_->key.size(), |
| 52 reinterpret_cast<const unsigned char*>(data.data()), | 53 reinterpret_cast<const unsigned char*>(data.data()), |
| 53 data.size(), result.safe_buffer(), NULL); | 54 data.size(), result.safe_buffer(), NULL); |
| 54 } | 55 } |
| 55 | 56 |
| 56 } // namespace crypto | 57 } // namespace crypto |
| OLD | NEW |