Commit Graph

1076 Commits

Author SHA1 Message Date
David Drysdale
acb80cfdf2 KeyMint: add VTS test with all IDs am: ef1123b24e
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3106417

Change-Id: Icfc31847731c3ca48492234751033d4be8ada033
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-31 12:19:59 +00:00
David Drysdale
ef1123b24e KeyMint: add VTS test with all IDs
Add a test that includes all of the device IDs for attestation, which
helps to check whether the emitted extension is including everything in
the correct order.

(This is already tested in CTS since aosp/2650044)

Also fix test of first API level to use `get_vsr_api_level` helper.

Test: VtsAidlKeyMintTargetTest
Test: with/without KeyMint hacked to emit tags in wrong order
Change-Id: Ic6e489aa99c773d794ad8cbddbe5153b1a145ea5
2024-05-31 12:05:04 +01:00
Treehugger Robot
14ae5a614b Merge "Added keymint_authSet_fuzzer" into main am: 7884619140
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3066744

Change-Id: I9e5ef4c4fabd7025f49829dcc6d1982342685920
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-28 08:41:50 +00:00
Treehugger Robot
7884619140 Merge "Added keymint_authSet_fuzzer" into main 2024-05-28 08:24:05 +00:00
Treehugger Robot
6707c6716b Merge "Added keymint_attestation_fuzzer" into main am: 02a086bdaa
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3066743

Change-Id: Id5c46cf92626e9f9ee13c3644b0128306dc09281
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-28 07:02:14 +00:00
Treehugger Robot
02a086bdaa Merge "Added keymint_attestation_fuzzer" into main 2024-05-28 06:45:29 +00:00
Xin Li
64e598ce2b Merge Android 24Q2 Release (ab/11526283) to aosp-main-future
Bug: 337098550
Merged-In: I53a278f1317f5307441103dc42dc5be6f20d7075
Change-Id: I3a53ebf7339cdb886d3c1b733b8eee1847f8832a
2024-05-24 08:28:04 -07:00
David Drysdale
fd7119ea67 Merge "Delete standard output in VtsAidlKeyMintTargetTest" into main 2024-05-17 05:59:57 +00:00
Alice Wang
46ff286f6d Run VtsHalRemotelyProvisionedComponentTargetTest only on V+ devices
Bug: 340188780
Test: atest VtsHalRemotelyProvisionedComponentTargetTest
Change-Id: Id20a01b23324eb46620d96bd29c30b8cf9acd162
2024-05-15 15:27:26 +00:00
Huang Rui
ca3ea117ef Delete standard output in VtsAidlKeyMintTargetTest
The Done flag of VtsAidlKeyMintTargetTest is false during running
the module with ‘--collect-tests-only’ because it uses standard
output to print logs.

Bug: 340576534
Test: run vts -m VtsAidlKeyMintTargetTest --collect-tests-only

Change-Id: I3d81f7e59b6189fab1b146320263509f2694c11e
Signed-off-by: Huang Rui <rui1.huang@intel.com>
Signed-off-by: Liu Kai <kai1.liu@intel.com>
2024-05-15 11:42:59 +01:00
Akhilesh Sanikop
0e568bc8e5 Added keymint_authSet_fuzzer
exec/s: 490
Test: ./keymint_authSet_fuzzer
Bug: 337985606

Change-Id: I47ee42e6e97b98110bab8f923a94ed7b6e8b992d
2024-05-13 23:47:19 +05:30
Akhilesh Sanikop
007129a7fd Added keymint_attestation_fuzzer
exec/s: 2
Test: ./keymint_attestation_fuzzer
Bug: 337985606

Change-Id: I2c0d56e1af97190a5eb06a34e15bcd93123f39a6
2024-05-13 23:46:36 +05:30
A. Cody Schuffelen
fbc3089310 insecure keymint: in-process initialization ordering
This creates an ordering of

1. In-memory HALs are initialized
2. Secure AIDL HALs are exposed

There are some dependencies on the information, e.g.

