Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: base/hmac_openssl.cc

Issue 6714032: Move some files in base to base/memory. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: only base Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/hmac.h" 5 #include "base/hmac.h"
6 6
7 #include <openssl/hmac.h> 7 #include <openssl/hmac.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/openssl_util.h" 14 #include "base/openssl_util.h"
14 #include "base/scoped_ptr.h"
15 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
16 16
17 namespace base { 17 namespace base {
18 18
19 struct HMACPlatformData { 19 struct HMACPlatformData {
20 std::vector<unsigned char> key; 20 std::vector<unsigned char> key;
21 }; 21 };
22 22
23 HMAC::HMAC(HashAlgorithm hash_alg) 23 HMAC::HMAC(HashAlgorithm hash_alg)
24 : hash_alg_(hash_alg), plat_(new HMACPlatformData()) { 24 : hash_alg_(hash_alg), plat_(new HMACPlatformData()) {
(...skipping 23 matching lines...) Expand all
48 48
49 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length); 49 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length);
50 return ::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(), 50 return ::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(),
51 &plat_->key[0], plat_->key.size(), 51 &plat_->key[0], plat_->key.size(),
52 reinterpret_cast<const unsigned char*>(data.data()), 52 reinterpret_cast<const unsigned char*>(data.data()),
53 data.size(), 53 data.size(),
54 result.safe_buffer(), NULL); 54 result.safe_buffer(), NULL);
55 } 55 }
56 56
57 } // namespace base 57 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698