OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_COMMON_SAFE_BROWSING_SIGNATURE_EVALUATOR_MAC_H_ | |
6 #define CHROME_COMMON_SAFE_BROWSING_SIGNATURE_EVALUATOR_MAC_H_ | |
7 | |
8 #include <Security/Security.h> | |
9 | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/files/file_path.h" | |
14 #include "base/mac/scoped_cftyperef.h" | |
15 #include "base/memory/ref_counted.h" | |
16 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h" | |
17 | |
18 #if !defined(__OBJC__) | |
19 using id = void*; | |
20 #endif | |
21 | |
22 namespace safe_browsing { | |
23 | |
24 // Wraps the OS X SecStaticCode API, to evaluate a given file object | |
25 // with a given code requirement, and produce a list of incident reports | |
26 // for files that fail code signature validity checks. | |
27 class MacSignatureEvaluator { | |
28 public: | |
29 explicit MacSignatureEvaluator(const base::FilePath& signed_object_path); | |
30 | |
31 // The requirement string must be a valid "Code Signing Requirement Language" | |
32 // string, which describes the identity of the signer. | |
33 MacSignatureEvaluator(const base::FilePath& signed_object_path, | |
34 const std::string& requirement); | |
35 | |
36 ~MacSignatureEvaluator(); | |
37 | |
38 // Creates the static code object and requirement string, and returns | |
39 // true if the object creation succeeds, else false. | |
40 bool Initialize(); | |
41 | |
42 // Evaluate the signature and return a list of any binary integrity incident | |
43 // reports. Returns true if and only if the signed code object is valid. | |
44 bool PerformEvaluation( | |
45 std::vector<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>& | |
Robert Sesek
2015/10/08 19:20:06
Non-constant references are forbidden by the style
Greg K
2015/10/09 17:12:01
Done.
| |
46 results); | |
47 | |
48 private: | |
49 // Process the NSError information about any files that were altered. | |
50 void ReportAlteredFiles( | |
51 id detail, | |
52 int32_t err_code, | |
53 std::vector<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>& | |
54 results); | |
55 | |
56 // The path to the code object on disk. | |
57 base::FilePath path_; | |
58 | |
59 // A Code Signing Requirement string. | |
60 std::string requirement_str_; | |
61 | |
62 // Records whether or not a requirement string was specified. | |
63 bool has_requirement_; | |
64 | |
65 // The static code object constructed from the code object on disk. | |
66 base::ScopedCFTypeRef<SecStaticCodeRef> code_; | |
67 | |
68 // The requirement object constructed from the requirement string. | |
69 base::ScopedCFTypeRef<SecRequirementRef> requirement_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(MacSignatureEvaluator); | |
72 }; | |
73 | |
74 } // namespace safe_browsing | |
75 | |
76 #endif // CHROME_COMMON_SAFE_BROWSING_SIGNATURE_EVALUATOR_MAC_H_ | |
OLD | NEW |