Robert Sesek | b49a6bb | 2021-05-10 14:53:17 | [diff] [blame] | 1 | // Copyright 2021 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_BROWSER_RESOURCES_INTEGRITY_H_ |
| 6 | #define CHROME_BROWSER_RESOURCES_INTEGRITY_H_ |
| 7 | |
| 8 | #include "base/callback.h" |
| 9 | #include "base/containers/span.h" |
| 10 | #include "base/files/file_path.h" |
| 11 | #include "chrome/browser/buildflags.h" |
| 12 | #include "crypto/sha2.h" |
| 13 | |
| 14 | // Computes a SHA-256 hash of the contents of file at |path| and compares it |
| 15 | // to the specified |expected_signature|. If no errors occur and the signatures |
| 16 | // match, runs |callback| with |true|; otherwise runs it with |false|. |
| 17 | void CheckResourceIntegrity( |
| 18 | const base::FilePath& path, |
| 19 | const base::span<const uint8_t, crypto::kSHA256Length> expected_signature, |
Etienne Bergeron | 2e35173 | 2021-07-01 01:06:31 | [diff] [blame] | 20 | scoped_refptr<base::SequencedTaskRunner> task_runner, |
Robert Sesek | b49a6bb | 2021-05-10 14:53:17 | [diff] [blame] | 21 | base::OnceCallback<void(bool)> callback); |
| 22 | |
Robert Sesek | b49a6bb | 2021-05-10 14:53:17 | [diff] [blame] | 23 | // Checks the main Chrome .pak files for corruption by calling |
| 24 | // CheckResourceIntegrity(), using hashes generated from the |
| 25 | // GN target //chrome:packed_resources_integrity. |
| 26 | void CheckPakFileIntegrity(); |
Robert Sesek | b49a6bb | 2021-05-10 14:53:17 | [diff] [blame] | 27 | |
| 28 | #endif // CHROME_BROWSER_RESOURCES_INTEGRITY_H_ |