Boot info:
https://cs.android.com/android/platform/superproject/main/+/main:system/keymint/ta/src/keys.rs;l=705;drc=72ed18b226a9944330ecd97d776d57ea1b2eb9e8
https://cs.android.com/android/platform/superproject/main/+/main:system/keymint/ta/src/lib.rs;l=356;drc=4f8cad1bf0b3392414e5735b95a7c5d80d64d6e6
https://cs.android.com/android/platform/superproject/main/+/main:system/keymint/ta/src/rkp.rs;l=75;drc=747e5931be387fb600f6865d2308390646243610

HAL info:
https://cs.android.com/android/platform/superproject/main/+/main:system/keymint/ta/src/rkp.rs;l=79;drc=747e5931be387fb600f6865d2308390646243610

Bug: b/339121782
Test: launch_cvd --resume=false --secure_hals=oemlock:guest_insecure_keymint:guest_insecure_gatekeeper
Change-Id: Ifbe8655bf14c248e886725217d261dae5458e15f
2024-05-07 16:56:42 -07:00
Seth Moore
8e57f5e434 Fix formatting around rkp-vm tag
Change-Id: I5d073427204596bc86e11d550e86da4c56745f72
2024-04-29 19:04:20 +00:00
David Drysdale
b2adc861ee Merge "KeyMint: more warnings around non-secure test impl" into main 2024-04-29 07:25:08 +00:00
David Drysdale
33a132f13f KeyMint: more warnings around non-secure test impl
Make it clearer that the default implementation is non-secure in
various ways, most notably because the TA code is running in-process
in the HAL service.

Bug: 314513765
Test: VtsAidlKeyMintTargetTest
Change-Id: I83509110c32a4df8df6c0b288d14659e022442ff
2024-04-29 07:09:34 +01:00
David Drysdale
b4598740de KeyMint: test for unique HMAC results
Bug: 218713582
Test: VtsAidlKeyMintTargetTest
Change-Id: I5babfa67e707dc1bf15dd40b1ee4c8c8b97f44a7
2024-04-25 10:00:05 +01:00
A. Cody Schuffelen
097e625335 C++ AIDL on-device GateKeeper / SharedSecret impl
Because Keystore2 always requires valid auth tokens for user keys, this
copies and extends the existing in-guest GateKeeper implementation to
negotiate a shared secret key with Keymint in order to generate a
session key for signing auth tokens.

This implementation also uses AIDL rather than HIDL to interact with the
framework. It's also packaged in an APEX.

The files are cobbled together from a few sources:

- SoftGateKeeper.h is based on hardware/interfaces/gatekeeper/1.0/software/SoftGateKeeper.h
- GateKeeper.{cpp,h} are based on device/google/cuttlefish/guest/hals/gatekeeper/remote/remote_gatekeeper.{cpp,h}
- SharedSecret.{cpp,h} are based on device/google/cuttlefish/guest/hals/keymint/remote/remote_shared_secret.{cpp,h}
- Apex files are based on device/google/cuttlefish/guest/hals/keymint/rust/

Keymint modifications to use BOOT_TIME are lifted from

https://android-review.git.corp.google.com/c/platform/hardware/interfaces/+/2856649/6..8/security/keymint/aidl/default/ta/clock.rs#38

Bug: 332376454
Change-Id: I81845d5e6370bdddb1a24d67437964e03a5fb243
Test: Run with rust-nonsecure keymint on Cuttlefish
2024-04-11 13:53:32 -07:00
Seth Moore
fae563acb0 Merge "Allow RKP-only devices to pass keymint VTS" into main 2024-04-09 15:31:26 +00:00
David Drysdale
61c9ab4d87 Merge "Make batch attestation keys/certs optional" into main 2024-04-09 09:11:54 +00:00
Nikolay Elenkov
6e71b471a9 Merge "Enable Java backend for ISecretKeeper" into main 2024-04-09 01:59:35 +00:00
Seth Moore
c5c52ce1d3 Allow RKP-only devices to pass keymint VTS
Add test paths for HALs that are RKP-only so that they may pass tests.

Fix up a few tests that were just being skipped for RKP-only HALs.

