1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 
21 #include <fs_avb/types.h>
22 #include <fstab/fstab.h>
23 #include <libavb/libavb.h>
24 
25 namespace android {
26 namespace fs_mgr {
27 
28 // Given a FstabEntry, loads and verifies the vbmeta.
29 std::unique_ptr<VBMetaData> LoadAndVerifyVbmeta(const FstabEntry& fstab_entry,
30                                                 const std::string& expected_public_key_blob,
31                                                 std::string* out_public_key_data,
32                                                 std::string* out_avb_partition_name,
33                                                 VBMetaVerifyResult* out_verify_result);
34 
35 // Loads the single vbmeta from a given path.
36 std::unique_ptr<VBMetaData> LoadAndVerifyVbmetaByPath(
37         const std::string& image_path, const std::string& partition_name,
38         const std::string& expected_public_key_blob, bool allow_verification_error,
39         bool rollback_protection, bool is_chained_vbmeta, std::string* out_public_key_data,
40         bool* out_verification_disabled, VBMetaVerifyResult* out_verify_result);
41 
42 // Gets the hashtree descriptor for avb_partition_name from the vbmeta.
43 std::unique_ptr<FsAvbHashtreeDescriptor> GetHashtreeDescriptor(
44         const std::string& avb_partition_name, VBMetaData&& vbmeta);
45 
46 // Gets the hash descriptor for avb_partition_name from the vbmeta.
47 std::unique_ptr<FsAvbHashDescriptor> GetHashDescriptor(const std::string& avb_partition_name,
48                                                        VBMetaData&& vbmeta);
49 
50 }  // namespace fs_mgr
51 }  // namespace android
52