diff options
author | Rob Austein <sra@hactrn.net> | 2016-09-11 16:39:20 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-09-11 16:39:20 -0400 |
commit | 421626cdc49cab03f9b4071ee9e836f8d095aa20 (patch) | |
tree | 8cf7ebc4c706f009bfcde3b21ee8a64061cce007 /hal_internal.h | |
parent | 52bafc94397795e196aa516df044994692f4705f (diff) |
Explicit initialization of keystore drivers instead of guessing.
Diffstat (limited to 'hal_internal.h')
-rw-r--r-- | hal_internal.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/hal_internal.h b/hal_internal.h index cc2d749..5e6b939 100644 --- a/hal_internal.h +++ b/hal_internal.h @@ -390,6 +390,10 @@ typedef struct hal_ks hal_ks_t; struct hal_ks_driver { + hal_error_t (*init)(const hal_ks_driver_t * const driver); + + hal_error_t (*shutdown)(const hal_ks_driver_t * const driver); + hal_error_t (*open)(const hal_ks_driver_t * const driver, hal_ks_t **ks); @@ -430,6 +434,22 @@ extern const hal_ks_driver_t hal_ks_volatile_driver[1], hal_ks_token_driver[1]; +static inline hal_error_t hal_ks_init(const hal_ks_driver_t * const driver) +{ + if (driver == NULL || driver->init == NULL) + return HAL_ERROR_BAD_ARGUMENTS; + + return driver->init(driver); +} + +static inline hal_error_t hal_ks_shutdown(const hal_ks_driver_t * const driver) +{ + if (driver == NULL || driver->shutdown == NULL) + return HAL_ERROR_BAD_ARGUMENTS; + + return driver->shutdown(driver); +} + static inline hal_error_t hal_ks_open(const hal_ks_driver_t * const driver, hal_ks_t **ks) { |