2022-04-10 23:43:18 +00:00
|
|
|
// Copyright 2022 QMK
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \file
|
|
|
|
*
|
|
|
|
* Exposes a set of functionality to act as a virtual padlock for your device
|
|
|
|
* ... As long as that padlock is made of paper and its currently raining.
|
|
|
|
*/
|
|
|
|
|
2022-04-10 23:43:18 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Available secure states
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
typedef enum {
|
|
|
|
SECURE_LOCKED,
|
|
|
|
SECURE_PENDING,
|
|
|
|
SECURE_UNLOCKED,
|
|
|
|
} secure_status_t;
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Query current secure state
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
secure_status_t secure_get_status(void);
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Helper to check if unlocking is currently locked
|
|
|
|
*/
|
|
|
|
#define secure_is_locked() (secure_get_status() == SECURE_LOCKED)
|
|
|
|
|
|
|
|
/** \brief Helper to check if unlocking is currently in progress
|
|
|
|
*/
|
|
|
|
#define secure_is_unlocking() (secure_get_status() == SECURE_PENDING)
|
|
|
|
|
|
|
|
/** \brief Helper to check if unlocking is currently unlocked
|
|
|
|
*/
|
|
|
|
#define secure_is_unlocked() (secure_get_status() == SECURE_UNLOCKED)
|
2022-04-10 23:43:18 +00:00
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Lock down the device
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
void secure_lock(void);
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Force unlock the device
|
|
|
|
*
|
|
|
|
* \warning bypasses user unlock sequence
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
void secure_unlock(void);
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Begin listening for an unlock sequence
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
void secure_request_unlock(void);
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Flag to the secure subsystem that user activity has happened
|
|
|
|
*
|
|
|
|
* Call when some user activity has happened and the device should remain unlocked
|
|
|
|
*/
|
2022-04-11 01:14:19 +00:00
|
|
|
void secure_activity_event(void);
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Flag to the secure subsystem that user has triggered a keypress
|
|
|
|
*
|
|
|
|
* Call to trigger processing of the unlock sequence
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
void secure_keypress_event(uint8_t row, uint8_t col);
|
|
|
|
|
2022-04-12 00:37:25 +00:00
|
|
|
/** \brief Handle various secure subsystem background tasks
|
|
|
|
*/
|
2022-04-10 23:43:18 +00:00
|
|
|
void secure_task(void);
|