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

Side by Side Diff: crypto/hmac_win.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_openssl.cc ('k') | crypto/symmetric_key_mac.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 <windows.h> 7 #include <windows.h>
8 #include <wincrypt.h> 8 #include <wincrypt.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SecureZeroMemory(key_blob->key_data, key_length); 149 SecureZeroMemory(key_blob->key_data, key_length);
150 150
151 return true; 151 return true;
152 } 152 }
153 153
154 HMAC::~HMAC() { 154 HMAC::~HMAC() {
155 } 155 }
156 156
157 bool HMAC::Sign(const std::string& data, 157 bool HMAC::Sign(const std::string& data,
158 unsigned char* digest, 158 unsigned char* digest,
159 int digest_length) { 159 int digest_length) const {
160 if (hash_alg_ == SHA256) { 160 if (hash_alg_ == SHA256) {
161 if (plat_->raw_key_.empty()) 161 if (plat_->raw_key_.empty())
162 return false; 162 return false;
163 ComputeHMACSHA256(&plat_->raw_key_[0], plat_->raw_key_.size(), 163 ComputeHMACSHA256(&plat_->raw_key_[0], plat_->raw_key_.size(),
164 reinterpret_cast<const unsigned char*>(data.data()), 164 reinterpret_cast<const unsigned char*>(data.data()),
165 data.size(), digest, digest_length); 165 data.size(), digest, digest_length);
166 return true; 166 return true;
167 } 167 }
168 168
169 if (!plat_->provider_ || !plat_->key_) 169 if (!plat_->provider_ || !plat_->key_)
(...skipping 18 matching lines...) Expand all
188 188
189 if (!CryptHashData(hash, reinterpret_cast<const BYTE*>(data.data()), 189 if (!CryptHashData(hash, reinterpret_cast<const BYTE*>(data.data()),
190 static_cast<DWORD>(data.size()), 0)) 190 static_cast<DWORD>(data.size()), 0))
191 return false; 191 return false;
192 192
193 DWORD sha1_size = digest_length; 193 DWORD sha1_size = digest_length;
194 return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0); 194 return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0);
195 } 195 }
196 196
197 } // namespace crypto 197 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/hmac_openssl.cc ('k') | crypto/symmetric_key_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698