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

Commit 9abd32b6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "The implementation of vts and default implementation to support...

Merge "The implementation of vts and default implementation to support ISecureClock and ISharedSecret AIDLs. Test: atest VtsAidlSecureClockTargetTest, atest VtsAidlSharedSecretTargetTest Bug: b/175136979, b/175141176" am: 9717a37b

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1562810

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0424942af64d493e556df6d8ffc93375123a0ff3
parents fb669b9e 9717a37b
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -2,7 +2,11 @@ cc_binary {
    name: "android.hardware.security.keymint-service",
    name: "android.hardware.security.keymint-service",
    relative_install_path: "hw",
    relative_install_path: "hw",
    init_rc: ["android.hardware.security.keymint-service.rc"],
    init_rc: ["android.hardware.security.keymint-service.rc"],
    vintf_fragments: ["android.hardware.security.keymint-service.xml"],
    vintf_fragments: [
        "android.hardware.security.keymint-service.xml",
        "android.hardware.security.sharedsecret-service.xml",
        "android.hardware.security.secureclock-service.xml",
    ],
    vendor: true,
    vendor: true,
    cflags: [
    cflags: [
        "-Wall",
        "-Wall",
@@ -10,6 +14,8 @@ cc_binary {
    ],
    ],
    shared_libs: [
    shared_libs: [
        "android.hardware.security.keymint-V1-ndk_platform",
        "android.hardware.security.keymint-V1-ndk_platform",
        "android.hardware.security.sharedsecret-unstable-ndk_platform",
        "android.hardware.security.secureclock-unstable-ndk_platform",
        "libbase",
        "libbase",
        "libbinder_ndk",
        "libbinder_ndk",
        "libcppbor",
        "libcppbor",
+6 −0
Original line number Original line Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="aidl">
        <name>android.hardware.security.secureclock</name>
        <fqname>ISecureClock/default</fqname>
    </hal>
</manifest>
+6 −0
Original line number Original line Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="aidl">
        <name>android.hardware.security.sharedsecret</name>
        <fqname>ISharedSecret/default</fqname>
    </hal>
</manifest>
+22 −9
Original line number Original line Diff line number Diff line
@@ -21,25 +21,38 @@
#include <android/binder_process.h>
#include <android/binder_process.h>


#include <AndroidKeyMintDevice.h>
#include <AndroidKeyMintDevice.h>
#include <AndroidSecureClock.h>
#include <AndroidSharedSecret.h>
#include <keymaster/soft_keymaster_logger.h>
#include <keymaster/soft_keymaster_logger.h>


using aidl::android::hardware::security::keymint::AndroidKeyMintDevice;
using aidl::android::hardware::security::keymint::AndroidKeyMintDevice;
using aidl::android::hardware::security::keymint::SecurityLevel;
using aidl::android::hardware::security::keymint::SecurityLevel;
using aidl::android::hardware::security::secureclock::AndroidSecureClock;
using aidl::android::hardware::security::sharedsecret::AndroidSharedSecret;

template <typename T, class... Args>
std::shared_ptr<T> addService(Args&&... args) {
    std::shared_ptr<T> ser = ndk::SharedRefBase::make<T>(std::forward<Args>(args)...);
    auto instanceName = std::string(T::descriptor) + "/default";
    LOG(INFO) << "adding keymint service instance: " << instanceName;
    binder_status_t status =
            AServiceManager_addService(ser->asBinder().get(), instanceName.c_str());
    CHECK(status == STATUS_OK);
    return ser;
}


int main() {
int main() {
    // Zero threads seems like a useless pool, but below we'll join this thread to it, increasing
    // Zero threads seems like a useless pool, but below we'll join this thread to it, increasing
    // the pool size to 1.
    // the pool size to 1.
    ABinderProcess_setThreadPoolMaxThreadCount(0);
    ABinderProcess_setThreadPoolMaxThreadCount(0);
    std::shared_ptr<AndroidKeyMintDevice> keyMint =
            ndk::SharedRefBase::make<AndroidKeyMintDevice>(SecurityLevel::SOFTWARE);

    keymaster::SoftKeymasterLogger logger;
    const auto instanceName = std::string(AndroidKeyMintDevice::descriptor) + "/default";
    LOG(INFO) << "instance: " << instanceName;
    binder_status_t status =
            AServiceManager_addService(keyMint->asBinder().get(), instanceName.c_str());
    CHECK(status == STATUS_OK);


    // Add Keymint Service
    std::shared_ptr<AndroidKeyMintDevice> keyMint =
            addService<AndroidKeyMintDevice>(SecurityLevel::SOFTWARE);
    // Add Secure Clock Service
    addService<AndroidSecureClock>(keyMint);
    // Add Shared Secret Service
    addService<AndroidSharedSecret>(keyMint);
    ABinderProcess_joinThreadPool();
    ABinderProcess_joinThreadPool();
    return EXIT_FAILURE;  // should not reach
    return EXIT_FAILURE;  // should not reach
}
}
+15 −2
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////////
/*
 * Copyright (C) 2020 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.
 * limitations under the License.
 *////////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////


@@ -20,5 +33,5 @@ package android.hardware.security.secureclock;
@VintfStability
@VintfStability
interface ISecureClock {
interface ISecureClock {
  android.hardware.security.secureclock.TimeStampToken generateTimeStamp(in long challenge);
  android.hardware.security.secureclock.TimeStampToken generateTimeStamp(in long challenge);
  const String TIME_STAMP_MAC_LABEL = "Time Verification";
  const String TIME_STAMP_MAC_LABEL = "Auth Verification";
}
}
Loading