Commit graph

2757 commits

Author SHA1 Message Date
Bob Badour
4c7858c848 [LSC] Add LOCAL_LICENSE_KINDS to system/security
Added SPDX-license-identifier-Apache-2.0 to:
  fsverity_init/Android.bp
  identity/Android.bp
  keystore/tests/Android.bp
  keystore2/Android.bp
  keystore2/aaid/Android.bp
  keystore2/aidl/Android.bp
  keystore2/apc_compat/Android.bp
  keystore2/selinux/Android.bp
  keystore2/src/crypto/Android.bp
  keystore2/src/km_compat/Android.bp
  ondevice-signing/Android.bp
  provisioner/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  Android.bp
  keystore/Android.bp

Added SPDX-license-identifier-BSD to:
  keystore-engine/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Ic9e19695bd19c3f127dfd545df60e4c9df89af77
2021-02-14 10:37:25 -08:00
Treehugger Robot
1e283ee2f3 Merge "Added the deviceLocked and earlyBootEnded implementations to KeyMintDevice in km)compat. This fixes the build errors. Test: n/a Bug: b/179062062" 2021-02-13 22:11:52 +00:00
Chirag Pathak
d889aff463 Added the deviceLocked and earlyBootEnded implementations to KeyMintDevice in km)compat. This fixes the build errors.
Test: n/a
Bug: b/179062062

Change-Id: I7458faa917317612536d640f42372489d30d960f
2021-02-10 20:48:47 +00:00
Matthew Maurer
84a668248f Merge "keystore2: Use libbinder_rs Strong references for Binder objects" 2021-02-10 19:06:53 +00:00
Stephen Crane
221bbb5f39 keystore2: Use libbinder_rs Strong references for Binder objects
Update keystore2 to use libbinder_rs Strong<> and Weak<> references for
Binder objects rather than just Box<dyn Interface>.

Bug: 175584883
Test: atest keystore2_test
Change-Id: Ic234ce5ed007a265769a72043d77eb817a21b8ea
2021-02-09 18:20:36 -08:00
Treehugger Robot
2bb8575ea0 Merge "Keystore 2.0: Provide confirmation token to operation." 2021-02-09 21:23:50 +00:00
Treehugger Robot
4029fd3281 Merge "Keystore 2.0: Fixes in the legacy wrapper." 2021-02-09 21:23:10 +00:00
Janis Danisevskis
b1673db3e5 Keystore 2.0: Provide confirmation token to operation.
This patch connects the APC manager to the enforment module and
ultimately to the operation, so that the confirmation token can be
delivered to operations that require it.

Also fix a bug in apc_compat.rs.

Test: CtsVerifier
Change-Id: I69b6b08b10f51d255c2d70da3a6354b04f0ce801
2021-02-09 12:10:08 -08:00
Janis Danisevskis
3793a5e6f4 Keystore 2.0: Fixes in the legacy wrapper.
* Filter out invalid tags before passing them to the Keymaster device.
* Support negative timestamps for NOT_BEFORE/AFTER tags. Because the
  Keystore CTS test wants to create historic certificates predating
  Jan 1970.

Test: Keystore CTS tests.
Change-Id: I25a4440bf1318e9925f7a0c2ac481c29a56a412e
2021-02-09 12:00:12 -08:00
Treehugger Robot
1327bc99b4 Merge changes If75c941b,Ie410e2ab
* changes:
  Keystore 2.0: Fix import wrapped key.
  Keystore 2.0: Implement UNIQUE_ID permission check.
2021-02-09 02:08:13 +00:00
Treehugger Robot
55381c7e36 Merge changes I1bc496ec,I917afe34,If50eedf4,Ie002eb18
* changes:
  Keystore 2.0: Handle Keystore enforceable enforcement parameters.
  Keystore 2.0 legacy wrapper: Fix best padding candidate lookup.
  Keystore 2.0: Add error logging.
  Keystore 2.0: Filter tags on key generation and import.
