aboutsummaryrefslogtreecommitdiff
path: root/hal_internal.h
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-05-22 23:22:09 -0400
committerRob Austein <sra@hactrn.net>2017-05-22 23:22:09 -0400
commit2b4dc660d9d10eed407851319bfe63d5f9c3acd1 (patch)
tree8890c91f6cae57a95f8616ffc5e9e979813faa58 /hal_internal.h
parent6c3ec32a384e3018f44dda42ff8bcaf9c94f15c4 (diff)
First pass on experimental one-size-fits-nobody keystore.
Support for variable-length keystore objects significantly complicates the keystore implementation, including serious some serious code bloat and a complex recovery algorithm to deal with crashes or loss of power at exactly the wrong time. Perhaps we don't really need this? So this is an experiment to see whether we can replace variable-length keystore objects with fixed-length, perhaps with a compile time option to let us make the fixed object length be 8192 bytes instead of 4096 bytes when needed to hold things like large RSA keys. First pass on this is just throwing away nearly 1,000 lines of excessively complex code. The result probably won't even compile yet, but it's already significantly easier to read.
Diffstat (limited to 'hal_internal.h')
-rw-r--r--hal_internal.h40
1 files changed, 1 insertions, 39 deletions
diff --git a/hal_internal.h b/hal_internal.h
index 3aadb48..aa31585 100644
--- a/hal_internal.h
+++ b/hal_internal.h
@@ -708,13 +708,6 @@ static inline hal_error_t hal_ks_get_attributes(hal_ks_t *ks,
* support a simplistic form of wear leveling in flash-based keystores.
*
* Key names are kept in a separate array, indexed by block number.
- * Key names here are a composite of the key's UUID and a "chunk"
- * number; the latter allows storage of keys whose total size exceeds
- * one block (whatever a block is). For the moment we keep the UUID
- * and the chunk number in a single array, which may provide (very)
- * slightly better performance due to reference locality in SDRAM, but
- * this may change if we need to reclaim the space wasted by structure
- * size rounding.
*
* The all-zeros UUID, which (by definition) cannot be a valid key
* UUID, is reserved for the (non-key) block used to stash PINs and
@@ -727,15 +720,10 @@ static inline hal_error_t hal_ks_get_attributes(hal_ks_t *ks,
*/
typedef struct {
- hal_uuid_t name; /* Key name */
- uint8_t chunk; /* Key chunk number */
-} hal_ks_name_t;
-
-typedef struct {
unsigned size; /* Array length */
unsigned used; /* How many blocks are in use */
uint16_t *index; /* Index/freelist array */
- hal_ks_name_t *names; /* Keyname array */
+ hal_uuid_t *names; /* Keyname array */
} hal_ks_index_t;
/*
@@ -755,27 +743,14 @@ extern hal_error_t hal_ks_index_setup(hal_ks_index_t *ksi);
*/
extern hal_error_t hal_ks_index_find(hal_ks_index_t *ksi,
const hal_uuid_t * const name,
- const unsigned chunk,
unsigned *blockno,
int *hint);
/*
- * Find all the blocks in a key, return the block numbers.
- */
-extern hal_error_t hal_ks_index_find_range(hal_ks_index_t *ksi,
- const hal_uuid_t * const name,
- const unsigned max_blocks,
- unsigned *n_blocks,
- unsigned *blocknos,
- int *hint,
- const int strict);
-
-/*
* Add a key block, return its block number.
*/
extern hal_error_t hal_ks_index_add(hal_ks_index_t *ksi,
const hal_uuid_t * const name,
- const unsigned chunk,
unsigned *blockno,
int *hint);
@@ -784,22 +759,10 @@ extern hal_error_t hal_ks_index_add(hal_ks_index_t *ksi,
*/
extern hal_error_t hal_ks_index_delete(hal_ks_index_t *ksi,
const hal_uuid_t * const name,
- const unsigned chunk,
unsigned *blockno,
int *hint);
/*
- * Delete all of blocks in a key, returning the block numbers.
- */
-
-extern hal_error_t hal_ks_index_delete_range(hal_ks_index_t *ksi,
- const hal_uuid_t * const name,
- const unsigned max_blocks,
- unsigned *n_blocks,
- unsigned *blocknos,
- int *hint);
-
-/*
* Replace a key block with a new one, return new block number.
* Name of block does not change. This is an optimization of
* a delete immediately followed by an add for the same name.
@@ -807,7 +770,6 @@ extern hal_error_t hal_ks_index_delete_range(hal_ks_index_t *ksi,
extern hal_error_t hal_ks_index_replace(hal_ks_index_t *ksi,
const hal_uuid_t * const name,
- const unsigned chunk,
unsigned *blockno,
int *hint);