Commit graph

980 commits

Author SHA1 Message Date
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
Shikha Panwar
0b0895a49b Merge "Secretkeeper VTS: Use trait CborSerializable" into main 2023-12-08 14:56:47 +00:00
Shikha Panwar
3f136b2914 Replace secretkeeper_comm_nostd->secretkeeper_core_nostd
Moving SecretkeeperTa struct to secretkeeper_core

Bug: 291224769
Test: Builds
Change-Id: I6f1a7ef08580e2c9383abcb88997a8eb11c6b14a
2023-12-08 13:51:51 +00:00
Justin Yun
31002f5d2e Vendor api level cannot use sdk api level
Update __ANDROID_API_V__ with 202404 for the vendor api level.

Bug: 312798205
Bug: 315246126
Test: atest VtsHalRemotelyProvisionedComponentTargetTest
Change-Id: I0e6ff71e57137e3f6d7e5e5bf082d10026cec2e0
2023-12-08 21:10:37 +09:00
Shikha Panwar
72e99b7604 Secretkeeper VTS: Use trait CborSerializable
With Request/Response packets impl CborSerializable. Use the methods
from those.

Test: atest libsecretkeeper_comm_nostd
Bug: 291228655
Change-Id: Ib0daf9c0aa3417befedbc130725fb3445b327079
2023-12-08 11:37:59 +00:00
Seth Moore
40f1230a1d Merge "Change the way rkp tool obtains serial number" into main 2023-12-07 19:14:37 +00:00
chuanchuan.gao
18a9fa99a8 Change the way rkp tool obtains serial number
[Description]
1.Add patch to modify rkp_factory_extraction_tool, so
 that it can meet TV customer's factory product line.
2.Change the method for
rkp_factory_extraction_tool to get the serial number.
3.Introduce a new input parameter, serialno_prop,
to the function jsonEncodeCsrWithBuild.
4.Use the new property of serialno_prop if it is set,
otherwise defaults to "ro.serialno".

Test:
1.build pass
2.AC on/off pass
3.run "rkp_factory_extraction_tool
--output_format build+csr
--serialno_prop $(customer_prop) > csr.json" pass
4.run "rkp_factory_extraction_tool
--output_format build+csr > csr.json" pass
5.VtsHalRemotelyProvisionedComponentTargetTest pass
6.libkeymint_remote_prov_support_test pass
7.VtsAidlKeyMintTargetTest pass

Bug: 313811996
Change-Id: I8aa83bacab22f0a28bc54aea9e816f75a382ffde
2023-12-07 18:23:15 +08:00
David Drysdale
986e92e098 Merge "Secretkeeper: add AuthGraph key exchange" into main 2023-12-07 06:56:12 +00:00
Seth Moore
0293d63b50 Fix incorrect link rendering.
The MD format was wrong for some RKP-VM links.

Change-Id: I03c9b4c394cbfc9c85b6c5cb3ea3625da2eb09a3
2023-12-06 15:53:19 +00:00
David Drysdale
8898d2ec57 Secretkeeper: add AuthGraph key exchange
Add `ISecretkeeper::getAuthGraphKe()` method to the Secretkeeper HAL.

Align the AIDL targets between AuthGraph and Secretkeeper, and add
some defaults that automatically link to the current version of the
Secretkeeper AIDL targets.

Move the non-secure implementation of AuthGraph to run the TA in a
separate thread.

Alter the nonsecure implementation of Secretkeeper so that it no longer
directly implements Secretkeeper functionality, but instead re-uses
common code from the Secretkeeper reference implementation.  This
involves re-using the common implementation of the HAL service (from
`authgraph_hal`), but also involves using the reference implementation
of the the TA code that would normally run in a separate secure
environment.  The latter code expects to run in a single-threaded
environment, so run it in a single local thread.

Note that the negotiated session keys emitted by AuthGraph are not yet
used by Secretkeeper (coming in a subsequent CL).

Extend the Secretkeeper VTS tests to invoke the AuthGraph VTS inner
tests on the returned IAuthGraphKeyExchange instance, exercising the
instance as an AuthGraph sink.

Bug: 291228560
Test: VtsSecretkeeperTargetTest
Change-Id: Ia2c97976edc4530b2c902d95a74f3c340d342174
2023-12-06 06:50:19 +00:00
Jooyung Han
577cc0ac9b Merge "Create secretkeeper HAL APEX" into main 2023-12-06 01:45:22 +00:00
Treehugger Robot
3cf2309b7b Merge "Add new CertificateType for the RKP VM" into main 2023-11-30 17:00:20 +00:00
Seth Moore
690571283b Add new CertificateType for the RKP VM
The RKP VM is part of the Android Virtualization Framework. It will be
uniquely authenticated by the RKP server, and therefore needs its own
certificate type.

