| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |