Add TODO comments to randomise keyring slot allocation

This commit is contained in:
Andrew Bettison 2015-08-24 22:33:19 +09:30
parent 166a03c7c6
commit b7ba297e31
2 changed files with 5 additions and 0 deletions

View File

@ -1265,6 +1265,7 @@ static void set_slot(keyring_file *k, unsigned slot, int bitvalue)
/* Find free slot in keyring. Slot 0 in any slab is the BAM and possible keyring salt, so only
* search for space in slots 1 and above. TODO: Extend to handle more than one slab!
* TODO: random search to avoid predictability of used slots!
*/
static unsigned find_free_slot(const keyring_file *k)
{

View File

@ -85,6 +85,10 @@ test_keyringList() {
tfw_cat http.headers list.json
tfw_preserve list.json
assert [ "$(jq '.rows | length' list.json)" = $IDENTITY_COUNT ]
# TODO: these tests only work because the listed order of identities is the
# order of creation, which makes locked identities easy to attack. When the
# random search TODO in keyring.c:find_free_slot() is done, then these tests
# should fail.
assert [ "$(jq -r '.rows[0][0]' list.json)" = $SIDA1 ]
assert [ "$(jq -r '.rows[4][0]' list.json)" = $SIDA5 ]
assert [ "$(jq -r '.rows[9][0]' list.json)" = $SIDA10 ]