OLD | NEW |
1 // Copyright (c) 2011 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 // Simple tool that uses the SignatureUtil class to extract signature | 5 // Simple tool that uses the SignatureUtil class to extract signature |
6 // information from an executable. The output is an encoded | 6 // information from an executable. The output is an encoded |
7 // ClientDownloadRequest_SignatureInfo protocol buffer. | 7 // ClientDownloadRequest_SignatureInfo protocol buffer. |
8 // | 8 // |
9 // Example usage: sb_sigutil --executable=blah.exe --output=siginfo.pb | 9 // Example usage: sb_sigutil --executable=blah.exe --output=siginfo.pb |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 return 1; | 37 return 1; |
38 } | 38 } |
39 | 39 |
40 scoped_refptr<safe_browsing::SignatureUtil> sig_util( | 40 scoped_refptr<safe_browsing::SignatureUtil> sig_util( |
41 new safe_browsing::SignatureUtil()); | 41 new safe_browsing::SignatureUtil()); |
42 safe_browsing::ClientDownloadRequest_SignatureInfo signature_info; | 42 safe_browsing::ClientDownloadRequest_SignatureInfo signature_info; |
43 sig_util->CheckSignature(cmd_line->GetSwitchValuePath(kExecutable), | 43 sig_util->CheckSignature(cmd_line->GetSwitchValuePath(kExecutable), |
44 &signature_info); | 44 &signature_info); |
45 | 45 |
46 std::string serialized_info = signature_info.SerializeAsString(); | 46 std::string serialized_info = signature_info.SerializeAsString(); |
47 int bytes_written = file_util::WriteFile( | 47 int bytes_written = base::WriteFile( |
48 cmd_line->GetSwitchValuePath(kOutputFile), | 48 cmd_line->GetSwitchValuePath(kOutputFile), |
49 serialized_info.data(), | 49 serialized_info.data(), |
50 serialized_info.size()); | 50 serialized_info.size()); |
51 if (bytes_written != static_cast<int>(serialized_info.size())) { | 51 if (bytes_written != static_cast<int>(serialized_info.size())) { |
52 LOG(ERROR) << "Error writing output file"; | 52 LOG(ERROR) << "Error writing output file"; |
53 return 1; | 53 return 1; |
54 } | 54 } |
55 | 55 |
56 return 0; | 56 return 0; |
57 } | 57 } |
OLD | NEW |