Keystore 2.0: Make key blob upgrade atomic.

This patch adds a key id lock. load_key_entry now returns a key id
guard, and database operations, that manipulate key entries require
a valid guard. This is mainly used to make upgrading the key blob
atomic.
This patch also adds key upgrade to wrapped key import and adds a helper
function, that hides the upgrade-required-retry logic.

Test: keystore2_test
Change-Id: I3f816817c731b89acb651b7d9a5fcacdd46c567f
3 files changed