blob: 2165fdd5ae9344fa2654367364526f413833a1de [file] [log] [blame]
Subrahmanyaman77acd432022-08-03 23:12:05 +00001/*
2 * Copyright (C) 2022 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
17package android.hardware.confirmationui;
18
19import android.hardware.confirmationui.IConfirmationUI;
20
21/**
22 * Callback interface passed to IConfirmationUI::promptUserConfirmation().
23 * Informs the caller about the result of the prompt operation.
24 */
25@VintfStability
26interface IConfirmationResultCallback {
27 /**
28 * This callback is called by the confirmation provider when it stops prompting the user.
29 * Iff the user has confirmed the prompted text, error is ErrorCode::OK and the
30 * parameters formattedMessage and confirmationToken hold the values needed to request
31 * a signature from keymaster.
32 * In all other cases formattedMessage and confirmationToken must be of length 0.
33 *
34 * @param error - OK: IFF the user has confirmed the prompt.
35 * - CANCELED: If the user has pressed the cancel button.
36 * - ABORTED: If IConfirmationUI::abort() was called.
37 * - SYSTEM_ERROR: If an unexpected System error occurred that prevented the TUI
38 * from being shut down gracefully.
39 *
40 * @param formattedMessage holds the prompt text and extra data.
41 * The message is CBOR (RFC 7049) encoded and has the following format:
42 * CBOR_MAP{ "prompt", <promptText>, "extra", <extraData> }
43 * The message is a CBOR encoded map (type 5) with the keys
44 * "prompt" and "extra". The keys are encoded as CBOR text string
45 * (type 3). The value <promptText> is encoded as CBOR text string
46 * (type 3), and the value <extraData> is encoded as CBOR byte string
47 * (type 2). The map must have exactly one key value pair for each of
48 * the keys "prompt" and "extra". Other keys are not allowed.
49 * The value of "prompt" is given by the proptText argument to
50 * IConfirmationUI::promptUserConfirmation and must not be modified
51 * by the implementation.
52 * The value of "extra" is given by the extraData argument to
53 * IConfirmationUI::promptUserConfirmation and must not be modified
54 * or interpreted by the implementation.
55 *
56 * @param confirmationToken a 32-byte HMAC-SHA256 value, computed over
57 * "confirmation token" || <formattedMessage>
58 * i.e. the literal UTF-8 encoded string "confirmation token", without
59 * the "", concatenated with the formatted message as returned in the
60 * formattedMessage argument. The HMAC is keyed with a 256-bit secret
61 * which is shared with Keymaster. In test mode the test key MUST be
62 * used (see types.hal TestModeCommands and
63 * IConfirmationUI::TEST_KEY_BYTE).
64 */
65 void result(in int error, in byte[] formattedMessage, in byte[] confirmationToken);
66}