Test: ran VTS against cuttlefish with no factory key
Bug: 329409739
Change-Id: I5400874dd2f9885c061970a30ea44985353d23ed
2024-04-08 12:38:20 -07:00
David Drysdale
fe5f33a61e Make batch attestation keys/certs optional
Test: VtsKeyMintTargetTest
Bug: 329399923
Bug: 329269183
Change-Id: I4ef49fcbda7a69ea5623c084e276eb64d34c5813
2024-04-05 16:54:31 +00:00
Charisee
5fc736d96d Update needed for Rust v1.77.1
error: field `0` is never read
  --> hardware/interfaces/security/keymint/aidl/default/main.rs:38:24
   |
38 | struct HalServiceError(String);
   |        --------------- ^^^^^^
   |        |
   |        field in this struct
   |
   = note: `HalServiceError` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(dead_code)]`
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
38 | struct HalServiceError(());
   |                        ~~

error: aborting due to 1 previous err


Bug: http://b/330185853
Test: ./test_compiler.py --prebuilt-path dist/rust-dev.tar.xz  --target aosp_cf_x86_64_phone --image
Change-Id: I57f3bd1d702c97929f5fd34f909aa72aa2f2ba02
2024-04-03 20:05:19 +00:00
Treehugger Robot
d741ab8a51 Merge "Package the rust_nonsecure keymint default HAL in an APEX" into main 2024-03-30 10:06:52 +00:00
Treehugger Robot
86d8bf593a Merge "Remove unnecessary "_external" suffix from libcppbor" into main 2024-03-29 21:18:28 +00:00
A. Cody Schuffelen
895ba8bdfa Package the rust_nonsecure keymint default HAL in an APEX
This will make it easier to swap in and out with the Cuttlefish remote
implementation.

Bug: 331474817
Test: m com.android.hardware.keymint.rust_nonsecure
Change-Id: I0e9a350b62a90ef6126db109195e19b4181d0cf8
2024-03-29 11:48:31 -07:00
Shawn Willden
98125926c1 Remove unnecessary "_external" suffix from libcppbor
Test: Build
Change-Id: Ied163d1f40c3b86d7b85cae1700310f5cb674e2d
2024-03-28 20:42:34 -06:00
Shawn Willden
deaa5dd808 Remove reference to factory reset of K
The ISharedSecret.aidl description of the pre-shared secret K
mentioned that K was set up during factory reset.  While that could be
done, it is almost never done; most OEMs inject K in the factory.
Removed the reference to setup in factory reset to reduce confusion.

Test: N/A, comment-only change
Change-Id: Idbbd5a8d64197ef4713a75075a9730d06162ad05
2024-03-29 01:22:06 +00:00
Charisee
c3a74935a1 Update needed for Rust v1.77.0
error: field `0` is never read
  --> hardware/interfaces/security/authgraph/default/src/main.rs:34:24
   |
34 | struct HalServiceError(String);
   |        --------------- ^^^^^^
   |        |
   |        field in this struct
   |
   = note: `HalServiceError` has derived impls for the traits `Clone` and `Debug`, but these are intenti
onally ignored during dead code analysis
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(dead_code)]`
help: consider changing the field to be of unit type to suppress this warning while preserving the field
 numbering, or remove the field
   |
34 | struct HalServiceError(());
   |                        ~~

error: aborting due to 1 previous error


Test: ./build.py --lto thin

bug: http://b/330185853
Change-Id: I08b79176fb5edea9e24990e4884e521c24660d68
2024-03-27 22:58:56 +00:00
David Drysdale
c8b02ff6e7 Merge "Secretkeeper: more VTS tests" into main 2024-03-27 12:22:06 +00:00
Nikolay Elenkov
03cf716392 Enable Java backend for ISecretKeeper
Bug: 324321147
Test: Manual -- trigger factory reset, confirm ISecretKeeper.deleteAll()
is being called in Trusty logs.

Change-Id: I0f033b53e83ff549f80271ba4a6ebeabac3db922
2024-03-27 06:51:05 +00:00
A. Cody Schuffelen
ddc6a8dbdf Fix .rc file for keymint-service.nonsecure
This target was using the same `.rc` as the keymint-service target,
though it had a different name.

