keystore: change migrate to duplicate

After discussion, it was determined that duplicate would be less
disruptive and it still fit in the current HAL model.

Change-Id: Id6ff97bfa5ec4cca9def177677263e9be1c9619f
Merge "keystore: change migrate to duplicate"
Merge remote-tracking branch 'aosp/master' into jb-aosp

Change-Id: I00ca4d26b98a4214eeffca76a2d139854dac15ad
revert keystore changes

Change-Id: I6ba24d49b03b81d4a457e016ed8534e7d0749e98
keystore: add API to query storage type

Add an API to query the HAL to see what kind of storage it reports the
device is.

Change-Id: I37951e989ad724e2352df6e321f03f19e58b4fca
Merge "keystore: add API to query storage type"
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"