Commit graph

3700 commits

Author SHA1 Message Date
Janis Danisevskis
3eb829da4d Keystore 2.0: Extend the functionality of the Vpn profile store.
It turns out there are more clients that use Keystore in a creative
way. This patch renames the VpnProfileStore to LegacyKeystore and
extends the functionality such that it allows access to all blobs with
alias prefixes that were not known to Keystore. It also brings back the
option to specify a uid argument. Specifically, for AID_SYSTEM to
manipulate the WIFI namespace.

Test: TBD
Bug: 191373871
Merged-In: Iaf81e7ccaee3c09a465dcec0fd5899b781c31db5
Change-Id: Iaf81e7ccaee3c09a465dcec0fd5899b781c31db5
2021-06-30 12:37:12 -07:00
Martijn Coenen
30257fa908 Merge "On-device signing: reject everything that's not a regular file/dir." 2021-06-29 14:37:29 +00:00
Martijn Coenen
0f760d7d54 On-device signing: reject everything that's not a regular file/dir.
We shouldn't allow anything else in the artifacts output directory.

Bug: 192061595
Test: TEST_MAPPING
Change-Id: I1be9dfd7982d543a8979ac3a34551bd5449004f7
2021-06-29 14:51:46 +02:00
Martijn Coenen
d2dede4e7b Merge "On-device signing: Use correct deleteKey() instance." 2021-06-29 11:29:24 +00:00
Martijn Coenen
16e25c5140 On-device signing: Use correct deleteKey() instance.
Use the one that isn't for blobs.

Bug: 190711210
Test: TEST_MAPPING
Change-Id: Ia77cbb8a94cfe96d4dc511e60b9e0b5da384eae6
2021-06-29 11:03:07 +02:00
Alan Stokes
890f115606 Merge "On-device signing: Delete the HMAC key when failing to use it." 2021-06-24 08:19:00 +00:00
Max Bires
1b8aac34d3 Merge "Fixing CBOR parsing/serialization for prod keys." 2021-06-23 21:54:34 +00:00
Max Bires
67e9512b81 Fixing CBOR parsing/serialization for prod keys.
Production keys are 6 bytes smaller than test keys due to the absence of
an entry in the COSE_Key map which would denote that key as a test key.
(-70000, nil). This patch properly adjusts for the size difference
between the two keys.

Bug: 189018262
Test: Let the provisioner run.
Change-Id: I9ff0c99e58a1691c8e7bdedb0cbeafb683b39722
Merged-In: I9ff0c99e58a1691c8e7bdedb0cbeafb683b39722
2021-06-22 19:30:11 -07:00
Treehugger Robot
f2fa29c555 Merge "Fix VPN profile store test" 2021-06-22 18:39:12 +00:00
Seth Moore
9ebec5fe6e Fix VPN profile store test
WAL mode was disabled, but one of the VPN profile store tests was
still checking to ensure WAL mode was enabled.

Fixes: 191099248
Test: keystore2_test
Test: vpnprofilestore_test
Change-Id: Ib02057e01bbc73ac3b744a4298fc388487fb61a8
Merged-In: Ib02057e01bbc73ac3b744a4298fc388487fb61a8
2021-06-22 10:20:28 -07:00
Martijn Coenen
efbb567893 On-device signing: Delete the HMAC key when failing to use it.
This may allow us to recover in certain bad situations. Also, add some
more clear error logs when failing to create/delete a key, to make it
easier to debug failures.

Bug: 190711210
Test: TEST_MAPPING
Change-Id: Ib9a9ce0c0d0e99ce44d124af85775780f448a854
2021-06-22 10:36:43 +02:00
Treehugger Robot
bd5edbc517 Merge "Keystore2: fix test_large_number_of_concurrent_db_manipulations" 2021-06-21 20:21:41 +00:00
Treehugger Robot
82beab1d29 Merge "Keystore2: Stop using WAL mode" 2021-06-21 20:17:02 +00:00
Kris Alder
9c9ff707e3 Merge changes Ifba05b57,Idd0f35fc
* changes:
  libkeystore-wifi-hidl: Updated to vendor_available:true
  libkeystore-wifi-hidl: Updated Android.bp
