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

Side by Side Diff: base/hmac_win.cc

Issue 4273: Fix some issues found looking at the code. I have made two posts about it:... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 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 | « base/hmac_nss.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 7 #include <windows.h>
8 #include <wincrypt.h> 8 #include <wincrypt.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 SecureZeroMemory(key_blob->key_data, key_length); 60 SecureZeroMemory(key_blob->key_data, key_length);
61 } 61 }
62 62
63 HMAC::~HMAC() { 63 HMAC::~HMAC() {
64 if (plat_->hkey_) 64 if (plat_->hkey_)
65 CryptDestroyKey(plat_->hkey_); 65 CryptDestroyKey(plat_->hkey_);
66 if (plat_->hash_) 66 if (plat_->hash_)
67 CryptDestroyHash(plat_->hash_); 67 CryptDestroyHash(plat_->hash_);
68 if (plat_->provider_) 68 if (plat_->provider_)
69 CryptReleaseContext(plat_->provider_, 0); 69 CryptReleaseContext(plat_->provider_, 0);
70
71 delete plat_;
72 } 70 }
73 71
74 bool HMAC::Sign(const std::string& data, 72 bool HMAC::Sign(const std::string& data,
75 unsigned char* digest, 73 unsigned char* digest,
76 int digest_length) { 74 int digest_length) {
77 if (!plat_->provider_ || !plat_->hkey_) 75 if (!plat_->provider_ || !plat_->hkey_)
78 return false; 76 return false;
79 77
80 if (hash_alg_ != SHA1) { 78 if (hash_alg_ != SHA1) {
81 NOTREACHED(); 79 NOTREACHED();
(...skipping 17 matching lines...) Expand all
99 return false; 97 return false;
100 98
101 DWORD sha1_size = digest_length; 99 DWORD sha1_size = digest_length;
102 if (!CryptGetHashParam(plat_->hash_, HP_HASHVAL, digest, &sha1_size, 0)) 100 if (!CryptGetHashParam(plat_->hash_, HP_HASHVAL, digest, &sha1_size, 0))
103 return false; 101 return false;
104 102
105 return true; 103 return true;
106 } 104 }
107 105
108 } // namespace base 106 } // namespace base
OLDNEW
« no previous file with comments | « base/hmac_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698