~aleteoryx/muditaos

2b05b9739ed81f7b79ff5bc0f77988500ba0d914 — Pawel Olejniczak 5 years ago d5c3d41
[EGD-5204] Secure USB communication

Secure all endpoints by returning 403(Forbidden) when USB is connected.
Request screen passcode to enable secured endpoints.
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +1 -1
@@ 53,7 53,7 @@ namespace app

        addActionReceiver(app::manager::actions::RequestScreenPasscode, [this](auto &&data) {
            lockHandler.handleScreenPasscodeRequest(std::move(data));
            return msgHandled();
            return actionHandled();
        });

        addActionReceiver(app::manager::actions::RequestPuk, [this](auto &&data) {

M module-apps/application-desktop/widgets/PinLockHandler.cpp => module-apps/application-desktop/widgets/PinLockHandler.cpp +6 -2
@@ 68,7 68,7 @@ namespace gui
            simLock.lockType  = type;
        }
        simLock.passcodeName = passcodeData->getPasscodeName();
        simLock.value = passcodeData->getAttempts();
        simLock.value        = passcodeData->getAttempts();
    }

    void PinLockHandler::handlePasscodeRequest(PinLock::LockType type, app::manager::actions::ActionParamsPtr &&data)


@@ 90,7 90,11 @@ namespace gui
            Store::GSM::SIM::NONE, PinLock::LockState::PasscodeRequired, PinLock::LockType::Screen);

        if (params->isCancel()) {
            app->switchWindow(app::window::name::desktop_main_window);
            if (app->getCurrentWindow()->getName() == app::window::name::desktop_pin_lock) {
                app->switchWindow(app::window::name::desktop_main_window);
            }
            app->bus.sendUnicast(std::make_shared<sdesktop::passcode::ScreenPasscodeUnlocked>(),
                                 service::name::service_desktop);
            return;
        }


M module-bsp/CMakeLists.txt => module-bsp/CMakeLists.txt +2 -0
@@ 75,6 75,8 @@ target_compile_definitions(${PROJECT_NAME}
        -DFSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1
        -D__STARTUP_INITIALIZE_NONCACHEDATA
        -D__USE_CMSIS
        -DDEBUG_VCOM=1
        -DDEBUG_USB=1
        )

target_include_directories(${PROJECT_NAME}

M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +2 -1
@@ 201,7 201,8 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
    });

    connect(sdesktop::usb::USBDisconnected(), [&](sys::Message *msg) {
        bus.sendUnicast(std::make_shared<sdesktop::passcode::ScreenPasscodeRequest>(),
        LOG_INFO("USB disconnected. Enabling secured endpoints.");
        bus.sendUnicast(std::make_shared<sdesktop::passcode::ScreenPasscodeRequest>(true),
                        app::manager::ApplicationManager::ServiceName);
        return std::make_shared<sys::ResponseMessage>();
    });

M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.hpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.hpp +5 -9
@@ 55,9 55,7 @@ namespace parserFSM
        inline constexpr auto changeCellularStateCmd = "changeCellularStateCmd";
        inline constexpr auto getInfo                = "getInfo";
        inline constexpr auto tethering              = "tethering";

        inline constexpr auto tethering   = "tethering";
        inline constexpr auto usbSecurity = "usbSecurity";
        inline constexpr auto usbSecurity            = "usbSecurity";
        /// values for getInfo cmd
        inline constexpr auto simStateInfo      = "simState";
        inline constexpr auto cellularStateInfo = "cellularState";


@@ 69,12 67,10 @@ namespace parserFSM
        inline constexpr auto tetheringOn  = "on";
        inline constexpr auto tetheringOff = "off";

        /// values for tethering
        inline constexpr auto tetheringOn  = "on";
        inline constexpr auto tetheringOff = "off";
        /// values for usbSecurity
        inline constexpr auto usbLock   = "usbLock";
        inline constexpr auto usbUnlock = "usbUnlock";

    } // namespace json::developerMode

    /// values for usbSecurity
    inline constexpr auto usbLock   = "usbLock";
    inline constexpr auto usbUnlock = "usbUnlock";
} // namespace parserFSM