Commit graph

1027 commits

Author SHA1 Message Date
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
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
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
d7f594dc4d Merge "Sk VTS: Identity of Secretkeeper is same as in DT" into main 2024-02-27 14:31:59 +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
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
Ryan Prichard
01cf20d711 Replace std::basic_string_view<uint8_t> with std::span
In newer versions of libc++, std::char_traits<T> is no longer defined
for non-character types, and a result, std::basic_string_view<uint8_t>
is also no longer defined. See
https://discourse.llvm.org/t/deprecating-std-string-t-for-non-character-t/66779.

Bug: 175635923
Test: libkeymint_remote_prov_support_test
Change-Id: Ic373e0a3c081b996d4c81a9783103ae6406833f7
2024-02-12 20:34:20 -08:00
Subrahmanyaman
e1560216fe Test to validate a range of certificate validity times.
Bug: 280624515
Test: run VtsAidlKeyMintTarget
Change-Id: Id315c28e2ea114c5c39e235d3ee6be2a0d8bfa71
2024-02-12 15:25:53 +00:00
Aditya Choudhary
ad2ba1b851 [DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
go/new-android-ownership-model

Bug: 304529413
Test: N/A
Change-Id: Ic8c4bd6ac246e7efa98bbdaf822d12ae8e1230a5
2024-02-05 15:45:22 +00:00
Treehugger Robot
17aa36a60d Merge "Replace use of deprecated logging functions" into main 2024-02-01 17:36:36 +00:00
Shikha Panwar
36e66b72fe Merge "Expand DICE chain in VTS/test to contain arrays" into main 2024-02-01 16:06:36 +00:00
Shikha Panwar
9e15e5e01e Expand DICE chain in VTS/test to contain arrays
Include a list of subcomponents in AVB DiceChainEntry in the sample DICE
chain and include constraints on that in the sealing_policy.

Bug: 291238565
Test: VTS#secret_management_policy_gate
Change-Id: Id36ddf137bacf99c273b61c3136691426f2d5b34
2024-02-01 13:15:36 +00:00
Jeff Vander Stoep
e8934d0991 Replace use of deprecated logging functions
This is needed to upgrade the android_logger crate from 0.12.0
to 0.13.3.

with_max_level provides the same functionality as with_min_level.
The renaming is admittedly confusing, but the new name is accurate
and it makes sense that they deprecated and then removed the
previously poorly named with_min_level.

See crate documentation [1] and code [2].

[1]: https://docs.rs/android_logger/0.12.0/android_logger/struct.Config.html#method.with_min_level
[2]: https://docs.rs/android_logger/0.12.0/src/android_logger/lib.rs.html#227

Bug: 322718401
Test: build and run CF with the change.
Test: m aosp_cf_x86_64_phone
Change-Id: I0ca9596433967be70e9d55acb6cfbf9322741bf8
2024-01-31 10:49:31 +01:00
David Drysdale
c97055b9b6 Merge "Secretkeeper: test sealing policy update" into main 2024-01-30 07:46:46 +00:00
David Drysdale
5498cfa85a Secretkeeper: test sealing policy update
Test: VtsSecretkeeperTargetTest
Change-Id: Ib1d60dc2f80aa8b02011506af7e5c310ad92573a
2024-01-29 17:29:04 +00:00
Treehugger Robot
9ef5917d40 Merge "Sk VTS: Use libdice_policy_builder" into main 2024-01-27 17:52:53 +00:00
David Drysdale
88da778d2a Merge "KeyMint: show vbmeta digest values on mismatch" into main 2024-01-25 13:01:53 +00:00
David Drysdale
0ab3d97350 KeyMint: show vbmeta digest values on mismatch
Bug: 314044749
Test: VtsAidlKeyMintTargetTest
Change-Id: I0db1af44445fd5c73517a82eec9f3208fd305b21
2024-01-25 11:32:17 +00:00
David Drysdale
922a49f278 Merge "KeyMint: test HAL version matches feature" into main 2024-01-24 11:54:13 +00:00
Shikha Panwar
9eab79b8c9 Sk VTS: Use libdice_policy_builder
With libdice_policy being refactored, get VTS to use the builder
library.

Test: Built the test-suite
Bug: 291238565
Change-Id: I149ec1ba9ee66fd19cbf0d0a6f3baa12ea2474ed
2024-01-24 11:24:05 +00:00
Seth Moore
ec10c484b7 Fix incorrect code comment about keymint version
Test: No test, just a comment change
Bug: 321632558
Change-Id: I7f5db4959dd9e3bc598fa2939121f37b3f0abb04
2024-01-23 20:37:52 +00:00
David Drysdale
6c9bdb839f KeyMint: test HAL version matches feature
Test: VtsAidlKeyMintTargetTest
Bug: 304309651
Change-Id: I7e38c2ab3ff4f6b5f9035af865ca5ebe6ff24cc1
2024-01-23 10:05:55 +00:00
David Drysdale
b95093d640 Secretkeeper: add test CLI
Allows testing of secret persistence across reboot (and non-persistence
across factory reset).

Move some test code into a library for re-use.

Test: Manual
Change-Id: I23772692d2de652f6d4a8e5659186bd9c1c06b72
2024-01-17 10:44:19 +00:00
Andrew Walbran
48391231a2 Import macros via rdroidtest for consistency.
This is what we recommend in the documentation.

Test: atest VtsSecretkeeperTargetTest
Change-Id: I9155e8b0f8c58547cb63dd40cdbf9e2e39648d9c
2024-01-16 16:48:31 +00:00
Shikha Panwar
84187967cb VTS to use enum for MissingAction
ConstraintSpec constructor will take enum instead of boolean for missing
action.

Test: atest VtsSecretkeeperTargetTest
Bug: 291213394
Change-Id: I55fb0d8ef1fccca5feedf1fd368854ffb7eafaaf
2024-01-15 13:04:35 +00:00
Shikha Panwar
c6cf62d113 Merge "Sk VTS: Policy gating & Out of Seq req rejection" into main 2024-01-12 16:49:49 +00:00
Shikha Panwar
6d5bb1eeaf Merge "Secretkeeper: VTS to use dice_chain as identity" into main 2024-01-12 16:49:09 +00:00
Shikha Panwar
62b6504c33 Merge "InitialPayload of ExplicitKeyDiceCertChain" into main 2024-01-12 10:46:21 +00:00
Shikha Panwar
8a3a29dd5a Sk VTS: Policy gating & Out of Seq req rejection
1. Add a test to check Access control in Secretkeeper HAL: Construct
   dice chains with different security version and check that the secret
   is accessible with upgraded dice chain && DicePolicyError is thrown
   when the access is requested using a dice chain with lower security
   version.

2. Re-enable test #replay_protection_out_of_seq_req_not_accepted - This
   was disabled because the method would not panic when run on
   devices without Sk HAL, causing test failure. Refactor the test to
   check the error instead of unwrapping.

Many methods of SkClient struct are refactored to return Error (also
introduced in this patch) instead of panicking on error.

Test: atest VtsSecretkeeperTargetTest
Bug: 291224769
Bug: 317416663
Change-Id: I646783e034064f81625a978a2bcacf143ff60c87
2024-01-12 09:51:08 +00:00
Shikha Panwar
fc0dbfee70 InitialPayload of ExplicitKeyDiceCertChain
Change the spec for DiceCertChainInitialPayload, removing the map &
directly equating it to bstr .cbor PubKey. Also mandate it to stick to
Core Deterministic Encoding Requirements. The deterministic encoding is
essential to ensure DicePolicies can be applied on the root key.

Test: Builds
Bug: 319613231
Change-Id: I5e12ecbcbae84ae608d784a12f8ae4afc49b5a9d
2024-01-12 06:32:08 +00:00
Shikha Panwar
7c53bb3144 Secretkeeper: VTS to use dice_chain as identity
VTS (being the client of Sk) will use dice_chain as the identity.
Consequently we can use the sealing policy constructed out of this
identity & no more need to use HYPOTHETICAL_DICE_POLICY hack.

For sample identity, we create dice_sample module which constructs an
example dice chain (in Explicit key chain format), along with secrets.

Test: Secretkeeper VTS
Bug: 291224769
Change-Id: Ia1d1a92391d3ee455bf9fe254770b4a9bd08cb12
2024-01-11 09:01:51 +00:00
Shikha Panwar
1eae7abfaa VTS: Use encoding of policy on explicit key dice
As we make Dice policy work with explicit key format of dice chain, the
hard coded policy needs to change to be compatible with hard coded
explicit key chain in the TA.

Test: VTS
Bug: 291213394
Change-Id: Ib3740d8f12f0a5f4e680bd215170bc96596fbe06
2024-01-10 15:59:42 +00:00
David Drysdale
388597703e Secretkeeper: use Ed25519 identity key
Test: VtsSecretkeeperTargetTest
Change-Id: I27aebb8913c34f043b7ccc7b6e23969377313e1e
2024-01-09 17:52:15 +00:00
David Drysdale
099c876e9c Secretkeeper: move VTS to rdroidtest
Use rdroidtest for running tests as it now supports parameterized
tests (aosp/2885268) and has an attribute macro (aosp/2890086).

Also rustfmt.

Test: VtsSecretkeeperTargetTest
Change-Id: I9570a7f33a6ff7dbf7cb7238fa3770dedb990e8c
2024-01-08 15:17:48 +00:00
David Drysdale
77a86d8dae KeyMint VTS: fix flipped error messages
Also make main() shorter by `using`.

Bug: 317693523
Test: VtsAidlKeyMintTargetTest
Change-Id: Ife6048001a003e387927338dfcf7a4b2293576c7
2024-01-03 11:30:22 +00:00
Treehugger Robot
78b266ba5a Merge "Secretkeeper: Disable a replay protection VTS" into main 2023-12-22 11:46:34 +00:00