Commit graph

1005 commits

Author SHA1 Message Date
David Drysdale
50d605f8a1 Merge "KeyMint: test HAL version matches feature" into main am: 922a49f278 am: 87e3ce175c
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2923274

Change-Id: Iaba22e15a8318c4a28a38de93dd9d9c8226461f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-24 13:07:57 +00:00
David Drysdale
922a49f278 Merge "KeyMint: test HAL version matches feature" into main 2024-01-24 11:54:13 +00:00
Seth Moore
655a0654f3 Fix incorrect code comment about keymint version am: ec10c484b7 am: 1ab8951974
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2925130

Change-Id: I6db7fe4d7168927706656f681df60b047cb5c20b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-23 23:20: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
45724c24fb Secretkeeper: add test CLI am: b95093d640 am: bf5f86baba
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2906876

Change-Id: Id32a621805667942f821a48ff769d785c884a67e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-17 13:03:40 +00:00
Andrew Walbran
a2ac0cc88f Merge "Import macros via rdroidtest for consistency." into main am: 787be21ae8 am: 22e75cd42a
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2910957

Change-Id: If2ca7366767f10f72be4fc41843b98e678771ba3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-17 11:57:26 +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
Shikha Panwar
206a12d04e VTS to use enum for MissingAction am: 84187967cb am: 37813dbd44
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2909582

Change-Id: I11ab91c91378f51c837723df1250db8ab6604b44
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-16 19:24:20 +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
1a06e22081 Merge "Sk VTS: Policy gating & Out of Seq req rejection" into main am: c6cf62d113 am: d3ae4e4258 am: 958b0e4038
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2904307

Change-Id: Ibef4a996a37777b3f15747fa5aaf6cf3f14477b1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-12 19:02:48 +00:00
Shikha Panwar
1bfbe74dda Merge "Secretkeeper: VTS to use dice_chain as identity" into main am: 6d5bb1eeaf am: 6710a7b129 am: 56dd940b20
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2896100

Change-Id: Ifde5cea18769c29fcf74daf6993bdead46941c0c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-12 19:01:58 +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
9770cae664 Merge "InitialPayload of ExplicitKeyDiceCertChain" into main am: 62b6504c33 am: 8a262b2975 am: e490437a14
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2906515

Change-Id: Ic07de65fcc4d6e9d4f28b4c2774275e10725b519
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-12 13:54:20 +00:00
Shikha Panwar
62b6504c33 Merge "InitialPayload of ExplicitKeyDiceCertChain" into main 2024-01-12 10:46:21 +00:00
Shikha Panwar
bf77b25594 Merge "VTS: Use encoding of policy on explicit key dice" into main am: 91fd13d579 am: 67755270ad am: 00a303d351
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2890552

Change-Id: I0ccbb70e110f3407f2ae04a686dd53949a160815
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-12 10:25:47 +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
Treehugger Robot
cadbe176ec Merge "Baseline NewApi issues" into main 2024-01-11 18:54:37 +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
Cole Faust
2424cc007d Baseline NewApi issues
NewApi is a lint check that you don't call framework methods that were
introduced in versions later than your min_sdk_version. We want to
make this an error, so we're baselineing all existing issues.

This cl was generated automatically, by taking all the NewApi issues
from the reference baselines, and all the non-NewApi issues from the
existing checked in baselines.

Bug: 268261262
Test: Presubmits
Change-Id: I3e4bcd76bad422513d48712303ce5c857511d9be
2024-01-10 12:30:37 -08: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
Shikha Panwar
ebeaa36f43 Secretkeeper: Disable a replay protection VTS
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
2023-12-22 10:51:08 +00:00
Shikha Panwar
5f20ea7b01 Merge "Secretkeeper: Use byte[64] as SecretId" into main 2023-12-22 10:04:46 +00:00
Treehugger Robot
856abca8db Merge "use getDescription in test failure message" into main 2023-12-21 23:21:02 +00:00
Shikha Panwar
3526efd027 Secretkeeper: Use byte[64] as SecretId
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
2023-12-21 19:47:54 +00:00
Alan Stokes
f7fb082947 Fix a typo
Test: N/A
Change-Id: I200d629e22824a4bfe5278194ff12d20a2d16f74
2023-12-21 11:13:02 +00:00
Shikha Panwar
99cf847175 Merge "Clarify Secretkeeper comments" into main 2023-12-20 18:38:51 +00:00
Alan Stokes
45d1faaea8 Clarify Secretkeeper comments
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
2023-12-20 17:46:14 +00:00
Shikha Panwar
3d33a135ad Secretkeeper/VTS: Per-connection replay protection
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
2023-12-20 14:41:09 +00:00
Shikha Panwar
73f66600e9 Add SeqNum as an the external_aad in CryptoPayload
Introduce sequence number in Secretkeeper packets to prevent replay of
packets with a session.

