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

Side by Side Diff: crypto/hmac_openssl.cc

Issue 6683060: Private API for extensions like ssh-client that need access to TCP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed changes to rand_util_unittest Created 9 years, 7 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
« no previous file with comments | « crypto/hmac_nss.cc ('k') | crypto/hmac_win.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 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 HMAC::~HMAC() { 37 HMAC::~HMAC() {
38 // Zero out key copy. 38 // Zero out key copy.
39 plat_->key.assign(plat_->key.size(), 0); 39 plat_->key.assign(plat_->key.size(), 0);
40 STLClearObject(&plat_->key); 40 STLClearObject(&plat_->key);
41 } 41 }
42 42
43 bool HMAC::Sign(const std::string& data, 43 bool HMAC::Sign(const std::string& data,
44 unsigned char* digest, 44 unsigned char* digest,
45 int digest_length) { 45 int digest_length) const {
46 DCHECK_GE(digest_length, 0); 46 DCHECK_GE(digest_length, 0);
47 DCHECK(!plat_->key.empty()); // Init must be called before Sign. 47 DCHECK(!plat_->key.empty()); // Init must be called before Sign.
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 crypto 57 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/hmac_nss.cc ('k') | crypto/hmac_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698