Bug: 331474817
Test: LOCAL_KEYMINT_PRODUCT_PACKAGE=android.hardware.security.keymint-service.nonsecure m && launch_cvd --noresume --secure_hals=keymint,oemlock
Change-Id: I0f744b75e451f6780d8f6c9bddbd5ea80c579a20
2024-03-26 15:40:37 -07:00
Andrew Scull
2146152db9 Require proper DICE if StrongBox is present
If a decice provides a StrongBox KeyMint instance then the default IRPC
instance is required to use a proper, non-degenerate DICE chain.

Expose a function to check whether the CSR contains a proper DICE chain
and use that from VTS to implement the test.

Bug: 302204396
Test: atest VtsHalRemotelyProvisionedComponentTargetTest
Change-Id: I90cf070bc2279fc52e0a8e7fd0039d3fdb68c1d7
2024-03-25 18:16:24 +00:00
David Drysdale
5f4493d75b Secretkeeper: more VTS tests
Add tests for:
- large number of session creations
  - also use a bigger identity, to better simulate real use
- attempt to retrieve a secret with an incorrect identity

Test: VtsSecretkeeperTargetTest (shiba)
Bug: 327526008
Change-Id: I8dddf643d03a8fb679511564cb03c2248477c116
2024-03-14 15:00:37 +00:00
Tri Vo
b02ff886be Tests for imported wrapped RSA and EC keys
Only applies for devices on VSR API level 35 and above, so that existing
devices which previously passed VTS should not need to pass the new
tests.

Bug: 292534977
Test: VtsAidlKeyMintTargetTest
Change-Id: I8281c3cebf05795e3f9a1ed2b112fc149d8a104c
2024-03-14 13:04:16 +00:00
Seth Moore
fcff3dd6c7 Update docs to use the correct canonicalization reference
Bug: 325906414
Change-Id: I1eb5bc52df4627c713bb2611101e2c3238ac7b9d
2024-03-08 14:10:49 +00:00
David Drysdale
764199f2c9 Reinstate C++ KeyMint impl as default
This is a partial revert of aosp/2856649, changeID
Ia450e9a8f2dc530f79e8d74d7ce65f7d67ea129f, because it turns out
that there are Wear devices that are using the default implementation
(but which are not covered by TreeHugger/presubmit).

It restores the C++ implementation for KeyMint as
android.hardware.security.keymint-service, but preserves the Rust
libraries that were moved here in that CL as a subsequent CL
(aosp/2852598) means that Cuttlefish now uses the libraries here.

Test: VtsAidlKeyMintTargetTest on Cuttlefish
Bug: 328251011
Bug: 314513765
Change-Id: Id6f3491144588e418cd6e18e51262fe839bfdf39
2024-03-07 10:33:22 +00:00
David Drysdale
ea20772c42 Merge "KeyMint: add separator for debugging output" into main 2024-03-05 11:12:38 +00:00
David Drysdale
30196cf77c KeyMint: default to Rust reference implementation
Copy code that can be re-used from the Cuttlefish KeyMint
implementation, specifically from the following directories
under device/google/cuttlefish:

- HAL-side code from guest/hals/keymint/rust/
- TA-side code from host/commands/secure_env/rust/

Create a corresponding pair of libkmr_{hal,ta}_nonsecure libraries here.
The only changes to the copied code are:

- Convert `pub(crate)` to `pub` in `attest.rs`.
- Add some missing doc comments.
- Add comment noting need for SELinux permission to read ro.serialno.
- Add comment noting need for clock to be in sync with Gatekeeper.

(A subsequent CL aosp/2852598 adjusts Cuttlefish so that it uses the
copied modules here, and can remove the original copies.)

In addition to the moved code, the default implementation also needs
a new implementation of a monotonic clock, added here in clock.rs
using `std::time::Instant`.

With the new nonsecure HAL and TA libraries in place, implement the
default KeyMint HAL service using the former, and spin up a single
thread running a nonsecure TA using the latter.  Communicate between
the two via a pair of mpsc::channel()s.

