Commit graph

2093 commits

Author SHA1 Message Date
Edman Anjos
ba9b7d32a7 Model KeyStore security level in keymaster worker
On certain device configurations the security level reported by the
Keymaster HAL differs from the security level understood in KeyStore.
Namely, on devices with only a software Keymaster, KeyStore will set it
in the TEE slot, and create a new in-process legacy Keymaster for the
software slot.

This change introduces a field to keymaster worker to represent the
security level that KeyStore understands this worker to operate on.

Bug: 167412989
Test: atest CtsKeystoreTestCases
Change-Id: Ifeaa4782913be45d89cdd175a02302c7dc318719
2020-09-02 19:11:37 +02:00
Treehugger Robot
ca543112cd Merge "Add derive macros to KeyDescriptor" 2020-08-26 17:34:43 +00:00
Treehugger Robot
826558a741 Merge "Update generated AIDL interface code." 2020-08-26 16:53:03 +00:00
Janis Danisevskis
8581d1f407 Add derive macros to KeyDescriptor
Change-Id: I8c02b504c7465c5057d5b5588e8f23724300921f
2020-08-25 20:30:43 -07:00
Janis Danisevskis
45304a3376 Update generated AIDL interface code.
This updated the "generated" AIDL interface code to observe the changes
in the AIDL spec.

Test: None
Change-Id: I82d52df370c77208c5f94fb6fd053a122d80dcba
2020-08-25 20:30:43 -07:00
Treehugger Robot
e1d2f7801f Merge "Adding TEST_MAPPING to system/security/keystore" am: 3b7ee238bd
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1405550

Change-Id: I42d77a368d901a7610f85f073fd981907ad1a0ae
2020-08-20 16:58:39 +00:00
Treehugger Robot
3b7ee238bd Merge "Adding TEST_MAPPING to system/security/keystore" 2020-08-20 16:25:48 +00:00
Max Bires
788136d2fa Adding TEST_MAPPING to system/security/keystore
This file maps to about 4 minutes and 15 seconds of tests within
Keystore to be added to presubmit.

Bug: 158797959
Test: atest --test-mapping
Change-Id: I3cb6614d3f3b3fe43f326f50e2dfa915a1b81d21
2020-08-20 00:40:28 -07:00
Thiébaud Weksteen
385e8fc14c Merge "Update rustfmt options" am: 936a232dec
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1400155

Change-Id: Ie9547238607cba00481f2e62508903574c1f7dde
2020-08-19 15:41:40 +00:00
Thiébaud Weksteen
936a232dec Merge "Update rustfmt options" 2020-08-19 15:29:43 +00:00
Thiébaud Weksteen
2e749f97dd Update rustfmt options
The options for the rustfmt repo hook have been updated
in change 1399689 to support multiple commits. Update
the configuration for system/security.

Bug: 164111102
Test: repo upload
Change-Id: I516200c81f31a2b3891a229277ac1cd15e5738a9
2020-08-19 15:19:21 +00:00
Hasini Gunasinghe
06ab405ae9 Merge "Implement key_parameter in Rust." am: c4946ad435
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1350725

Change-Id: I458e9e07b1d1bcc0afe462f6513cd1378bd0ad64
2020-08-17 22:04:23 +00:00
Hasini Gunasinghe
c4946ad435 Merge "Implement key_parameter in Rust." 2020-08-17 21:51:45 +00:00
Hasini Gunasinghe
1248636ea9 Implement key_parameter in Rust.
This contains the basic functionality of key parameter.

Bug: 157664923
Test: atest --host keystore2_tests
Change-Id: I6eb325f6403c976c48c98394ad2aad625f59d2a1
2020-08-17 15:53:38 +00:00
Treehugger Robot
13bdce08c5 Merge changes Ibc7851ba,Ie743cff7 am: ce8c6af02a
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1391125

Change-Id: I531a97df9a4e216371c4bbff8a7c5b8129efac2a
2020-08-14 18:20:06 +00:00
Treehugger Robot
ce8c6af02a Merge changes Ibc7851ba,Ie743cff7
* changes:
  Cache the KeystoreKeyBackend with a lazy static.
  Implement Keystore 2.0 access control
2020-08-14 18:02:21 +00:00
Treehugger Robot
7320ca7f09 Merge "Add Debug, Copy, Clone, Eq, PartialEq to AidlResult." am: 0ce0bee197
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1395707

Change-Id: I09f513ef3a918fb7be9a981661410fa79109e251
2020-08-14 05:27:00 +00:00
Treehugger Robot
0ce0bee197 Merge "Add Debug, Copy, Clone, Eq, PartialEq to AidlResult." 2020-08-14 05:10:55 +00:00
Janis Danisevskis
4ad056ffad Cache the KeystoreKeyBackend with a lazy static.
This patch makes KeystoreKeyBackend Sync and uses a lazy static to cache
the back end in the permissions module.

