OSDN Git Service

KeyStorage: rework key upgrade handling
authorEric Biggers <ebiggers@google.com>
Fri, 6 Nov 2020 03:58:26 +0000 (19:58 -0800)
committerEric Biggers <ebiggers@google.com>
Fri, 6 Nov 2020 03:58:26 +0000 (19:58 -0800)
commitf74373b17758886ba2880fc1ed838689e2022467
tree97f6cf28e280832680ba2095d95c7ceab3a87f97
parente244a15f34ae2e85e3f5b40be0bf252e37eab56b
KeyStorage: rework key upgrade handling

Remove the error-prone 'keepOld' parameter, and instead make begin()
(renamed to BeginKeymasterOp()) do all the key upgrade handling.

Don't handle /data and /metadata differently anymore.  Previously, when
a checkpoint is active, key blob files were replaced on /data
immediately; only the actual Keymaster key deletion was delayed until
checkpoint commit.  But it's easier to just delay the key blob file
replacement too, as we have to implement that for /metadata anyway.

Also be more vigilant about deleting any leftover upgraded keys.

Test: Tested on bramble using an OTA rvc-d1-release => master.  In OTA
      success case, verified via logcat that the keys were upgraded and
      then were committed after the boot succeeded.  In OTA failure
      case, verified that the device still boots -- i.e., the old keys
      weren't lost.  Verified that in either case, no
      keymaster_key_blob_upgraded files were left over.  Finally, also
      tried 'pm create-user' and 'pm remove-user' and verified via
      logcat that the Keymaster keys still get deleted.
Change-Id: Ic9c3e63e0bcae0c608fc79050ca4a1676b3852ee
FsCrypt.cpp
KeyStorage.cpp
KeyStorage.h
KeyUtil.cpp
KeyUtil.h
MetadataCrypt.cpp
Utils.cpp
Utils.h