2021-06-18 23:31:13 +00:00
Janis Danisevskis
8f6fb01eaf Merge "To initialize StrongBox KM with TEE KM" 2021-06-18 18:40:47 +00:00
Treehugger Robot
c2d11c39bf Merge "Use fsverity_formatted_digest from <linux/fsverity.h>" am: f557951af1
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1731926

Change-Id: I3fe92b73781abfa54d2f46c99fa5b06caa128a1b
2021-06-18 03:18:43 +00:00
Treehugger Robot
f557951af1 Merge "Use fsverity_formatted_digest from <linux/fsverity.h>" 2021-06-18 03:06:23 +00:00
Eric Biggers
37708580d9 Use fsverity_formatted_digest from <linux/fsverity.h>
struct fsverity_formatted_digest (previously called
fsverity_signed_digest) is now in <linux/fsverity.h>, so there is no
longer any need to have a local definition of it.

Test: build
Change-Id: Ie3623a56fe6415d686a51ddfde8a1ebab83b8364
2021-06-18 02:00:55 +00:00
Manish Dwivedi
ddae34a825 To initialize StrongBox KM with TEE KM
Test: Run Keystore CTS tests
Bug: b/191171542
Change-Id: I0f2c6d4e1d7a3fda973bcf65fd967119cbd52337
2021-06-17 20:44:05 +00:00
Treehugger Robot
eadab2cd2d Merge "Remove provisioner_cli tool" am: e47093b55c
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1738081

Change-Id: I657e0f5a8e5c05f2aa72b6b6f53e7a949cdaf11f
2021-06-17 12:16:21 +00:00
Treehugger Robot
e47093b55c Merge "Remove provisioner_cli tool" 2021-06-17 12:01:19 +00:00
Alan Stokes
f3489a8dc0 Merge changes I1bcb7f89,I2f2f0434 am: 24fed161df
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1736867

Change-Id: I43ac8c907f5e449302643f0a2515bd101e6bf0d5
2021-06-17 08:15:17 +00:00
Alan Stokes
24fed161df Merge changes I1bcb7f89,I2f2f0434
* changes:
  Add (fake) CompOS key verification.
  Add (fake) CompOS key generation.
2021-06-17 08:06:11 +00:00
Seth Moore
7c05fd841e Remove provisioner_cli tool
This tool has been made obsolete by rkp_factory_extraction_tool

Test: n/a -- nothing uses this tool
Change-Id: Ic15ff9e526809dd7dae0d9f17b79fd7ff87f61c7
2021-06-16 15:13:00 -07:00
Alan Stokes
4ead5ec4ca Merge "Improved error checking for fsverity_init/odsign." am: 5cfce6fda6
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1733276

Change-Id: Ia37dcd49dcbc543b9eeffc989544ce0ec9428cb7
2021-06-15 08:25:55 +00:00
Alan Stokes
5cfce6fda6 Merge "Improved error checking for fsverity_init/odsign." 2021-06-15 08:16:13 +00:00
Seth Moore
444b51aea7 Keystore2: fix test_large_number_of_concurrent_db_manipulations
The test was disabled and got stale. Fix the test so it uses the GC,
as it's useful for checking perf-related code changes. Will investigate
fully re-enabling the test on T.

Bug: 190142197
Test: keystore2_test
Change-Id: Ifc0a4a5b3c8c301c42d068ee46754d877eeb10bc
Merged-In: Ifc0a4a5b3c8c301c42d068ee46754d877eeb10bc
2021-06-14 14:28:41 -07:00
Seth Moore
fbe5cf545c Keystore2: Stop using WAL mode
WAL mode attempts to open an additional file for use as a shared memory
mechanism. If storage is too full, then the database fails to open.
Remove the use of WAL mode so that keystore can perform read-only
transactions on the database and startup even on a full disk.

