1 /* 2 * Copyright (C) 2020 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 #ifndef CHRE_PLATFORM_SHARED_AUTHENTICATION_H_ 18 #define CHRE_PLATFORM_SHARED_AUTHENTICATION_H_ 19 20 #include <cstddef> 21 22 namespace chre { 23 24 /** 25 * Authenticates the signature of the provided binary. If not provided 26 * elsewhere by the platform, this method must ensure that nanoapps are signed 27 * appropriately and no corruption has occurred to the binary prior to being 28 * loaded. If this method succeeds, CHRE will assume the binary has the same 29 * execution privileges as the core framework itself. 30 * 31 * @param binary Pointer to the binary that should be authenticated. 32 * @param appBinaryLen The length of the binary. 33 * @param realBinaryStart A non-null pointer that, if this method succeeds, must 34 * be filled with the starting address of the raw binary after any headers 35 * used by the authentication code. This will be passed to the dynamic 36 * loader which will assume the starting address is a valid ELF binary. 37 * @return True if the binary passed authentication. 38 */ 39 bool authenticateBinary(const void *binary, size_t appBinaryLen, 40 void **realBinaryStart); 41 42 } // namespace chre 43 44 #endif // CHRE_PLATFORM_SHARED_AUTHENTICATION_H_ 45