Bug: 316126411
Test: VTS
Change-Id: I20a5d8489e988bdcbe9058495ab56ed18a07b946
2023-12-20 14:41:09 +00:00
David Drysdale
0bd88b03b3 Secretkeeper VTS: check for declared instances
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
2023-12-19 15:14:52 +00:00
David Drysdale
a662feeee4 Merge "secretkeeper: add fuzzer" into main 2023-12-19 09:45:14 +00:00
David Drysdale
b108e8cd87 authgraph: cope with LocalTa being dropped
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
2023-12-18 17:33:33 +00:00
David Drysdale
c3aa44207f secretkeeper: add fuzzer
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
2023-12-18 17:31:58 +00:00
David Drysdale
38174301c6 Secretkeeper: improve VTS tests
- 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
2023-12-13 13:12:28 +00:00
David Drysdale
1357b92dbc [Secretkeeper] Add maintenance methods
Also move error codes from separate `ErrorCode.aidl` file to be inline
ERROR_ constants instead.

Bug: 291224769
Test: VtsSecretkeeperTargetTest
Change-Id: I1b0f3f3b5a7c5e891da3022444bf6c7925850550
2023-12-13 13:08:10 +00:00
David Drysdale
bef8d3ae89 Secretkeeper: add message encryption
All request messages are encrypted, but response messages have an outer
unencrypted layer, with an inner response (and the result values inside
that).

Make the SecretManagement.cddl file clearer to reflect that, and make
the schema valid along the way.

Move the outer (unencrypted) error code values into `ErrorCode.aidl` and
use them as service-specific error codes, thus reducing the number of
error types from 3 to 2.

Bug: 291228560
Test: VtsSecretkeeperTargetTest
Test: validate CDDL with https://atacama.informatik.uni-bremen.de/
Change-Id: I46c5bfd7e40b03919d7d3779b265b3bb3ff1ce1e
2023-12-12 16:03:04 +00:00
Shikha Panwar
cbad9a37d3 Test store & get Secret functionality
Test Store/Get api of SecretManagement HAL. We use a hard coded
hypothetical chain & a dice policy (which the dice chain matches
against) for testing the store/get functionality.

This patch also adds required error codes in SecretManagement.cddl

Bug: 291224769
Test: atest VtsSecretkeeperTargetTest
Change-Id: I0aa2dfc7413791e9de62a6e753bda4ab2f813d2c
2023-12-12 14:24:14 +00:00
Shikha Panwar
2759df0d3c [Secretkeeper] In-memory KeyValueStore
We introduce InMemoryStore, an implementation of KeyValueStore trait.
This can be used for implementing backends that VTS can run against.

Bug: 291224769
Test: atest VtsSecretkeeperTargetTest
Change-Id: Id109ee3bd38ec0979953b6285019c97d418172ef
2023-12-12 14:24:14 +00:00
Seth Moore
121fedaa46 Replace string copies with const-ref
Change-Id: Ie3ea65cc81aa8b9a92a7718ca2003440a3189a4b
Test: Treehugger
2023-12-11 10:32:02 -08:00
Treehugger Robot
05585eb79a Merge "Replace secretkeeper_comm_nostd->secretkeeper_core_nostd" into main 2023-12-08 17:17:43 +00:00
Treehugger Robot
4de610c690 Merge "Vendor api level cannot use sdk api level" into main 2023-12-08 16:24:15 +00:00
Shikha Panwar
5afbeec13d Create OWNERS file for secretkeeper interface
Bug: 291224769
Test: N/A
Change-Id: I650d4e640522876f79ea583cbbddd159776c8955
2023-12-08 15:16:41 +00:00