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 <windows.h> | 9 #include <windows.h> |
10 #include <wintrust.h> | 10 #include <wintrust.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 = | 42 *public_key_hash = base::ToLowerASCII(base::HexEncode(hash, arraysize(hash))); |
43 base::StringToLowerASCII(base::HexEncode(hash, arraysize(hash))); | |
44 return true; | 43 return true; |
45 } | 44 } |
46 | 45 |
47 // The traits class for HCERTSTORE handles that can be closed via | 46 // The traits class for HCERTSTORE handles that can be closed via |
48 // CertCloseStore() API. | 47 // CertCloseStore() API. |
49 class CertStoreHandleTraits { | 48 class CertStoreHandleTraits { |
50 public: | 49 public: |
51 typedef HCERTSTORE Handle; | 50 typedef HCERTSTORE Handle; |
52 | 51 |
53 // Closes the handle. | 52 // Closes the handle. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // to make sure the cert is current. | 212 // to make sure the cert is current. |
214 std::vector<std::string>::const_iterator it = std::find( | 213 std::vector<std::string>::const_iterator it = std::find( |
215 expected_hashes.begin(), | 214 expected_hashes.begin(), |
216 expected_hashes.end(), | 215 expected_hashes.end(), |
217 cert_info.public_key_hash()); | 216 cert_info.public_key_hash()); |
218 if (it == expected_hashes.end() || !cert_info.IsValidNow()) | 217 if (it == expected_hashes.end() || !cert_info.IsValidNow()) |
219 return false; | 218 return false; |
220 | 219 |
221 return true; | 220 return true; |
222 } | 221 } |
OLD | NEW |