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
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
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
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
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
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
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
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
With libdice_policy being refactored, get VTS to use the builder
library.
Test: Built the test-suite
Bug: 291238565
Change-Id: I149ec1ba9ee66fd19cbf0d0a6f3baa12ea2474ed
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
ConstraintSpec constructor will take enum instead of boolean for missing
action.
Test: atest VtsSecretkeeperTargetTest
Bug: 291213394
Change-Id: I55fb0d8ef1fccca5feedf1fd368854ffb7eafaaf
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
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
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
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
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
This test does not account for potentially missing Sk HAL. Ideally, the
test should pass on those devices too (since Sk is an optional HAL at
the moment).
This test uses should_panic expecting the client code to panic on
processing the message, but that code is never executed because the
backend is not present & the method doesn't panic & the test fails.
As a mitigation, #ignore the test.
Bug: 317416663
Test: VTS show "IGNORED"
Change-Id: I2f1bb45361943f22d8cadc929059c65cb3120f3f
SecretId is a parameter in deleteIds() method, which will be invoked by
host (Android). Restrict the size to 64 bytes to avoid unnecessarily
large bytes making it to HAL & TA.
Test: atest VtsSecretkeeperTargetTest
Bug: 317374882
Change-Id: Ieb34fee4efd11636bee133fe9132c1d739d08a1c
Various small wording changes to attempt to clarify some of the
details of the Secretkeeper API.
While I'm here: fix error code naming inconsistency.
Bug: 291224769
Test: N/A
Change-Id: I956b549bc5bf4d2b964dde9867430cb4778e445b
Add test coverage for replay protection in Secretkeeper. Test that:
1. Sk implementation encrypts/decrypts messages using correct
sequence_numbers.
2. Out of order messages are not accepted.
3. The sequence numbers are per-connection ie, new SeqNum is used for a
fresh connection.
Also, refactor code. SeqNumbers are maintained by
libsecretkeeper_client. Have sk_client use a handle to SkSession for
SecretManagement requests. Replay protection tests however require more
fine grained control of SeqNums. For these we have introduced
`secret_management_request_custom_aad()` method.
Bug: 316126411
Test: atest VtsSecretkeeperTargetTest
Change-Id: I385856c04e185d2b300d59a1b54cb8f09cbf836f
Introduce sequence number in Secretkeeper packets to prevent replay of
packets with a session.
Bug: 316126411
Test: VTS
Change-Id: I20a5d8489e988bdcbe9058495ab56ed18a07b946
Calling binder::get_interface(name) for a name that isn't declared may
take multiple seconds before failing. Restrict to looking for instance
names that are declared.
Also add a rustfmt.toml file, copied from system/secretkeeper/
Bug: 291228655
Test: VtsSecretkeeperTargetTest on Cuttlefish and Pixel8
Change-Id: I9972bc782fe99f5dc5c2dc3b74fa12a0e000ea6c
When a LocalTa instance is used in a fuzzer, it gets dropped at the end
of processing each fuzz input. This makes the `mpsc::channel`s fail,
so update to cope with this.
Bug: 316075932
Test: run fuzzer on Cuttlefish
Change-Id: I069f441013e269f652cbe1ff3053606f9bcb2dfd
Move nonsecure implementation code out of main.rs and into a new
secretkeeper_nonsecure library, to allow re-use in both the nonsecure
service and the new fuzzer.
The fuzzer drops the `LocalTa` instance on each input, so adjust the
error path to cope with this happening (the channels will fail).
Test: build, fuzz
Bug: 291228655
Change-Id: Ibe2ca5db9a9c8eed129ac5a90de85b933ab256a0
- Look for either /default or /nonsecure instances.
- Only run a `deleteAll()` test on a /nonsecure instance.
- Delete IDs on client drop to ensure a consistent state.
- Use a config that ensures tests are run single-threaded, to ensure a
consistent state.
- Shift to using types not raw arrays.
- Add a macro for common test setup.
- Add helper methods to reduce the amount of copy-pasta in the VTS
tests.
- Use these helpers to create some additional tests.
Test: VtsSecretkeeperTargetTest
Bug: 291224769
Change-Id: Icff0bba1bcdd66b18398ed4b64ebd2c6bc0de7e7
Also move error codes from separate `ErrorCode.aidl` file to be inline
ERROR_ constants instead.
Bug: 291224769
Test: VtsSecretkeeperTargetTest
Change-Id: I1b0f3f3b5a7c5e891da3022444bf6c7925850550