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

Side by Side Diff: crypto/hmac_openssl.cc

Issue 1870233002: Convert crypto to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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
« no previous file with comments | « crypto/hmac_nss.cc ('k') | crypto/nss_key_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <memory>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "crypto/openssl_util.h" 16 #include "crypto/openssl_util.h"
17 17
18 namespace crypto { 18 namespace crypto {
19 19
20 struct HMACPlatformData { 20 struct HMACPlatformData {
21 std::vector<unsigned char> key; 21 std::vector<unsigned char> key;
22 }; 22 };
23 23
24 HMAC::HMAC(HashAlgorithm hash_alg) : hash_alg_(hash_alg) { 24 HMAC::HMAC(HashAlgorithm hash_alg) : hash_alg_(hash_alg) {
(...skipping 23 matching lines...) Expand all
48 DCHECK(plat_); // Init must be called before Sign. 48 DCHECK(plat_); // Init must be called before Sign.
49 49
50 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length); 50 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length);
51 return !!::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(), 51 return !!::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(),
52 plat_->key.data(), plat_->key.size(), 52 plat_->key.data(), plat_->key.size(),
53 reinterpret_cast<const unsigned char*>(data.data()), 53 reinterpret_cast<const unsigned char*>(data.data()),
54 data.size(), result.safe_buffer(), NULL); 54 data.size(), result.safe_buffer(), NULL);
55 } 55 }
56 56
57 } // namespace crypto 57 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/hmac_nss.cc ('k') | crypto/nss_key_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698