1*e1997b9aSAndroid Build Coastguard Worker /* 2*e1997b9aSAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project 3*e1997b9aSAndroid Build Coastguard Worker * 4*e1997b9aSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*e1997b9aSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*e1997b9aSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*e1997b9aSAndroid Build Coastguard Worker * 8*e1997b9aSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*e1997b9aSAndroid Build Coastguard Worker * 10*e1997b9aSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*e1997b9aSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*e1997b9aSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*e1997b9aSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*e1997b9aSAndroid Build Coastguard Worker * limitations under the License. 15*e1997b9aSAndroid Build Coastguard Worker */ 16*e1997b9aSAndroid Build Coastguard Worker 17*e1997b9aSAndroid Build Coastguard Worker #pragma once 18*e1997b9aSAndroid Build Coastguard Worker 19*e1997b9aSAndroid Build Coastguard Worker #include <android-base/result.h> 20*e1997b9aSAndroid Build Coastguard Worker 21*e1997b9aSAndroid Build Coastguard Worker #include <map> 22*e1997b9aSAndroid Build Coastguard Worker #include <string> 23*e1997b9aSAndroid Build Coastguard Worker #include <vector> 24*e1997b9aSAndroid Build Coastguard Worker 25*e1997b9aSAndroid Build Coastguard Worker android::base::Result<std::vector<uint8_t>> createDigest(const std::string& path); 26*e1997b9aSAndroid Build Coastguard Worker android::base::Result<std::string> enableFsVerity(int fd); 27*e1997b9aSAndroid Build Coastguard Worker bool SupportsFsVerity(); 28*e1997b9aSAndroid Build Coastguard Worker android::base::Result<std::map<std::string, std::string>> 29*e1997b9aSAndroid Build Coastguard Worker verifyAllFilesInVerity(const std::string& path); 30*e1997b9aSAndroid Build Coastguard Worker 31*e1997b9aSAndroid Build Coastguard Worker // Note that this function will skip files that are already in fs-verity, and 32*e1997b9aSAndroid Build Coastguard Worker // for those files it will return the existing digest. 33*e1997b9aSAndroid Build Coastguard Worker android::base::Result<std::map<std::string, std::string>> 34*e1997b9aSAndroid Build Coastguard Worker addFilesToVerityRecursive(const std::string& path); 35*e1997b9aSAndroid Build Coastguard Worker 36*e1997b9aSAndroid Build Coastguard Worker // Enable verity on the provided file. 37*e1997b9aSAndroid Build Coastguard Worker android::base::Result<void> enableFsVerity(const std::string& path); 38*e1997b9aSAndroid Build Coastguard Worker 39*e1997b9aSAndroid Build Coastguard Worker android::base::Result<void> 40*e1997b9aSAndroid Build Coastguard Worker verifyAllFilesUsingCompOs(const std::string& directory_path, 41*e1997b9aSAndroid Build Coastguard Worker const std::map<std::string, std::string>& digests); 42