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 <windows.h> | 5 #include <windows.h> |
6 #include <atlstr.h> | 6 #include <atlstr.h> |
7 #include <wintrust.h> | 7 #include <wintrust.h> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 size_t public_key_length = blob.cbData; | 78 size_t public_key_length = blob.cbData; |
79 uint8* public_key = blob.pbData; | 79 uint8* public_key = blob.pbData; |
80 | 80 |
81 uint8 hash[crypto::kSHA256Length] = {0}; | 81 uint8 hash[crypto::kSHA256Length] = {0}; |
82 | 82 |
83 base::StringPiece key_bytes(reinterpret_cast<char*>(public_key), | 83 base::StringPiece key_bytes(reinterpret_cast<char*>(public_key), |
84 public_key_length); | 84 public_key_length); |
85 crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length); | 85 crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length); |
86 | 86 |
87 std::string public_key_hash = | 87 std::string public_key_hash = |
88 base::StringToLowerASCII(base::HexEncode(hash, arraysize(hash))); | 88 base::ToLowerASCII(base::HexEncode(hash, arraysize(hash))); |
89 expected_hashes_.push_back(public_key_hash); | 89 expected_hashes_.push_back(public_key_hash); |
90 } | 90 } |
91 | 91 |
92 void RunTest(const wchar_t* dll_filename, bool isValid, bool isGoogle) { | 92 void RunTest(const wchar_t* dll_filename, bool isValid, bool isGoogle) { |
93 base::FilePath full_dll_path = GetTestDLLsDirectory().Append(dll_filename); | 93 base::FilePath full_dll_path = GetTestDLLsDirectory().Append(dll_filename); |
94 ASSERT_EQ(isValid, VerifyAuthenticodeSignature(full_dll_path)); | 94 ASSERT_EQ(isValid, VerifyAuthenticodeSignature(full_dll_path)); |
95 ASSERT_EQ(isGoogle, VerifySignerIsGoogle(full_dll_path, kGoogleCertIssuer, | 95 ASSERT_EQ(isGoogle, VerifySignerIsGoogle(full_dll_path, kGoogleCertIssuer, |
96 expected_hashes_)); | 96 expected_hashes_)); |
97 } | 97 } |
98 | 98 |
(...skipping 23 matching lines...) Expand all Loading... |
122 TEST_F(SignatureValidatorTest, CertPinningTest) { | 122 TEST_F(SignatureValidatorTest, CertPinningTest) { |
123 RunTest(L"different_hash.dll", true, false); | 123 RunTest(L"different_hash.dll", true, false); |
124 } | 124 } |
125 | 125 |
126 TEST_F(SignatureValidatorTest, ExpiredCertTest) { | 126 TEST_F(SignatureValidatorTest, ExpiredCertTest) { |
127 //TODO(caitkp): Figure out how to sign a dll with an expired cert. | 127 //TODO(caitkp): Figure out how to sign a dll with an expired cert. |
128 RunTest(L"expired.dll", false, false); | 128 RunTest(L"expired.dll", false, false); |
129 } | 129 } |
130 | 130 |
131 | 131 |
OLD | NEW |