Test: atest keystore2_test
Bug: 159466840
Change-Id: Ibc7851baede3506acbdf962e59c281fa16cfaf0e
2020-08-13 20:21:17 -07:00
Janis Danisevskis
78bd48c704 Implement Keystore 2.0 access control
This patch provides higher level functions to query Keystore 2.0
specific SEPolicy.
It provides abstractions for the permissions of the security classes
"keystore2" and "keystore2_key".
It also provides functions to check permission for general Keystore
requests as well as Keystore key and grant requests.

Bug: 159466840
Test: keystore2_test
Change-Id: Ie743cff76fe27f8ad96b2405f5d77b298ba35293
2020-08-13 20:21:17 -07:00
Treehugger Robot
662bfceef1 Merge "Add generated form AIDL interface sources." am: eacdd0e75b
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1393852

Change-Id: I238a392df84b7c2b1bf3e24f40e03fe96faf0891
2020-08-14 02:18:17 +00:00
Treehugger Robot
eacdd0e75b Merge "Add generated form AIDL interface sources." 2020-08-14 02:03:19 +00:00
Janis Danisevskis
f78a58222a Merge "Keystore libselinux rust bindings." am: f08ccb4637
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387138

Change-Id: I2e6b14b3548e234e8f73c9202b92f6923bd8427d
2020-08-13 23:05:17 +00:00
Janis Danisevskis
f08ccb4637 Merge "Keystore libselinux rust bindings." 2020-08-13 22:49:56 +00:00
Janis Danisevskis
ce99543bb0 Keystore libselinux rust bindings.
Provide safe wrappers around the libselinux API needed for keystore.
 * getcon
 * selinux_check_acces
 * selabel_lookup

Test: keystore2_selinux_test
Test: keystore2_selinux_rust_bindings_host_test
Bug: 159466840
Change-Id: I73b4aa2e1da9b477965b10927eba069e6346ce6e
2020-08-13 12:47:50 -07:00
Treehugger Robot
129415c842 Merge changes Ia4ad48fd,Idaf23a27,Ia4abebc0,Ie5ec091a am: d0282625db
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1385292

Change-Id: I3134a2489bdd606692497a80882750c10febe2b7
2020-08-13 19:23:01 +00:00
Treehugger Robot
d0282625db Merge changes Ia4ad48fd,Idaf23a27,Ia4abebc0,Ie5ec091a
* changes:
  Add rebind_alias.
  Persist database on disk.
  Add create_key_entry.
  Add (mostly) empty KeystoreDB struct.
2020-08-13 19:07:40 +00:00
Janis Danisevskis
be8ebf44df Add Debug, Copy, Clone, Eq, PartialEq to AidlResult.
This patch adds #[derive(Debug, Copy, Clone, Eq, PartialEq)]
to android.security.keystore2.Result.
We only add these features by demand until the modified code is reliable
generated form AIDL.

Test: None
Change-Id: I79970df31b759845c0ecd7026925792d6786741a
2020-08-13 10:52:42 -07:00
Janis Danisevskis
1fe113230e Add generated form AIDL interface sources.
This is a temporary solution until crates can be built form AIDL
directly.

Test: None
Change-Id: I36e8a65e58a464b98ee035a2b0e78f43c39719fc
2020-08-13 10:52:16 -07:00
Joel Galenson
33c04add76 Add rebind_alias.
Bug: 159370859
Test: atest keystore2_test
Change-Id: Ia4ad48fd576fc12b4bfe78bc09ed33c6cf0008a4
2020-08-12 17:54:22 -07:00
Joel Galenson
2aab443c58 Persist database on disk.
This adds support for persisting the database on disk.  Tests do not
do this to avoid race conditions (except for one test that ensures
that persistence works).

Bug: 159370859
Test: atest keystore2_test
Change-Id: Idaf23a271e269902f34c32509dfd923db08df067
2020-08-12 17:54:22 -07:00
Joel Galenson
0891bc1563 Add create_key_entry.
Bug: 159370859
Test: atest keystore2_test
Change-Id: Ia4abebc06d7d351678b524b4be3414c7b243d04a
2020-08-12 17:54:22 -07:00
Joel Galenson
26f4d0100d Add (mostly) empty KeystoreDB struct.
The KeystoreDB struct contains the interface with sqlite.

This commit introduces the KeystoreDB object and a sqlite connection
but does not add any operations.