2021-02-09 00:33:48 +00:00
Janis Danisevskis
ec18e4dfeb Keystore 2.0: Handle Keystore enforceable enforcement parameters.
KeyMint adds some new enforceable features. We don't want to confuse the
legacy backends, so we already filter them from the input parameters.
As a result they won't be included in the output key characteristics, so
in this patch we identify them and add them back in.

Test: N/A
Change-Id: I1bc496eca7d79aa1bb6dc2cfa7f0b3821969b401
2021-02-08 12:19:13 -08:00
Janis Danisevskis
2ce4d4fecf Keystore 2.0 legacy wrapper: Fix best padding candidate lookup.
Also add signature padding only if algorithm RSA was selected and add
Digest::None as viably selectable digest.

Test: atest android.keystore.cts.KeyPairGeneratorTest#testGenerate_RSA_ModernSpec_UsableForTLSPeerAuth
Change-Id: I917afe345c96f4f13fe7afc9430e621b3ba567bf
2021-02-08 12:16:49 -08:00
Janis Danisevskis
27fdaac42d Keystore 2.0: Add error logging.
Add logging in case of error in the legacy wrapper.

Test: N/A
Change-Id: If50eedf45d2c5cd34031e195dc22fa6f77ee61ee
2021-02-08 12:16:49 -08:00
Janis Danisevskis
d89dc1c569 Keystore 2.0: Filter tags on key generation and import.
Keystore 2.0 expects Keymint to perform key generation/import and
attestation in one opration. This means it passes all of the relevant
parameters to the generate/import functions. The legacy backends
might respond with an error if, say an attestation parameter is passed
to generateKey. So this wrapper filters the paramerers to not include
irrelevant parameters.

Test: Keystore CTS tests.
Change-Id: Ie002eb188e6ba2a47554c38b3225cdd9ce961136
2021-02-08 12:16:49 -08:00
Treehugger Robot
de483bef10 Merge "Keystore 2.0: Rename keystore2 enable property." 2021-02-08 20:04:38 +00:00
Janis Danisevskis
23606cc337 Merge changes Icc3bc610,I8ce3e315
* changes:
  Keystore 2.0: Add indexes to certain high traffic tables.
  Keystore 2.0: Poll on DB locked.
2021-02-08 18:27:17 +00:00
Janis Danisevskis
32adc7d500 Keystore 2.0: Fix import wrapped key.
Test: CTS test for wrapped key import.
Change-Id: If75c941b0ec5e5c1f12bc683f3568fba613c53fa
2021-02-08 09:11:51 -08:00
Janis Danisevskis
e766edca91 Keystore 2.0: Implement UNIQUE_ID permission check.
Gating UNIQUE_ID generation by sepolicy permision
keystore2_key:gen_uniqu_id

Test: atest android.keystore.cts.KeyAttestationTest#testEcAttestation_KeyStoreExceptionWhenRequestingUniqueId
Change-Id: Ie410e2abdf0d6b291c25d3cd393d40c25024ec9f
2021-02-08 09:11:51 -08:00
Janis Danisevskis
a543818e40 Keystore 2.0: Add indexes to certain high traffic tables.
This greatly improves the performance of Keystore 2.0.

Test: keystore2_test
Change-Id: Icc3bc610165e9258bb7d7233068b61c166e3d42a
2021-02-08 09:11:28 -08:00
Janis Danisevskis
66784c4628 Keystore 2.0: Poll on DB locked.
SQLite2 seems to hold a shared mutex while running the busy handler when
waiting for the database file to become available. This makes it
impossible to successfully recover from a locked database when the
transaction holding the device busy is in the same process on a
different connection. As a result the busy hander has to time out and
fail in order to make progress.

This patch replaces the default busy handler with one that times out
immediately. In addition all database accesses have been moved into
retry loops that handle the busy error which can occur at any time, not
only during begin or commit of a transaction. This assures that no
sqlite3 internal mutexes are held while waiting for the database to
become available.

