xref: /aosp_15_r20/hardware/interfaces/weaver/1.0/IWeaver.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
17*4d7e907cSAndroid Build Coastguard Worker
18*4d7e907cSAndroid Build Coastguard Worker/**
19*4d7e907cSAndroid Build Coastguard Worker * Weaver provides secure storage of secret values that may only be read if the
20*4d7e907cSAndroid Build Coastguard Worker * corresponding key has been presented.
21*4d7e907cSAndroid Build Coastguard Worker *
22*4d7e907cSAndroid Build Coastguard Worker * The storage must be secure as the device's user authentication and encryption
23*4d7e907cSAndroid Build Coastguard Worker * relies on the security of these values. The cardinality of the domains of the
24*4d7e907cSAndroid Build Coastguard Worker * key and value must be suitably large such that they cannot be easily guessed.
25*4d7e907cSAndroid Build Coastguard Worker *
26*4d7e907cSAndroid Build Coastguard Worker * Weaver is structured as an array of slots, each containing a key-value pair.
27*4d7e907cSAndroid Build Coastguard Worker * Slots are uniquely identified by an ID in the range [0, `getConfig().slots`).
28*4d7e907cSAndroid Build Coastguard Worker */
29*4d7e907cSAndroid Build Coastguard Workerinterface IWeaver {
30*4d7e907cSAndroid Build Coastguard Worker    /**
31*4d7e907cSAndroid Build Coastguard Worker     * Retrieves the config information for this implementation of Weaver.
32*4d7e907cSAndroid Build Coastguard Worker     *
33*4d7e907cSAndroid Build Coastguard Worker     * The config is static i.e. every invocation returns the same information.
34*4d7e907cSAndroid Build Coastguard Worker     *
35*4d7e907cSAndroid Build Coastguard Worker     * @return status is OK if the config was successfuly obtained.
36*4d7e907cSAndroid Build Coastguard Worker     * @return config data for this implementation of Weaver if status is OK,
37*4d7e907cSAndroid Build Coastguard Worker     *         otherwise undefined.
38*4d7e907cSAndroid Build Coastguard Worker     */
39*4d7e907cSAndroid Build Coastguard Worker    getConfig() generates (WeaverStatus status, WeaverConfig config);
40*4d7e907cSAndroid Build Coastguard Worker
41*4d7e907cSAndroid Build Coastguard Worker    /**
42*4d7e907cSAndroid Build Coastguard Worker     * Overwrites the identified slot with the provided key and value.
43*4d7e907cSAndroid Build Coastguard Worker     *
44*4d7e907cSAndroid Build Coastguard Worker     * The new values are written regardless of the current state of the slot in
45*4d7e907cSAndroid Build Coastguard Worker     * order to remain idempotent.
46*4d7e907cSAndroid Build Coastguard Worker     *
47*4d7e907cSAndroid Build Coastguard Worker     * @param slotId of the slot to write to.
48*4d7e907cSAndroid Build Coastguard Worker     * @param key to write to the slot.
49*4d7e907cSAndroid Build Coastguard Worker     * @param value to write to slot.
50*4d7e907cSAndroid Build Coastguard Worker     * @return status is OK if the write was successfully completed.
51*4d7e907cSAndroid Build Coastguard Worker     */
52*4d7e907cSAndroid Build Coastguard Worker    write(uint32_t slotId, vec<uint8_t> key, vec<uint8_t> value)
53*4d7e907cSAndroid Build Coastguard Worker                generates (WeaverStatus status);
54*4d7e907cSAndroid Build Coastguard Worker
55*4d7e907cSAndroid Build Coastguard Worker    /**
56*4d7e907cSAndroid Build Coastguard Worker     * Attempts to retrieve the value stored in the identified slot.
57*4d7e907cSAndroid Build Coastguard Worker     *
58*4d7e907cSAndroid Build Coastguard Worker     * The value is only returned if the provided key matches the key stored in
59*4d7e907cSAndroid Build Coastguard Worker     * the slot. The value is never returned if the wrong key is provided.
60*4d7e907cSAndroid Build Coastguard Worker     *
61*4d7e907cSAndroid Build Coastguard Worker     * Throttling must be used to limit the frequency of failed read attempts.
62*4d7e907cSAndroid Build Coastguard Worker     * The value is only returned when throttling is not active, even if the
63*4d7e907cSAndroid Build Coastguard Worker     * correct key is provided. If called when throttling is active, the time
64*4d7e907cSAndroid Build Coastguard Worker     * until the next attempt can be made is returned.
65*4d7e907cSAndroid Build Coastguard Worker     *
66*4d7e907cSAndroid Build Coastguard Worker     * @param slotId of the slot to read from.
67*4d7e907cSAndroid Build Coastguard Worker     * @param key that is stored in the slot.
68*4d7e907cSAndroid Build Coastguard Worker     * @return status is OK if the value was successfully read, INCORRECT_KEY if
69*4d7e907cSAndroid Build Coastguard Worker     *         the key does not match the key in the slot, THROTTLE if
70*4d7e907cSAndroid Build Coastguard Worker     *         throttling is active or FAILED if the read was unsuccessful for
71*4d7e907cSAndroid Build Coastguard Worker     *         another reason.
72*4d7e907cSAndroid Build Coastguard Worker     * @return readResponse contains the value read and the timeout to wait
73*4d7e907cSAndroid Build Coastguard Worker     *         before making the next request. If the status is OK, value is set
74*4d7e907cSAndroid Build Coastguard Worker     *         to the value in the slot and timeout is 0. Otherwise, value is
75*4d7e907cSAndroid Build Coastguard Worker     *         empty and timeout is set accordingly.
76*4d7e907cSAndroid Build Coastguard Worker     */
77*4d7e907cSAndroid Build Coastguard Worker    read(uint32_t slotId, vec<uint8_t> key)
78*4d7e907cSAndroid Build Coastguard Worker                generates (WeaverReadStatus status,
79*4d7e907cSAndroid Build Coastguard Worker                           WeaverReadResponse readResponse);
80*4d7e907cSAndroid Build Coastguard Worker};
81