OLD | NEW |
1 // Copyright (c) 2010 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 "base/sha1.h" | 5 #include "base/sha1.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <wincrypt.h> | 8 #include <wincrypt.h> |
9 | 9 |
10 #include "base/crypto/scoped_capi_types.h" | 10 // This file is not being compiled at the moment (see bug 47218). If we keep |
| 11 // sha1 inside base, we cannot depend on src/crypto. |
| 12 // #include "crypto/scoped_capi_types.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 | 16 |
15 std::string SHA1HashString(const std::string& str) { | 17 std::string SHA1HashString(const std::string& str) { |
16 ScopedHCRYPTPROV provider; | 18 ScopedHCRYPTPROV provider; |
17 if (!CryptAcquireContext(provider.receive(), NULL, NULL, PROV_RSA_FULL, | 19 if (!CryptAcquireContext(provider.receive(), NULL, NULL, PROV_RSA_FULL, |
18 CRYPT_VERIFYCONTEXT)) { | 20 CRYPT_VERIFYCONTEXT)) { |
19 LOG(ERROR) << "CryptAcquireContext failed: " << GetLastError(); | 21 LOG(ERROR) << "CryptAcquireContext failed: " << GetLastError(); |
20 return std::string(SHA1_LENGTH, '\0'); | 22 return std::string(SHA1_LENGTH, '\0'); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 LOG(ERROR) << "Returned hash value is wrong length: " << hash_len | 58 LOG(ERROR) << "Returned hash value is wrong length: " << hash_len |
57 << " should be " << SHA1_LENGTH; | 59 << " should be " << SHA1_LENGTH; |
58 return std::string(SHA1_LENGTH, '\0'); | 60 return std::string(SHA1_LENGTH, '\0'); |
59 } | 61 } |
60 | 62 |
61 return result; | 63 return result; |
62 } | 64 } |
63 } | 65 } |
64 | 66 |
65 } // namespace base | 67 } // namespace base |
OLD | NEW |