The database interface had to change slightly to assure that all
database manipulations can be replayed and not data is lost.

A test has been added that makes sure that the correct error is caught,
and another test was added that produces a lot of concurrent database
manipulations and would easily trigger database busy errors.

Test: keystore2_test
Change-Id: I8ce3e3159b2356ace2b9f0ebdf074bbabc6612af
2021-02-08 09:11:28 -08:00
Janis Danisevskis
f49ca074c1 Merge "Keystore 2.0: Add support for the new CERTIFICATE_* tags." 2021-02-08 16:52:16 +00:00
Janis Danisevskis
2c08401f93 Keystore 2.0: Add support for the new CERTIFICATE_* tags.
Test: Keystore CTS tests
Change-Id: Ifbecd4517e8b6fb143283ed3f815aed4812a3c4a
2021-02-07 19:12:00 -08:00
Treehugger Robot
ae6899d2d9 Merge "Adding remote provisioning AIDL interface" 2021-02-06 01:20:34 +00:00
Treehugger Robot
0c7a5fd83b Merge "Adding remote provisioning functionality" 2021-02-06 01:20:34 +00:00
Janis Danisevskis
984658f806 Keystore 2.0: Rename keystore2 enable property.
Test: N/A
Bug: 160623310
Change-Id: Id8de044e4810fe39375a910b34bfeb2715251282
2021-02-05 12:25:39 -08:00
Treehugger Robot
01d8f1be2b Merge changes I98272fb0,I1ce8ca51
* changes:
  Keystore 2.0: No longer transition to database directory.
  Keystore 2.0: Make per boot database an in memory db.
2021-02-04 22:57:59 +00:00
Janis Danisevskis
3f2955c325 Keystore 2.0: No longer transition to database directory.
Keystore no longer transitions to the database directory as its working
directory. This allows keystore to start before data is mounted.

Test: keystore starts and early.
Change-Id: I98272fb0e97e8fe93eb87a657286681c78d28a60
2021-02-04 12:50:41 -08:00
Janis Danisevskis
b00ebd0c8c Keystore 2.0: Make per boot database an in memory db.
Test: keystore2_test
Change-Id: I1ce8ca517af2dc2777cbb23b52ea6a8df89cc99d
2021-02-04 12:50:41 -08:00
Max Bires
2b2e656418 Adding remote provisioning functionality
This commit provides the tables and database access functionality that
will be needed by Keystore to implement its portion of remote
provisioning.

Test: atest keystore2_test
Change-Id: I5b79b1df2896387511759c0a6fadca80edf528fc
2021-02-04 09:06:40 -08:00
Max Bires
148c08e1e7 Adding remote provisioning AIDL interface
This commit adds the AIDL interface required to use remote provisioning,
as well as the implementation.

Test: tbd
Change-Id: I28ade347a00210f4bc3b74664873c2cf5221adb0
2021-02-04 09:00:42 -08:00
Treehugger Robot
2b3ca3c367 Merge "Keystore 2.0: Adding uuid field to persistent.keyentry" 2021-02-03 05:57:13 +00:00
Max Bires
8e93d2be1e Keystore 2.0: Adding uuid field to persistent.keyentry
This change adds a uuid field to map keys to KM devices to the keyentry
table. For now, the security level reported by the KeyMint instance's
hardware info is uased as uuid until the hardware info returns an
actual uuid. This security level may differ from the security level
requested by keystore clients in some situations, e.g., when running a
pure software implementation or on chrome os.

Test: atest keystore2_test
Change-Id: I4b9556804eb6a435ac48d5929fc238e22c23d94d
2021-02-02 14:27:17 -08:00
Treehugger Robot
660cedaaea Merge "Keystore 2.0: Add Pure Certificate Entry suport." 2021-02-02 07:59:35 +00:00
Janis Danisevskis
377d1006de Keystore 2.0: Add Pure Certificate Entry suport.
Allow storing certificates without keys.
Also allow deleting subcomponents by setting corresponding arguments to
None.

