Commit graph

2365 commits

Author SHA1 Message Date
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
1eb1a3394b Merge "Keystore 2.0 error module" am: dc246a01c1 am: 7b65a44a9a am: e5d718163f
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387139

Change-Id: I3c023063eff938812d7001d621d027b81572f4c8
2020-08-06 19:13:20 +00:00
Treehugger Robot
e5d718163f Merge "Keystore 2.0 error module" am: dc246a01c1 am: 7b65a44a9a
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387139

Change-Id: I8480f50d43198bd6c83866f55229e402e143414f
2020-08-06 18:55:35 +00: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
6739c3705f Merge "Add placeholder for types generated from AIDL" am: eb9bee159f am: 13ab0f6d99 am: 1c74e071f1
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387137

Change-Id: I5f9f562e215f102eba96d16e4a6c411a184adb5d
2020-08-05 21:18:15 +00:00
Treehugger Robot
1c74e071f1 Merge "Add placeholder for types generated from AIDL" am: eb9bee159f am: 13ab0f6d99
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387137

Change-Id: I5c4f91c161f75961f121f7e6739fbe754284bc35
2020-08-05 20:53:29 +00: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
ce0312a4e6 Merge "Add empty keystore2 crate" am: f7ee95d340 am: 540936b9cc am: 3b997f0d2a
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387136

Change-Id: I16ca58573c9730b1a1ef250adedfec2275925ddf
2020-08-04 21:39:23 +00:00
Treehugger Robot
3b997f0d2a Merge "Add empty keystore2 crate" am: f7ee95d340 am: 540936b9cc
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1387136

Change-Id: I2db63fb772ffa33dc2bce9618c024b6163bf7b28
2020-08-04 21:18:33 +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
Janis Danisevskis
43c8971a3c Add empty keystore2 crate
Adds an empty crate with a build config for libkeystore2 and the
keystore2 test.

Also add a TEST_MAPPING file setting up keystore2_test as presubmit
test.

Bug: 160623310
Test: keystore2_test
Change-Id: I2cda9a74a43422453cf5d1d44867107c9f0292bf
2020-08-04 01:42:50 +00:00
Treehugger Robot
86dc34ce54 Merge "Switch from count to N for template due to ambiguity with std::count" am: 3db19cfa0b am: 2324c8b96c am: eca147a17b
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1363328

Change-Id: I52e797c1dd124563dad22d7dbe746ffee7c1e32c
2020-07-24 19:33:08 +00:00
Treehugger Robot
eca147a17b Merge "Switch from count to N for template due to ambiguity with std::count" am: 3db19cfa0b am: 2324c8b96c
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1363328

Change-Id: I27a7b07d5057b7f936798dc6891984457f7304e5
2020-07-24 19:13:05 +00:00
Treehugger Robot
2324c8b96c Merge "Switch from count to N for template due to ambiguity with std::count" am: 3db19cfa0b
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1363328

Change-Id: Ic6c23ecb8804ac4099c60ab5be7b241079117310
2020-07-24 18:39:44 +00:00
Treehugger Robot
3db19cfa0b Merge "Switch from count to N for template due to ambiguity with std::count" 2020-07-24 18:27:53 +00:00
Stephen Hines
8b68026faa Switch from count to N for template due to ambiguity with std::count
Recent versions of Clang will flag this use of `count` in namespace
`std` as ambiguous due to the existence of `std::count`. To remove this
problem, we can switch to the commonly used `N` for array sizes.

Bug: http://b/155835175
Test: m with aosp_blueline
Change-Id: I983180b6e2e94dadb095f531e13ea415468ee104
2020-07-15 18:12:36 -07:00
Automerger Merge Worker
b83d98d950 Merge "[automerger skipped] credstore: Don't require credentials to use ACP ids starting at 0. am: 969d3803c8 am: 764af005ee -s ours" into rvc-d1-dev-plus-aosp 2020-07-14 18:37:33 +00:00
David Zeuthen
d744adaf0c [automerger skipped] credstore: Don't require credentials to use ACP ids starting at 0. am: 969d3803c8 -s ours am: a8e4c957bf -s ours
am skip reason: Change-Id I58595e6bf5f3ca3f82ebe9291fde54b7cf11e0dd with SHA-1 5263000348 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/12141145

Change-Id: I1e3408aa0a7c2f367143df99efd3836415e5e93e
2020-07-14 18:37:22 +00:00
David Zeuthen
752152eb20 [automerger skipped] credstore: Don't require credentials to use ACP ids starting at 0. am: 969d3803c8 am: 764af005ee -s ours
am skip reason: Change-Id I58595e6bf5f3ca3f82ebe9291fde54b7cf11e0dd with SHA-1 5263000348 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/12141145

Change-Id: I48f6450589e81989c66a2e522bf89445d1c188bc
2020-07-14 18:37:19 +00:00
David Zeuthen
764af005ee credstore: Don't require credentials to use ACP ids starting at 0. am: 969d3803c8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/12141145

Change-Id: I79456d9543c19919f5d1f063a3fcf3ef1a72c535
2020-07-14 18:36:50 +00:00
David Zeuthen
a8e4c957bf [automerger skipped] credstore: Don't require credentials to use ACP ids starting at 0. am: 969d3803c8 -s ours
am skip reason: Change-Id I58595e6bf5f3ca3f82ebe9291fde54b7cf11e0dd with SHA-1 5263000348 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/12141145

Change-Id: Ibd6ee7bf201a920e72602010bef128083f235453
2020-07-14 18:36:36 +00:00
Treehugger Robot
1c30a57fc2 Merge "credstore: Don't require credentials to use ACP ids starting at 0." am: 9cc2e83059 am: 8b10eced4b am: df1e99225b
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1360881

Change-Id: I7cec3b1c471e08b8c9601ff09d0c4911df75c208
2020-07-13 17:26:44 +00:00