Commit graph

2064 commits

Author SHA1 Message Date
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
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
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
eacdd0e75b Merge "Add generated form AIDL interface sources." 2020-08-14 02:03:19 +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
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
9ce48febac Merge "Log keystore key attestation events using statsd." 2020-08-12 17:13:40 +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
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
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
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
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
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
Treehugger Robot
9cc2e83059 Merge "credstore: Don't require credentials to use ACP ids starting at 0." 2020-07-13 16:33:27 +00:00
David Zeuthen
5263000348 credstore: Don't require credentials to use ACP ids starting at 0.
This fixes a bug in credstore where it only worked if a credential
used ACP ids starting at zero and upwards (e.g. no holes). This is not
a reasonable requirement, it just happened to be a bug which wasn't
triggered because all CTS tests uses identifiers starting at 0 with
no holes.

This bug-fix is merged along with a new CTS test to check this bug no
longer exists.

Bug: 160966911
Test: atest android.security.identity.cts
Test: New CTS test testProvisionAcpIdNotStartingAtZero
Change-Id: I58595e6bf5f3ca3f82ebe9291fde54b7cf11e0dd
2020-07-10 14:14:52 -04:00
Orion Hodson
c373ce2a88 Merge "Remove unused libnativehelper include" 2020-07-07 08:46:24 +00:00
Orion Hodson
45d12bd92b Remove unused libnativehelper include
Bug: 152482542
Test: build clean-up
Change-Id: Ibe4534362891201476ee31fee19663f9bc8e1410
2020-07-02 13:16:19 +01:00
Thiébaud Weksteen
ed2fe02dd0 Merge "Enable rustfmt for system/security" 2020-06-25 06:49:41 +00:00
Thiébaud Weksteen
4ca7152102 Enable rustfmt for system/security
The rustfmt configuration is linked to the default from
build/soong/scripts. This is similar to how clang-format is setup for
system/core.

Test: Added a commit with a bogus lib.rs and run repo upload.
  An error is returned by the rusfmt hook.
Bug: 157146658
Change-Id: If346bdd73c9cdd84c3cd98ed00b95ed9d790aa4f
2020-06-23 15:50:23 +02:00
Treehugger Robot
442727c6e8 Merge "Fix incorrect use of TEMP_FAILURE_RETRY" 2020-06-19 18:27:22 +00:00
Yi Kong
1bdb61e5fa Fix incorrect use of TEMP_FAILURE_RETRY
TEMP_FAILURE_RETRY expects an argument that returns -1 on temporary
failure, not a boolean.

Test: TreeHugger
Change-Id: If8cb4a440e909c4ed7cbfdd34454670b0d5ee045
Exempt-From-Owner-Approval: Janitorial fix
2020-06-19 18:27:11 +00:00
Treehugger Robot
e3421680c8 Merge "credstore: Never pass an empty challenge." 2020-06-05 13:36:47 +00:00
David Zeuthen
673c6ced22 credstore: Never pass an empty challenge.
Bug: 156911917
Bug: 158107945
Test: atest VtsHalIdentityTargetTest
Test: atest android.security.identity.cts

Change-Id: Ia274fcbaabb0c0ec7c884070eb30737dc236c064
2020-06-03 17:26:27 -04:00
Treehugger Robot
0137d70c1a Merge "keystore: Pass verification token to credstore along with requested auth token." am: 6a917e5245
Change-Id: Ieb4fc49601b843f2d745b7f5a49c23d32889cf6d
2020-05-11 19:30:43 +00:00
Treehugger Robot
6a917e5245 Merge "keystore: Pass verification token to credstore along with requested auth token." 2020-05-11 17:28:43 +00:00
David Zeuthen
59102f388f keystore: Pass verification token to credstore along with requested auth token.
This is needed because the Secure Areas backing the Identity
Credential HAL may exist in a different environment from where the
auth token is minted. In this case, the Secure Area needs a
verification token to make sense of the timestamp in the auth token.

Getting a verification token is an asynchronous operation so change
the binder method used by credstore to be asynchronous as well.

Bug: 156076333
Test: atest VtsHalIdentityTargetTest
Test: atest android.security.identity.cts
Change-Id: Id6cb6812a31d968069b7d72bd2b39b512d38d241
2020-05-08 11:30:49 -04:00
Bill Yi
8dcb508544 Merge "Merge android10-qpr2-s3-release to aosp/master - DO NOT MERGE" am: de087d8746
Change-Id: Ibcd786c392a17832803d11a5a680b8f433b587bd
2020-05-06 16:15:40 +00:00
Bill Yi
874e53d5ca Merge android10-qpr2-s3-release to aosp/master - DO NOT MERGE am: 3255773023
Change-Id: Ida9c4551add66f274b1d8db60af1ca23285f4d45
2020-05-06 16:15:34 +00:00
Bill Yi
de087d8746 Merge "Merge android10-qpr2-s3-release to aosp/master - DO NOT MERGE" 2020-05-06 15:59:08 +00:00
Dorin Drimus
22f7ffb0a5 Merge "Allow device properties attestation in attestKey" am: a2ff64573e
Change-Id: I50edab331353b9d1b865aa87cd8c827bfa49b64b
2020-05-06 08:15:27 +00:00
Dorin Drimus
a2ff64573e Merge "Allow device properties attestation in attestKey" 2020-05-06 08:04:07 +00:00
Dorin Drimus
2f43a6a754 Allow device properties attestation in attestKey
Allow base device properties that are not unique IDs and don't
require special permission to be attested from any process.

Test: atest CtsKeystoreTestCases
Bug: 152945378
Change-Id: I45eeda0eac725fd0ad28caf25a5a183fe117fabb
2020-05-05 19:19:24 +02:00
Bill Yi
3255773023 Merge android10-qpr2-s3-release to aosp/master - DO NOT MERGE
Change-Id: Ic781131f8d6c84feacd1df31c5dbdd5533c3f24c
2020-05-04 20:39:43 -07:00