| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> | |
| 9 | 8 |
| 10 #include <algorithm> | 9 #include <algorithm> |
| 11 #include <vector> | 10 #include <vector> |
| 12 | 11 |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 14 #include "crypto/scoped_capi_types.h" | 13 #include "crypto/scoped_capi_types.h" |
| 15 #include "crypto/third_party/nss/chromium-blapi.h" | 14 #include "crypto/third_party/nss/chromium-blapi.h" |
| 16 #include "crypto/third_party/nss/chromium-sha256.h" | 15 #include "crypto/third_party/nss/chromium-sha256.h" |
| 16 #include "crypto/wincrypt_shim.h" |
| 17 | 17 |
| 18 namespace crypto { | 18 namespace crypto { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Implementation of HMAC-SHA-256: | 22 // Implementation of HMAC-SHA-256: |
| 23 // | 23 // |
| 24 // SHA-256 is supported in Windows XP SP3 or later. We still need to support | 24 // SHA-256 is supported in Windows XP SP3 or later. We still need to support |
| 25 // Windows XP SP2, so unfortunately we have to implement HMAC-SHA-256 here. | 25 // Windows XP SP2, so unfortunately we have to implement HMAC-SHA-256 here. |
| 26 | 26 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 200 |
| 201 if (!CryptHashData(hash, reinterpret_cast<const BYTE*>(data.data()), | 201 if (!CryptHashData(hash, reinterpret_cast<const BYTE*>(data.data()), |
| 202 static_cast<DWORD>(data.size()), 0)) | 202 static_cast<DWORD>(data.size()), 0)) |
| 203 return false; | 203 return false; |
| 204 | 204 |
| 205 DWORD sha1_size = static_cast<DWORD>(digest_length); | 205 DWORD sha1_size = static_cast<DWORD>(digest_length); |
| 206 return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0); | 206 return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace crypto | 209 } // namespace crypto |
| OLD | NEW |