Janis Danisevskis | 212c68b | 2021-01-14 22:29:28 -0800 | [diff] [blame] | 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 | #pragma once |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | #include <stddef.h> |
| 20 | |
| 21 | /** |
| 22 | * This is a redefinition of KEY_ATTESTATION_APPLICATION_ID_MAX_SIZE in |
| 23 | * system/security/keystore/keystore_attestation_id.h and must be kept in sync. |
| 24 | * There is a static assert in aaid.cpp to assure that they are in sync. |
| 25 | * We redefine this here to avoid unnecessary build dependencies for |
| 26 | * the rust bindgen target. |
| 27 | */ |
| 28 | constexpr const size_t KEY_ATTESTATION_APPLICATION_ID_MAX_SIZE = 1024; |
| 29 | |
| 30 | extern "C" { |
| 31 | /** |
| 32 | * Fills the buffer at aaid with the attestation application id of the app uid. |
| 33 | * The buffer must be exactly KEY_ATTESTATION_APPLICATION_ID_MAX_SIZE bytes in size. |
| 34 | * *aaid_size is set to the number of bytes written to aaid. |
| 35 | * |
| 36 | * @param uid the uid of the app to retrieve the aaid for. |
| 37 | * @param aaid output buffer for the attestation id. |
| 38 | * @param aaid_size must be set to the size of the output buffer, which must be exactly |
| 39 | * KEY_ATTESTATION_APPLICATION_ID_MAX_SIZE bytes in size, by the caller. On success |
| 40 | * it is set to the number of bytes written. |
| 41 | * @return OK on success. |
| 42 | */ |
| 43 | uint32_t aaid_keystore_attestation_id(uint32_t uid, uint8_t* aaid, size_t* aaid_size); |
| 44 | } |