Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 075d928e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I22ca138e,I1d93a855,I72017b39

* changes:
  ConfirmationUI reference implementation
  Add confirmation UI support libaray
  ConfirmationUI HAL definition
parents b3aa121d a0c33ea1
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
    name: "android.hardware.confirmationui@1.0",
    root: "android.hardware",
    vndk: {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IConfirmationResultCallback.hal",
        "IConfirmationUI.hal",
    ],
    interfaces: [
        "android.hardware.keymaster@4.0",
        "android.hidl.base@1.0",
    ],
    types: [
        "MessageSize",
        "ResponseCode",
        "TestKeyBits",
        "TestModeCommands",
        "UIOption",
    ],
    gen_java: false,
}
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.confirmationui@1.0;

/**
 * Callback interface passed to IConfirmationUI::promptUserConfirmation().
 * Informs the caller about the result of the prompt operation.
 */
interface IConfirmationResultCallback {
    /**
     * This callback is called by the confirmation provider when it stops prompting the user.
     * Iff the user has confirmed the prompted text, error is ErrorCode::OK and the
     * parameters formattedMessage and confirmationToken hold the values needed to request
     * a signature from keymaster.
     * In all other cases formattedMessage and confirmationToken must be of length 0.
     *
     * @param error - OK: IFF the user has confirmed the prompt.
     *              - Canceled: If the user has pressed the cancel button.
     *              - Aborted: If IConfirmationUI::abort() was called.
     *              - SystemError: If an unexpected System error occurred that prevented the TUI
     *                             from being shut down gracefully.
     * @param formattedMessage holds the prompt text and extra data.
     *                         The message is CBOR (RFC 7049) encoded and has the following format:
     *                         CBOR_MAP{ "prompt", <promptText>, "extra", <extraData> }
     *                         The message is a CBOR encoded map (type 5) with the keys
     *                         "prompt" and "extra". The keys are encoded as CBOR text string
     *                         (type 3). The value <promptText> is encoded as CBOR text string
     *                         (type 3), and the value <extraData> is encoded as CBOR byte string
     *                         (type 2). The map must have exactly one key value pair for each of
     *                         the keys "prompt" and "extra". Other keys are not allowed.
     *                         The value of "prompt" is given by the proptText argument to
     *                         IConfirmationUI::promptUserConfirmation and must not be modified
     *                         by the implementation.
     *                         The value of "extra" is given by the extraData argument to
     *                         IConfirmationUI::promptUserConfirmation and must not be modified
     *                         or interpreted by the implementation.
     *
     * @param confirmationToken a 32-byte HMAC-SHA256 value, computed over
     *                          "confirmation token" || <formattedMessage>
     *                          i.e. the literal UTF-8 encoded string "confirmation token", without
     *                          the "", concatenated with the formatted message as returned in the
     *                          formattedMessage argument. The HMAC is keyed with a 256-bit secret
     *                          which is shared with Keymaster. In test mode the test key MUST be
     *                          used (see types.hal TestModeCommands and TestKeyBits).
     */
    result(ResponseCode error, vec<uint8_t> formattedMessage, vec<uint8_t> confirmationToken);
};
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.confirmationui@1.0;

import android.hardware.keymaster@4.0::HardwareAuthToken;
import IConfirmationResultCallback;

