summaryrefslogtreecommitdiff
path: root/include/fpsensor_state.h
diff options
context:
space:
mode:
authorYicheng Li <yichengli@chromium.org>2019-06-14 18:21:17 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-09 03:43:59 +0000
commit83e0848263313dbdaf10ebc887dea548faaf251a (patch)
tree9e5175d0fdee0265ef0d96fc6705fded4917c246 /include/fpsensor_state.h
parent635f21d41c095f138cb711118a7866fcd0b5bcc4 (diff)
downloadchrome-ec-83e0848263313dbdaf10ebc887dea548faaf251a.tar.gz
fpsensor: Implement command to read positive_match_secret.
Add EC command to read positive_match_secret on match success. If the attempt to read is 5 seconds after the match, the read is not allowed (the readable bit for positive match secret is cleared). Test that the command can read the data correctly and can read for each finger only once. Test that attempt to read secret after deadline will be rejected. BRANCH=nocturne BUG=chromium:927095 TEST=make buildall TEST=tested enrollment, matching and multifinger on DUT nocturne TEST=tested that if biod requests to download template and secret for a finger that's not currently matched, reading secret will fail. Change-Id: Idc734c6392d271e2aaee1cddf7c2c5b81b727b4a Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1679372 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Diffstat (limited to 'include/fpsensor_state.h')
-rw-r--r--include/fpsensor_state.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h
index 63ebaa465d..624318837d 100644
--- a/include/fpsensor_state.h
+++ b/include/fpsensor_state.h
@@ -8,10 +8,12 @@
#ifndef __CROS_EC_FPSENSOR_STATE_H
#define __CROS_EC_FPSENSOR_STATE_H
+#include <stdbool.h>
#include <stdint.h>
#include "common.h"
#include "ec_commands.h"
#include "link_defs.h"
+#include "timer.h"
/* if no special memory regions are defined, fallback on regular SRAM */
#ifndef FP_FRAME_SECTION
@@ -33,7 +35,6 @@
#define FP_ALGORITHM_TEMPLATE_SIZE 0
#define FP_MAX_FINGER_COUNT 5
#endif
-#define FP_POSITIVE_MATCH_SECRET_BYTES 32
#define SBP_ENC_KEY_LEN 16
#define FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE \
(FP_ALGORITHM_TEMPLATE_SIZE + \
@@ -44,6 +45,8 @@
#define TASK_EVENT_SENSOR_IRQ TASK_EVENT_CUSTOM_BIT(0)
#define TASK_EVENT_UPDATE_CONFIG TASK_EVENT_CUSTOM_BIT(1)
+#define FP_NO_SUCH_TEMPLATE -1
+
/* --- Global variables defined in fpsensor_state.c --- */
/* Last acquired frame (aligned as it is used by arbitrary binary libraries) */
@@ -73,6 +76,17 @@ extern uint32_t fp_events;
extern uint32_t sensor_mode;
+struct positive_match_secret_state {
+ /* Index of the most recently matched template. */
+ int8_t template_matched;
+ /* Flag indicating positive match secret can be read. */
+ bool readable;
+ /* Deadline to read positive match secret. */
+ timestamp_t deadline;
+};
+
+extern struct positive_match_secret_state positive_match_secret_state;
+
/* Simulation for unit tests. */
void fp_task_simulate(void);
@@ -112,4 +126,22 @@ int fp_tpm_seed_is_set(void);
*/
int fp_set_sensor_mode(uint32_t mode, uint32_t *mode_output);
+/**
+ * Allow reading positive match secret for |fgr| in the next 5 seconds.
+ *
+ * @param fgr the index of template to enable positive match secret.
+ * @param state the state of positive match secret, e.g. readable or not.
+ * @return EC_SUCCESS if the request is valid, error code otherwise.
+ */
+int fp_enable_positive_match_secret(uint32_t fgr,
+ struct positive_match_secret_state *state);
+
+/**
+ * Disallow positive match secret for any finger to be read.
+ *
+ * @param state the state of positive match secret, e.g. readable or not.
+ */
+void fp_disable_positive_match_secret(
+ struct positive_match_secret_state *state);
+
#endif /* __CROS_EC_FPSENSOR_STATE_H */