1 /* 2 * Copyright (C) 2024 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 <android-base/result.h> 20 21 #include <string> 22 23 #include "apex_constants.h" 24 #include "apex_file.h" 25 26 namespace android::apex { 27 28 // Verifies a specific brand-new package against the 29 // pre-installed public keys and blocklists. The housing partition of the public 30 // key and blocklist is returned if the verification succeeds. Verifies a 31 // brand-new APEX in that 32 // 1. brand-new APEX is enabled 33 // 2. it matches exactly one certificate in one of the built-in partitions 34 // 3. its name and version are not blocked by the blocklist in the matching 35 // partition 36 // 37 // The function is called in 38 // |SubmitStagedSession| (brand-new apex becomes 'staged') 39 // |ScanStagedSessionsDirAndStage| ('staged' apex becomes 'active') 40 // |ApexFileRepository::AddDataApex| (add 'active' apex to repository) 41 android::base::Result<ApexPartition> VerifyBrandNewPackageAgainstPreinstalled( 42 const ApexFile& apex); 43 44 // Returns the verification result of a specific brand-new package. 45 // Verifies a brand-new APEX in that its public key is the same as the existing 46 // active version if any. Pre-installed APEX is skipped. 47 // 48 // The function is called in 49 // |SubmitStagedSession| (brand-new apex becomes 'staged') 50 android::base::Result<void> VerifyBrandNewPackageAgainstActive( 51 const ApexFile& apex); 52 53 } // namespace android::apex 54