Test: VtsAidlKeyMintTargetTest with normal Cuttlefish (all pass)
Test: VtsAidlKeyMintTargetTest with default/nonsecure impl (auth
      tests fail, but this is expected as Gatekeeper hasn't moved)
Bug: 314513765
Change-Id: Ia450e9a8f2dc530f79e8d74d7ce65f7d67ea129f
2024-03-01 07:20:57 +00:00
Devin Moore
9eec1433fa Merge "Vendor API level 202404 is now frozen" into main 2024-02-29 17:14:40 +00:00
David Drysdale
f3a4bea6df KeyMint: add separator for debugging output
When dumping attestation certificate chains with the --dump_attestations
option, add a separator between distinct chains to make them easier to
analyze.

Bug: 326564087
Test: VtsAidlKeyMintTargetTest
Change-Id: Ife19edfddef6c8cd26de9f9816c3c9bf65cbb929
2024-02-28 11:32:35 +00:00
Shikha Panwar
d840d11317 Merge "Sk VTS: Identity of Secretkeeper is same as in DT" into main am: d7f594dc4d am: 8a06fd4343
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2973515

Change-Id: I6b7d719c854071fa9ef06eb81815f06a9eccb221
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-27 16:03:30 +00:00
Shikha Panwar
d7f594dc4d Merge "Sk VTS: Identity of Secretkeeper is same as in DT" into main 2024-02-27 14:31:59 +00:00
Treehugger Robot
8fcf758544 Merge "Fixed issue converting Asn1 time to posix on 32-bit systems." into main am: 5c7dd08f12 am: 1cd5d233b6
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2977478

Change-Id: Ic0d8e0d1900eea7634cf9b2b0e42a2e8b809d5a2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-27 08:09:51 +00:00
Subrahmanya Manikanta Venkateswarlu Bhamidipati Kameswara Sri
b66a37a8e2 Fixed issue converting Asn1 time to posix on 32-bit systems.
Used ASN1_TIME_to_posix API instead of ASN1_TIME_to_time_t
to avoid integer overflow on 32-bit systems.

Bug: 325853206
Test: vts -m VtsAidlKeyMintTarget
Change-Id: I7a01a521d389482a61ad9974b7e40eaa099c3571
2024-02-26 19:23:44 +00:00
Shikha Panwar
0d286b3867 Sk VTS: Identity of Secretkeeper is same as in DT
Secretkeeper is expected to advertize its public key to Android via
Device tree node at /avf/reference/avf/ Check that the identity used
during AutGraph key exchange protocol with client is indeed this.

Test: #secretkeeper_check_identity on device with Sk/default instance
enabled
Bug: 291213394

Change-Id: I08815d75410fdd0c76d675c7cc9521abe0cda98b
2024-02-22 22:06:20 +00:00
Devin Moore
a8efdb127e Vendor API level 202404 is now frozen
Ignore-AOSP-First: VINTF 202404 Finalization
Bug: 279809333
Test: build
Change-Id: Ie6d38d27a287e258c30516e0030ad8c931d06432
2024-02-20 21:05:23 +00:00
Eric Biggers
b62bdd33be Merge "keymint: document deprecation of UNLOCKED_DEVICE_REQUIRED enforcement" into main am: 8c7558625f am: 1438394ac9
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2966026

Change-Id: I9cb9e8b2cf36fc8c60c0ff78a0a1f591f61ad4a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-20 20:11:19 +00:00
Eric Biggers
df32f52a47 keymint: document deprecation of UNLOCKED_DEVICE_REQUIRED enforcement
KeyMint enforcement of UNLOCKED_DEVICE_REQUIRED is broken, has never
been used, and cannot be fixed.  So, document that it does not need to
be implemented.  Also remove the VTS test for it, which was disabled.

UNLOCKED_DEVICE_REQUIRED remains supported in Keystore.

Bug: 321100166
Test: Build
Change-Id: If4d47ee49c9d4a595820cfceb0f5f3027f99ee9f
2024-02-16 20:28:17 +00:00