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