Bug: 159370859
Test: atest keystore2_test
Change-Id: Ie5ec091a01d25ecd520ac29be67117cc3c3fd83c
2020-08-12 17:54:20 -07:00
Hasini Gunasinghe
9b9be9863e Merge "Log keystore key attestation events using statsd." am: 9ce48febac
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1347802

Change-Id: Idf9c442987a9a7fa4361911bdbf20afaf8395a2f
2020-08-12 17:38:41 +00:00
Hasini Gunasinghe
9ce48febac Merge "Log keystore key attestation events using statsd." 2020-08-12 17:13:40 +00:00
Treehugger Robot
b7d4af86ad Merge "Log keystore key operation events using statsd." am: 54c295ccab
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1334294

Change-Id: I687b3530e2ca0e954a21d82b64a6c6607b102623
2020-08-12 16:29:45 +00:00
Hasini Gunasinghe
8c8c2d4676 Log keystore key attestation events using statsd.
This is the third CL on sending keystore logging to statsd.
This creates the logs for key attestation events.
Test: Adding tests for logging is yet to be decided.
Bug: 157664923
Merged-In: I412ac59fd6bb2dbcb380f8579740d02ce2fd8790
Change-Id: I16cac8c4ee950adc330659dcb648052e8b2b41a2
2020-08-12 16:19:11 +00:00
Treehugger Robot
54c295ccab Merge "Log keystore key operation events using statsd." 2020-08-12 15:59:09 +00:00
Hasini Gunasinghe
242460eac7 Log keystore key operation events using statsd.
This is the second CL on migrating keystore logging to statsd.
This migrates the logging for key operation events.
Three new ResponseCodes are added for the logging purpose of the
	abort operations.

Test: Adding tests for logging is yet to be decided.
Change-Id: Iede72341b0f4c80199c9e16cef96a5d98bca8754
Merged-In: I68c1d89beeb733e4b6ba493b8d95935b7e73df60
2020-08-12 15:11:11 +00:00
Hasini Gunasinghe
0040637e44 Merge "Log keystore key creation events using statsd." am: 0781274cd9
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1393656

Change-Id: Ice464ef5c1a5368bf11f49a70c48f29252d37fe9
2020-08-10 15:23:53 +00:00
Hasini Gunasinghe
0781274cd9 Merge "Log keystore key creation events using statsd." 2020-08-10 15:09:49 +00:00
Hasini Gunasinghe
4e55c2f279 Log keystore key creation events using statsd.
This is the first CL on migrating keystore logging to use statsd.
This migrates the logging for key creation events
	(generation/import).
A work-around is implemented to handle repeated fields via bitmaps
	because statsd does not support repeated fields as of now.

Test: Adding tests for logging is yet to be decided.
Bug: 157664923
Change-Id: Id23724cfbd21dca8ef5fd77e5712c0bc2e727f4b
Merged-In: Id23724cfbd21dca8ef5fd77e5712c0bc2e727f4b
2020-08-06 13:52:36 -07:00
Treehugger Robot
7b65a44a9a Merge "Keystore 2.0 error module" am: dc246a01c1
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387139

Change-Id: Ib4e1817c0cd193c9947d1b0c9a604915d3e1afb3
2020-08-06 18:35:53 +00:00
Treehugger Robot
dc246a01c1 Merge "Keystore 2.0 error module" 2020-08-06 18:21:15 +00:00
Janis Danisevskis
7d77a7604f Keystore 2.0 error module
This patch provides some convenience methods for error handling in
Keystore 2.0. Specifically, a way to convert errors into messages to the
client and logging errors.

Test: keystore2_test
Bug: 159378374
Change-Id: Ifa6b5745533863bfd76319bc991748a47453d31e
2020-08-05 16:13:24 -07:00
Treehugger Robot
13ab0f6d99 Merge "Add placeholder for types generated from AIDL" am: eb9bee159f
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387137

Change-Id: I7202bb191489af46ee1be84cec5271bd56bc75ac
2020-08-05 20:26:09 +00:00
Treehugger Robot
eb9bee159f Merge "Add placeholder for types generated from AIDL" 2020-08-05 20:05:57 +00:00
Janis Danisevskis
652f38183d Add placeholder for types generated from AIDL
Test: None
Bug: 160623310
Change-Id: Ib16003543c416010edf17ee7659033434d70c0f3
2020-08-04 23:29:51 +00:00
Treehugger Robot
540936b9cc Merge "Add empty keystore2 crate" am: f7ee95d340
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387136

Change-Id: Iade99f7b798cd80778c5b10483d77752ee8726d8
2020-08-04 21:01:49 +00:00
Treehugger Robot
f7ee95d340 Merge "Add empty keystore2 crate" 2020-08-04 20:31:48 +00:00