blob: ddba80578cf8a4fd072ac54d8a6aeeee9e30fe1b [file] [log] [blame]
Robert Sesekb49a6bb2021-05-10 14:53:171// 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|.
17void CheckResourceIntegrity(
18 const base::FilePath& path,
19 const base::span<const uint8_t, crypto::kSHA256Length> expected_signature,
Etienne Bergeron2e351732021-07-01 01:06:3120 scoped_refptr<base::SequencedTaskRunner> task_runner,
Robert Sesekb49a6bb2021-05-10 14:53:1721 base::OnceCallback<void(bool)> callback);
22
Robert Sesekb49a6bb2021-05-10 14:53:1723// Checks the main Chrome .pak files for corruption by calling
24// CheckResourceIntegrity(), using hashes generated from the
25// GN target //chrome:packed_resources_integrity.
26void CheckPakFileIntegrity();
Robert Sesekb49a6bb2021-05-10 14:53:1727
28#endif // CHROME_BROWSER_RESOURCES_INTEGRITY_H_