diff options
| author | Joel Challis <git@zvecr.com> | 2022-04-16 19:13:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-16 11:13:05 -0700 |
| commit | 92a61aa0cd9a28056e6979f01a72b8742702dbfe (patch) | |
| tree | a09ed136ab6355a762757cbffb5f836cb1b35b11 /quantum/secure.h | |
| parent | ae4d518352204d1d7bdf32427b569a03f35fb494 (diff) | |
Implement XAP 'secure' core requirements (#16843)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
Diffstat (limited to 'quantum/secure.h')
| -rw-r--r-- | quantum/secure.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/quantum/secure.h b/quantum/secure.h new file mode 100644 index 0000000000..04507fd5b1 --- /dev/null +++ b/quantum/secure.h | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | // Copyright 2022 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | /** \file | ||
| 7 | * | ||
| 8 | * Exposes a set of functionality to act as a virtual padlock for your device | ||
| 9 | * ... As long as that padlock is made of paper and its currently raining. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <stdint.h> | ||
| 13 | #include <stdbool.h> | ||
| 14 | |||
| 15 | /** \brief Available secure states | ||
| 16 | */ | ||
| 17 | typedef enum { | ||
| 18 | SECURE_LOCKED, | ||
| 19 | SECURE_PENDING, | ||
| 20 | SECURE_UNLOCKED, | ||
| 21 | } secure_status_t; | ||
| 22 | |||
| 23 | /** \brief Query current secure state | ||
| 24 | */ | ||
| 25 | secure_status_t secure_get_status(void); | ||
| 26 | |||
| 27 | /** \brief Helper to check if unlocking is currently locked | ||
| 28 | */ | ||
| 29 | #define secure_is_locked() (secure_get_status() == SECURE_LOCKED) | ||
| 30 | |||
| 31 | /** \brief Helper to check if unlocking is currently in progress | ||
| 32 | */ | ||
| 33 | #define secure_is_unlocking() (secure_get_status() == SECURE_PENDING) | ||
| 34 | |||
| 35 | /** \brief Helper to check if unlocking is currently unlocked | ||
| 36 | */ | ||
| 37 | #define secure_is_unlocked() (secure_get_status() == SECURE_UNLOCKED) | ||
| 38 | |||
| 39 | /** \brief Lock down the device | ||
| 40 | */ | ||
| 41 | void secure_lock(void); | ||
| 42 | |||
| 43 | /** \brief Force unlock the device | ||
| 44 | * | ||
| 45 | * \warning bypasses user unlock sequence | ||
| 46 | */ | ||
| 47 | void secure_unlock(void); | ||
| 48 | |||
| 49 | /** \brief Begin listening for an unlock sequence | ||
| 50 | */ | ||
| 51 | void secure_request_unlock(void); | ||
| 52 | |||
| 53 | /** \brief Flag to the secure subsystem that user activity has happened | ||
| 54 | * | ||
| 55 | * Call when some user activity has happened and the device should remain unlocked | ||
| 56 | */ | ||
| 57 | void secure_activity_event(void); | ||
| 58 | |||
| 59 | /** \brief Flag to the secure subsystem that user has triggered a keypress | ||
| 60 | * | ||
| 61 | * Call to trigger processing of the unlock sequence | ||
| 62 | */ | ||
| 63 | void secure_keypress_event(uint8_t row, uint8_t col); | ||
| 64 | |||
| 65 | /** \brief Handle various secure subsystem background tasks | ||
| 66 | */ | ||
| 67 | void secure_task(void); | ||