Test: KeyStore CTS and keystore2_test
Change-Id: Ie3c937941c6dd6d4a43cd86273cce4f0d7880ca6
2021-02-01 22:35:36 -08:00
Treehugger Robot
df81f8e75b Merge "Add new SecurityLevel::KEYSTORE" 2021-02-02 06:13:07 +00:00
Janis Danisevskis
130c40fafc Merge "Keystore 2.0: Respect input consumed." 2021-02-02 06:00:34 +00:00
Janis Danisevskis
002891c342 Keystore 2.0: Respect input consumed.
Respect input consumed by KeyMint device and call update in a loop
until all input was consumed.

Test: Keystore CTS tests.
Change-Id: If7bcb019fe5f22d69e2d87d2ba56d597131e318c
2021-02-01 21:59:18 -08:00
Treehugger Robot
403808875b Merge "Specify version for aidl_interface explicitly" 2021-02-02 00:09:18 +00:00
Shawn Willden
a857a654d1 Add new SecurityLevel::KEYSTORE
We need a way to distinguish between tags that are enforced by KeyMint
with security level "SOFTWARE" and tags that are not enforced by
KeyMint but are expected to be enforced by KEYSTORE.

Test: VtsAidlKeyMintTargetTest
Change-Id: I8a88d661bca0125ee149276f6b9cb0017a1c9b12
2021-02-01 16:54:31 -07:00
Treehugger Robot
5318d3dc57 Merge "Keystore 2.0: Skip compat test if no legacy keymaster is available." 2021-02-01 23:36:00 +00:00
Janis Danisevskis
1291384d85 Keystore 2.0: Skip compat test if no legacy keymaster is available.
The km compatibility test only makes sense on devices that actually have
legacy keymaster. With this patch we skip all the tests if no connection
can be established.

Test: keystore2_km_compat_test
Change-Id: I6cfd52a0410fe1b13f5df4be11d23ef4ea223296
2021-02-01 13:51:50 -08:00
Treehugger Robot
07e6a52427 Merge "Keystore 2.0: Revise Legacy wrapper error handling" 2021-02-01 18:33:21 +00:00
Treehugger Robot
2de1313f53 Merge "Keystore 2.0: Fix permission tests." 2021-02-01 18:20:49 +00:00
Treehugger Robot
95eee225a4 Merge "Keystore 2.0: Install database busy handler." 2021-02-01 17:01:59 +00:00
Janis Danisevskis
a31dd9ef24 Keystore 2.0: Fix permission tests.
Some of the permission tests only pass on cuttlefish because its
system_server is permissive. This fix makes them pass on real devices.

Test: keystore2_test
Change-Id: I3cca0cf7ca30276eb75fa1d86a9243ee65d3d588
2021-02-01 08:17:42 -08:00
Janis Danisevskis
926a6c032f Keystore 2.0: Revise Legacy wrapper error handling
Now using mostly KeyMint error codes and a safe conversion function.

Test: keystore2_km_compat_test_cpp

Change-Id: I43ec848a8ee5544fcc8e79a4af0690e45bc28095
2021-01-31 22:41:04 -08:00
Janis Danisevskis
aea2734a7c Keystore 2.0: Install database busy handler.
Make keystore DB poll every 50us for the database lock.

Test: N/A
Change-Id: Ibb6c8d438e4b3d99d80671b6720baad23cc17a0d
2021-01-31 22:38:24 -08:00
Treehugger Robot
f3caf2698b Merge "Add AGREE_KEY operation for EC keys." 2021-01-28 13:08:43 +00:00
Treehugger Robot
13ffc59553 Merge "Keystore 2.0: Allow by key id usage of granted keys." 2021-01-27 02:29:21 +00:00