Disabling WAL mode shows about a 5% performance drop on a synthetic test
that creates and destroys 5000 AES keys.

Bug: 190142197
Test: keystore2_test
Change-Id: I9b1cb7e6398e07fa9f02f0ba4e9eb48313c06472
Merged-In: I9b1cb7e6398e07fa9f02f0ba4e9eb48313c06472
2021-06-14 14:28:32 -07:00
Alan Stokes
314845dc8f Add (fake) CompOS key verification.
If we have a persisted key blob and public key for CompOS, but no
cert, then get CompOS to verify that they are genuine. If so, we can
generate a new cert for the public key. Otherwise we fall back to
generating a new keypair.

Once again I have made a few unrelated changes as I understand things
better.

Bug: 190166662
Test: Presubmit
Test: Manual - various valid & missing/invalid files.
Change-Id: I1bcb7f89698c103f413bdb899026bfd2578447db
2021-06-14 18:02:52 +01:00
Alan Stokes
bfd2ec0404 Add (fake) CompOS key generation.
Note: the CompOS work here is all still behind an if (false).

Added a new class, FakeCompOs, to allow prototyping of the interface
and implementation of the key management work that will be in CompOS.

Extensive refactoring of the certificate generation code to support
both a self-signed cert and our certificate for the CompOS key.

Bug: 190166662
Test: presubmits
Test: manual - certificate gets generated on first boot
Test: manual - certificate verifies ok on second boot
Test: manual inspection of the generated certs' text form
Change-Id: I2f2f043427774c0805e963dfe582feb8d3eac3a4
2021-06-14 09:15:39 +01:00
Xin Li
06d1b48561 Merge "DO NOT MERGE - Merge ab/7272582" am: ee5c643f54
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1735953

Change-Id: I4c281f211463cf0143fdc1c20c48e23c19f3a111
2021-06-14 03:14:01 +00:00
Xin Li
28bf846900 DO NOT MERGE - Merge ab/7272582 am: 9c0a7e2b65
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1735953

Change-Id: I3d1b2d96eba9b3dfceaabb89f673c6be1c9a8aad
2021-06-14 03:13:54 +00:00
Xin Li
ee5c643f54 Merge "DO NOT MERGE - Merge ab/7272582" 2021-06-14 03:02:54 +00:00
Xin Li
9c0a7e2b65 DO NOT MERGE - Merge ab/7272582
Bug: 190855093
Change-Id: I477816eed7b78ae7768be4eafec685d44f24f4cc
2021-06-11 17:34:04 -07:00
Alan Stokes
246a7f13ac Improved error checking for fsverity_init/odsign.
When attempting to load a non-existent cert I got:
  06-10 12:48:11.939   662   662 E fsverity_init: Failed to add key: Invalid argument
  06-10 12:48:11.940   662   662 E fsverity_init: Failed to load key from stdin
  06-10 12:48:11.941   648   648 I odsign  : Added CompOs key to fs-verity keyring
Which looks like everything worked when nothing did.

Added more error checks on both sides.

Test: Presubmits
Test: Manual
Change-Id: Ib2b17ce75e58dafb0ad6905106e35b11b55e91d0
2021-06-11 10:01:33 +01:00
Aditya Wazir
64ce92520d libkeystore-wifi-hidl: Updated to vendor_available:true
Updated libkeystore-wifi-hidl from 'vendor: true' to 'vendor_available: true'

Test: Build libkeystore-wifi-hidl
Bug: 187130384

Change-Id: Ifba05b57248f52ac33e297acd5d0b7811e3524ee
2021-06-11 11:06:26 +05:30
Aditya Wazir
f6c3bfc428 libkeystore-wifi-hidl: Updated Android.bp
Updated Android.bp to build both static and shared library

Test: Build libkeystore-wifi-hidl
Bug: 187130384

Change-Id: Idd0f35fc33a224c598fc3e96f11f88cacf5c9aba
2021-06-11 11:06:10 +05:30
Treehugger Robot
3542845824 Merge "Keystore 2.0: Don't panic key negotiation checksum failure." am: 21f7f98fe8
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1733716

