From a1e4e4fe7331338ece1a6d3ba01862a35a22f4ae Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 23 Dec 2015 21:35:28 -0500 Subject: RPC interface to TRNG and (incomplete) PIN code. --- ks_flash.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'ks_flash.c') diff --git a/ks_flash.c b/ks_flash.c index ad9d2fe..ed05ab5 100644 --- a/ks_flash.c +++ b/ks_flash.c @@ -48,7 +48,7 @@ const hal_ks_keydb_t *hal_ks_get_keydb(void) hal_error_t hal_ks_set_keydb(const hal_ks_key_t * const key, const int loc) { - if (key == NULL || loc < 0 || loc >= sizeof(db.keys)/sizeof(*db.keys) || key->in_use) + if (key == NULL || loc < 0 || loc >= sizeof(db->keys)/sizeof(*db->keys) || key->in_use) return HAL_ERROR_BAD_ARGUMENTS; #error Not sure what goes here yet either @@ -57,13 +57,34 @@ hal_error_t hal_ks_set_keydb(const hal_ks_key_t * const key, hal_error_t hal_ks_del_keydb(const int loc) { - if (loc < 0 || loc >= sizeof(db.keys)/sizeof(*db.keys)) + if (loc < 0 || loc >= sizeof(db->keys)/sizeof(*db->keys)) return HAL_ERROR_BAD_ARGUMENTS; #error Or what goes here } +hal_error_t hal_ks_set_pin(const hal_user_t user, + const hal_ks_pin_t * const pin) +{ + if (pin == NULL) + return HAL_ERROR_BAD_ARGUMENTS; + + hal_ks_pin_t *p = NULL; + + switch (user) { + case HAL_USER_WHEEL: p = &db->wheel_pin; break; + case HAL_USER_SO: p = &db->so_pin; break; + case HAL_USER_NORMAL: p = &db->user_pin; break; + default: return HAL_ERROR_BAD_ARGUMENTS; + } + +#error Or what goes here + + return HAL_OK; +} + + /* * Local variables: * indent-tabs-mode: nil -- cgit v1.2.3