mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-16 09:40:06 +00:00
When MBEDTLS_PSA_KEY_STORE_DYNAMIC is enabled, key slots are now organized in multiple slices. The slices are allocated on demand, which allows the key store to grow. The size of slices grows exponentially, which allows reaching a large number of slots with a small (static) number of slices without too much overhead. Maintain a linked list of free slots in each slice. This way, allocating a slot takes O(1) time unless a slice needs to be allocated. In this commit, slices are only ever freed when deinitializing the key store. This should be improved in the future to free empty slices. To avoid growing the persistent key cache without control, the persistent key cache has a fixed size (reusing MBEDTLS_PSA_KEY_SLOT_COUNT to avoid creating yet another option). When MBEDTLS_PSA_KEY_STORE_DYNAMIC is disabled. no semantic change and minimal changes to the code. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>