Change-Id: I24c829347ad9a0d7ca62edaaae6ab3768b203653
2021-06-10 23:59:46 +00:00
Treehugger Robot
21f7f98fe8 Merge "Keystore 2.0: Don't panic key negotiation checksum failure." 2021-06-10 23:41:44 +00:00
Janis Danisevskis
d7308c7968 Keystore 2.0: Don't panic key negotiation checksum failure.
We should not panic when a checksum failure happens during shared key
negotiation. This is typical for pre production devices that have not
been fully provisioned yet. Not panicking gives the user the chance to
finalize the provisioning step.

Bug: 190702219
Test: N/A
Merged-In: I0c847b52f2c63c6c2eef0765cc1536daa0893d1c
Change-Id: I0c847b52f2c63c6c2eef0765cc1536daa0893d1c
2021-06-10 15:14:45 -07:00
Alan Stokes
263ebd0300 Merge "Add support for an existing CompOS cert." am: ba9317c064
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1730432

Change-Id: I41ea3e5b80f0fb7d835ee1ced243a781179f3b06
2021-06-10 08:27:14 +00:00
Alan Stokes
ba9317c064 Merge "Add support for an existing CompOS cert." 2021-06-10 08:09:52 +00:00
Janis Danisevskis
d97323b246 Merge "Keystore 2.0: Fix shared secret negotiation for Keymaster 4.x" am: d955c25a00
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1731552

Change-Id: I8ed9fd505808eb5376707ac65b516403dedca0c8
2021-06-09 20:21:55 +00:00
Janis Danisevskis
d955c25a00 Merge "Keystore 2.0: Fix shared secret negotiation for Keymaster 4.x" 2021-06-09 20:06:04 +00:00
Janis Danisevskis
d0e0888e89 Keystore 2.0: Fix shared secret negotiation for Keymaster 4.x
The km_compat legacy wrapper would only cache the first shared secret
participant and then return this participant regardless of which
security level was requested. As a result only one Keymaster instance
would take part in the shared secret negotiation.

This patch adds a per security level cache for ISharedSecret instances
to km_compat. It filters Keymaster instances in Keystore 2.0 to only
include the highest version of each HIDL Keymaster security level.

Bug: 190539964
Test: See b/190539964
Merged-In: I0b73da88d3e1b6900cfb332c1befc704eca59cc5
Change-Id: I0b73da88d3e1b6900cfb332c1befc704eca59cc5
2021-06-09 10:59:08 -07:00
Alan Stokes
b182178879 Add support for an existing CompOS cert.
Modify odsign to verify an existing CompOS cert and add it to the
fs-verity keyring if ok or delete it if not.

The significant new behaviour is all behind an if (false), since
there's still a lot to do (like making it possible for a valid cert to
exist).

Otherwise, various refactorings and gratuitous tinkering.

Bug: 190166662
Bug: 188450218
Test: Presubmits
Test: Manual - push various differently-invalid certs & observe
Change-Id: I51021c95fa4670d5fd022783565b1e215962483b
2021-06-09 08:43:46 +00:00
Treehugger Robot
2fe224e138 Merge "Minor fixes." am: fc9ba206e4
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1729310

Change-Id: I8089022f7fa85d0974dddc4a510d4ac504236b23
2021-06-07 17:03:32 +00:00
Treehugger Robot
fc9ba206e4 Merge "Minor fixes." 2021-06-07 16:41:23 +00:00
Alan Stokes
3b88598cff Minor fixes.
Fix 2 small memory leaks.

Remove now-redundant cast.

Test: atest -p
Change-Id: Icf37fec3b5d6e138671176310d85afda29807ed8
2021-06-07 15:33:05 +01:00
Treehugger Robot
414f22ccae Merge "Keystore 2.0 certificate utils: Set time by string." am: fbeb0a69bc
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1727331

Change-Id: I6c026562249c74af478ea9040cef3e91cc04cf12
2021-06-07 09:50:18 +00:00