OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/app/signature_validator_win.h" | 5 #include "chrome/app/signature_validator_win.h" |
6 | 6 |
7 #include <atlstr.h> | 7 #include <atlstr.h> |
8 #include <softpub.h> | 8 #include <softpub.h> |
9 #include <wincrypt.h> | 9 #include <wincrypt.h> |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Key blobs that are not an integral number of bytes are unsupported. | 32 // Key blobs that are not an integral number of bytes are unsupported. |
33 if (crypt_blob.cUnusedBits != 0) | 33 if (crypt_blob.cUnusedBits != 0) |
34 return false; | 34 return false; |
35 | 35 |
36 uint8 hash[crypto::kSHA256Length] = {}; | 36 uint8 hash[crypto::kSHA256Length] = {}; |
37 | 37 |
38 base::StringPiece key_bytes(reinterpret_cast<char*>( | 38 base::StringPiece key_bytes(reinterpret_cast<char*>( |
39 crypt_blob.pbData), crypt_blob.cbData); | 39 crypt_blob.pbData), crypt_blob.cbData); |
40 crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length); | 40 crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length); |
41 | 41 |
42 *public_key_hash = StringToLowerASCII(base::HexEncode(hash, arraysize(hash))); | 42 *public_key_hash = |
| 43 base::StringToLowerASCII(base::HexEncode(hash, arraysize(hash))); |
43 return true; | 44 return true; |
44 } | 45 } |
45 | 46 |
46 // The traits class for HCERTSTORE handles that can be closed via | 47 // The traits class for HCERTSTORE handles that can be closed via |
47 // CertCloseStore() API. | 48 // CertCloseStore() API. |
48 class CertStoreHandleTraits { | 49 class CertStoreHandleTraits { |
49 public: | 50 public: |
50 typedef HCERTSTORE Handle; | 51 typedef HCERTSTORE Handle; |
51 | 52 |
52 // Closes the handle. | 53 // Closes the handle. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // to make sure the cert is current. | 213 // to make sure the cert is current. |
213 std::vector<std::string>::const_iterator it = std::find( | 214 std::vector<std::string>::const_iterator it = std::find( |
214 expected_hashes.begin(), | 215 expected_hashes.begin(), |
215 expected_hashes.end(), | 216 expected_hashes.end(), |
216 cert_info.public_key_hash()); | 217 cert_info.public_key_hash()); |
217 if (it == expected_hashes.end() || !cert_info.IsValidNow()) | 218 if (it == expected_hashes.end() || !cert_info.IsValidNow()) |
218 return false; | 219 return false; |
219 | 220 |
220 return true; | 221 return true; |
221 } | 222 } |
OLD | NEW |