Commit graph

2104 commits

Author SHA1 Message Date
Treehugger Robot
1fe037562b Merge "Revise database initialization." 2020-09-03 18:55:18 +00:00
Treehugger Robot
5061b81606 Merge "Change error.rs to use generated types." 2020-09-03 17:05:36 +00:00
Janis Danisevskis
4df44f4fca Revise database initialization.
Initializing the Keystore 2.0 database will now open the files
persistent.sql and perboot.sql. Tables are created, if they don't
exist, once per service startup instead of on every connection
instantiation. In the test situation we make use of the module
private visibility to create in-memory test databases or attaching
to a set of temporary files.

Test: keystore2_test
Bug: 159370859
Change-Id: I88594dabc72483779d980e81dbc05f2b7a687437
2020-09-03 08:52:32 -07:00
Janis Danisevskis
e24f347d2f Change error.rs to use generated types.
This patch also removes AidlResult form the error module.
The new version of the Keystore 2.0 AIDL spec requires that ResponseCode
and ErrorCode will be returned as service specific error, instead of the
Result type.

Test: keystore2_test
Change-Id: I6f730b282c84abc8be2e693e5d2c7053648d7588
2020-09-03 08:52:30 -07:00
Treehugger Robot
5de2d3086d Merge "Slightly cleanup KeyParameter error handling." 2020-09-03 15:40:33 +00:00
Janis Danisevskis
21e53ab0ff Merge "Keystore 2.0 permissions.rs: Use generated aidl types." 2020-09-03 15:33:32 +00:00
Joel Galenson
5c0ec0d83c Slightly cleanup KeyParameter error handling.
Test: keystore2_test
Change-Id: I06fb3ba134337e989b80acb0616a9f1eaf566069
2020-09-02 14:24:30 -07:00
Janis Danisevskis
1b3a6e25da Keystore 2.0 permissions.rs: Use generated aidl types.
Modify permissions.rs to use generated aidl types instead of
placeholders.

Test: keystore2_test

Change-Id: Ia6bcc9cff714a5839f0d2391c30c287e4e4cbadf
2020-09-02 14:13:22 -07:00
Hasini Gunasinghe
a2716509a1 Merge "Implement key_parameter conversion from/to rusqlite storage." 2020-09-02 21:10:58 +00:00
Hasini Gunasinghe
af99366934 Implement key_parameter conversion from/to rusqlite storage.
This implements conversion methods on top of basic
keyparameter implementation in aosp/1350725

Bug: 159722691, 159723797, 161798431
Test: atest --host keystore2_tests.
Change-Id: I1457ae4cf4336ebc5bff2645bca55ad285a4449c
2020-09-02 19:24:34 +00:00
Treehugger Robot
fd13bc1fe6 Merge "Add getpidcon to libselinux bindings and fix a typo." 2020-09-02 18:01:53 +00:00
Janis Danisevskis
63c4fb0df6 Add getpidcon to libselinux bindings and fix a typo.
Bug: 158500146
Test: None
Change-Id: Ia5e58933eff3766e2aa0a7b072107aeec294aa2f
2020-09-02 09:52:17 -07: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