Bug: 300624493
Change-Id: Ice586ad85ae43235dd80a5d220603e7394c1c49b
2023-11-30 15:55:54 +00:00
David Drysdale
2ae2061864 Merge "KeyMint: check length of verified boot key" into main 2023-11-29 10:41:13 +00:00
Jooyung Han
bc19229812 Create secretkeeper HAL APEX
Bug: 276190333
Test: VtsSecretkeeperTargetTest
Change-Id: Ia932b8eaaccf806d7fbfd764db2922a5ff1a9a1b
2023-11-29 14:27:07 +09:00
David Drysdale
20c6549f34 AuthGraph: drop now-unused StdClock
Test: build
Bug: 291228560
Change-Id: Ie4bd2c7ebca1ceae07012f406c2dcbb5efbd915d
2023-11-23 15:50:42 +00:00
Jooyung Han
28b3387f4c Merge "Add authgraph HAL APEX" into main 2023-11-23 02:03:18 +00:00
Alice Wang
c9655da294 Merge "Revert^4 "[avf] Adjust IRPC VTS tests to handle AVF in unsupported env"" into main 2023-11-22 09:49:19 +00:00
David Drysdale
f4cb6de19c Merge "AuthGraph VTS: detect additional errors" into main 2023-11-22 06:23:38 +00:00
Shikha Panwar
0da7c09716 Merge changes from topic "sk_hal" into main
* changes:
  VTS test for ISecretkeeper
  Secretkeeper implementation: in-HAL/nonsecure impl
  Introduce Secretkeeper HAL interface
2023-11-21 17:56:46 +00:00
Alice Wang
895f4b33e8 Revert^4 "[avf] Adjust IRPC VTS tests to handle AVF in unsupported env"
Revert submission 2829351-revert-2812456-revert-2812435-revert-2778549-expose-avf-rkp-hal-GTFGLMUUKQ-PAWNEHUQBT-WYENGHRTXK

Reason for revert: Relands the original topic:
https://r.android.com/q/topic:%22expose-avf-rkp-hal%22
PS2 is the same as the original cl: aosp/2796032

Reverted changes: /q/submissionid:2829351-revert-2812456-revert-2812435-revert-2778549-expose-avf-rkp-hal-GTFGLMUUKQ-PAWNEHUQBT-WYENGHRTXK

Test: atest MicrodroidHostTests librkp_support_test
Change-Id: I7200599131c01908db7fa3bb4a6f989418a89288
2023-11-21 12:26:53 +00:00
Shikha Panwar
a6eaf55d7d VTS test for ISecretkeeper
Add VTS for testing ISecretkeeper implementation. At present, VTS is
limited to testing GetVersion operation of SecretManagement.

Test: atest VtsSecretkeeperTargetTest
Bug: 291224769
Change-Id: I6084af2fa6cb578e27996e26a0505b267a10b4ef
2023-11-21 12:00:49 +00:00
David Drysdale
087ead1608 AuthGraph VTS: detect additional errors
A failure to get the IAuthGraphKeyExchange/nonsecure instance might
be because it's not registered (likely on most non-Cuttlefish devices)
or it might be for some other reason, such as SELinux denial.

So detect other kinds of failure to get the service, and also change
the VTS to require root so SELinux denials don't happen.

Also tweak the expected return code when a source is given a corrupt
key; now that replay protection is implemented, the reference
implementation rejects this earlier (and with a different error)
because the session lookup fails.

Test: VtsAidlAuthGraphRoleTest
Bug: 291228560
Change-Id: I032600ac809f43a3642fa9ef9aae788d3ca2378f
2023-11-21 11:09:42 +00:00
David Drysdale
3fb1cddadc Merge "KeyMint: tweak spec to allow for no v4 in V" into main 2023-11-21 09:38:53 +00:00
Jooyung Han
9f3f37f288 Add authgraph HAL APEX
Bug: 309463258
Test: VtsAidlAuthGraphSessionTest
Change-Id: I5ac32a6e5d70321f31321b613a982020bf51db68
2023-11-21 17:14:33 +09:00
David Drysdale
1405dbc7a4 KeyMint: tweak spec to allow for no v4 in V
Given that we are not expecting to release a v4 of the KeyMint HAL for
Android V, tweak some spec and test details so that existing v3
implementations do not need to change.

- Soften the requirement to use (1970-01-01, 9999-12-31) as cert dates
  when secure-importing an asymmetric to be a suggestion instead.
- Change the version gate for the test of importing an EC key with no
  specified `EC_CURVE` to be VSR-gated rather than gated on a putative
  future version of the HAL.

Test: VtsAidlKeyMintTargetTest
Bug: 292318194
Bug: 292534977
Change-Id: Ib8d6e79ea948ee77eeb2528d698205179f026fd3
2023-11-20 12:13:42 +00:00