keystore: command to clear all keys for UID

Add ability for system UID to clear all entries for a different UID.

Bug: 3020069
Change-Id: Ibfeea6aae9006cb2ef7052ead72b2704dfce3cb4
Merge "keystore: command to clear all keys for UID"
keystore: fix upgrades

During an upgrade, a blob would be written out to disk. Whenever a blob
is written to disk, it is encrypted in-place. After upgrade, keystore
would attempt to use the blob, but get garbage instead of what it
expected since it was encrypted.

This moves the work of writing up a level so it can then re-read the
blob after upgrade.

Bug: 7249554
Change-Id: I3946c5db1c2fc57ace476db04f792e3b82d1cb15
Merge "keystore: fix upgrades"
Fix CL split and build

Change-Id: Ie96b2d22af839b67daed4f194e37864cd50e8463
Merge "Fix CL split and build"
keystore: fix inverted hardware keystore check

Check should be that the 'is_software' flag is off.

Change-Id: Ic03ef957f6aa62b959b24fe8e4ff202f431aab89
Merge "keystore: fix inverted hardware keystore check"
keystore: Add multi-user support

Split the directories out per-user. Each Android user ID gets its own
directory and master key. This gives each user its own locked/unlocked
state.

Add migration code that converts existing keystores to this scheme. This
even migrates keys that used the non-public API, but only for the
primary user. The secondary users may have a different lock screen
pattern that would no longer work to unlock the master key.

Bug: 7249554
Change-Id: Ie135235ab1eb88ddb2d89a6cb4ffd8fb6736c573
Merge "keystore: Add multi-user support"
keystore: fix bug in clear_uid

(cherry picked from commit aae26fc0e58c99ac8e0df69b913523e81fa15d66)

Bug: 8566369
Change-Id: Ic1b604f6cc0c3a950e7ce1b98604a9fd7419f720
Merge "keystore: fix bug in clear_uid"
keystore: Add flag for blobs to be unencrypted

In order to let apps use keystore more productively, make the blob
encryption optional. As more hardware-assisted keystores (i.e., hardware
that has a Keymaster HAL) come around, encrypting blobs start to make
less sense since the thing it's encrypting is usually a token and not
any raw key material.

(cherry picked from commit 0c540aad5915e6aa34345049be96f28b64d0e84c)

Bug: 8122243
Change-Id: Ie97f6df1ba141b1ed8007413ec1a834b0486cc2a
Merge "keystore: Add flag for blobs to be unencrypted"
keystore: fix import as other UIDs

The targetUid was not being used as the user to store the key as, so it
was ending up under the calling UID. This change matches the code for
insert and generate now.

(cherry picked from commit 360f51f7af191316cd739f229db1c5f7233be063)

Bug: 8634328
Change-Id: I6bb9f66687552af990fdf90501f183930910ba8d
Merge "keystore: fix import as other UIDs"
Merge branch 'master' into HEAD