interface IConfirmationUI {
    /**
     * Asynchronously initiates a confirmation UI dialog prompting the user to confirm a given text.
     * The TUI prompt must be implemented in such a way that a positive response indicates with
     * high confidence that a user has seen the given prompt text even if the Android framework
     * including the kernel was compromised.
     *
     * @param resultCB Implementation of IResultCallback. Used by the implementation to report
     *                 the result of the current pending user prompt.
     *
     * @param promptText UTF-8 encoded string which is to be presented to the user.
     *
     * @param extraData A binary blob that must be included in the formatted output message as is.
     *                  It is opaque to the implementation. Implementations must neither interpret
     *                  nor modify the content.
     *
     * @param locale String specifying the locale that must be used by the TUI dialog. The string
     *                      is an IETF BCP 47 tag.
     *
     * @param uiOptions A set of uiOptions manipulating how the confirmation prompt is displayed.
     *                  Refer to UIOption in types.hal for possible options.
     *
     * @return error  - OK: IFF the dialog was successfully started. In this case, and only in this
     *                      case, the implementation must, eventually, call the callback to
     *                      indicate completion.
     *                - OperationPending: Is returned when the confirmation provider is currently
     *                      in use.
     *                - SystemError: An error occurred trying to communicate with the confirmation
     *                      provider (e.g. trusted app).
     *                - UIError: The confirmation provider encountered an issue with displaying
     *                      the prompt text to the user.
     */
    promptUserConfirmation(IConfirmationResultCallback resultCB, string promptText,
                           vec<uint8_t> extraData, string locale, vec<UIOption> uiOptions)
        generates(ResponseCode error);

    /**
     * DeliverSecureInput is used by the framework to deliver a secure input event to the
     * confirmation provider.
     *
     * VTS test mode:
     * This function can be used to test certain code paths non-interactively. See TestModeCommands
     * in types.hal for details.
     *
     * @param secureInputToken An authentication token as generated by Android authentication
     *                         providers.
     *
     * @return error - Ignored: Unless used for testing (See TestModeCommands).
     */
    deliverSecureInputEvent(HardwareAuthToken secureInputToken)
        generates(ResponseCode error);

    /**
     * Aborts a pending user prompt. This allows the framework to gracefully end a TUI dialog.
     * If a TUI operation was pending the corresponding call back is informed with
     * ErrorCode::Aborted.
     */
    abort();
};
+43 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_binary {
    name: "android.hardware.confirmationui@1.0-service",
    init_rc: ["android.hardware.confirmationui@1.0-service.rc"],
    vendor: true,
    relative_install_path: "hw",
    cflags: [
        "-Wall",
        "-Wextra",
        "-Werror",
    ],
    srcs: [
        "service.cpp",
        "ConfirmationUI.cpp",
        "PlatformSpecifics.cpp",
    ],
    shared_libs: [
        "android.hardware.confirmationui@1.0",
        "android.hardware.confirmationui-support-lib",
        "android.hardware.keymaster@4.0",
        "libcrypto",
        "libbase",
        "libhidlbase",
        "libhidltransport",
        "liblog",
        "libutils",
    ],
}
 No newline at end of file
+66 −0
Original line number Diff line number Diff line
/*
**
** Copyright 2017, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#include "ConfirmationUI.h"

#include "PlatformSpecifics.h"

#include <android/hardware/confirmationui/support/cbor.h>
#include <android/hardware/confirmationui/support/confirmationui_utils.h>

#include <android/hardware/confirmationui/1.0/generic/GenericOperation.h>

#include <time.h>

namespace android {
namespace hardware {
namespace confirmationui {
namespace V1_0 {
namespace implementation {

using ::android::hardware::confirmationui::V1_0::generic::Operation;
using ::android::hardware::keymaster::V4_0::HardwareAuthToken;

uint8_t hmacKey[32];

// Methods from ::android::hardware::confirmationui::V1_0::IConfirmationUI follow.
Return<ResponseCode> ConfirmationUI::promptUserConfirmation(
    const sp<IConfirmationResultCallback>& resultCB, const hidl_string& promptText,
    const hidl_vec<uint8_t>& extraData, const hidl_string& locale,
    const hidl_vec<UIOption>& uiOptions) {
    auto& operation = MyOperation::get();
    return operation.init(resultCB, promptText, extraData, locale, uiOptions);
}

Return<ResponseCode> ConfirmationUI::deliverSecureInputEvent(
    const HardwareAuthToken& secureInputToken) {
    auto& operation = MyOperation::get();
    return operation.deliverSecureInputEvent(secureInputToken);
}

Return<void> ConfirmationUI::abort() {
    auto& operation = MyOperation::get();
    operation.abort();
    operation.finalize(hmacKey);
    return Void();
}

}  // namespace implementation
}  // namespace V1_0
}  // namespace confirmationui
}  // namespace hardware
}  // namespace android
Loading