Commit graph

9155 commits

Author SHA1 Message Date
Alice Wang
16e3442965 Skip CSR generation for AVF RKP HAL when it is not supported
Test: Run `adb shell rkp_factory_extraction_tool
--output_format build+csr` on a device AVF RKP HAL is unsupported

Change-Id: I8f1ffa63710be6f566fb6f0800c45f3cfb907d69
2024-06-07 13:01:30 +00:00
Cindy Lin
a8fc566120 Merge "Implement mls-rs-crypto-traits backed by BoringSSL." into main 2024-05-30 09:27:49 +00:00
Cindy Lin
6ec3c2b64f Implement mls-rs-crypto-traits backed by BoringSSL.
Fix: 302021139
Test: Presubmit
Change-Id: Iaefa21d3fb69f92d735875778f3f96e1878d0876
2024-05-28 13:29:16 +00:00
David Drysdale
95b8309b2f Merge "Add debugging info for transactions" into main 2024-05-28 07:44:21 +00:00
David Drysdale
de2ac5cf7d Merge "Add/use watchdog with standard timeout" into main 2024-05-28 07:17:08 +00:00
David Drysdale
7b9ca23b18 Add debugging info for transactions
Pass around information about which code is performing an exclusive
database transaction, and run an additional watchdog inside the
transaction closure.

Bug: 319563050
Test: CtsKeystoreTestCases
Change-Id: Ib54f1f4c0c37f9d7392d21d9ccb880d066029945
2024-05-24 15:42:24 +01:00
David Drysdale
5b257c6923 Merge "Remove unused code" into main 2024-05-24 09:33:26 +00:00
David Drysdale
541846b93c Add/use watchdog with standard timeout
Almost all uses of the watchdog use the same 500ms timeout, so add a new
method that assumes that.

Test: CtsKeystoreTestCases
Change-Id: Idf7852400a58ba954e4a71e5e2282734a0960072
2024-05-23 13:23:22 +01:00
David Drysdale
8c4c4f3420 Remove unused code
Test: TreeHugger
Change-Id: If7a4606f5a6a09c574574ed8ed04788435259fa8
2024-05-23 12:58:15 +01:00
Max Bires
ef518cbe49 Merge "Revert "Deprecating the aidl for Android Protected Confirmation"" into main 2024-05-23 03:32:38 +00:00
David Drysdale
99464340c4 Merge "Give up on busy DB after a while" into main 2024-05-22 10:18:24 +00:00
Max Bires
9535b1b443 Revert "Deprecating the aidl for Android Protected Confirmation"
Revert submission 2864688-apc-deprecate

Reason for revert: fix inadvertent partial deprecation

Reverted changes: /q/submissionid:2864688-apc-deprecate

Change-Id: Id97e7ec533b630a22ea91db82ab75f14b0d32edc
2024-05-22 05:13:36 +00:00
David Drysdale
115c4722f8 Give up on busy DB after a while
Calls to `with_transaction(Immediate, ...)` act as an exclusive lock on
the Keystore database, because the sleep-loop does not release the
transaction.  That gives the potential for deadlock if any of the code
in the invoked callback takes some other lock without consideration
for lock inversions.

There isn't (yet) a smoking gun that definitively identifies a lock
inversion, but this CL adds timeout behaviour just in case.

Include a unit test that deadlocks without the code change, because
of an explicit lock inversion between the immediate-mode database and a
`KeyIdGuard` object (which acts like a `MutexGuard`).

Bug: 319563050
Bug: 315165314
Flag: android.security.keystore2.database_loop_timeout
Test: keystore2_test#database::tests::test_key_id_guard_immediate
Change-Id: I34fa044ce8e3185a89084b84c6f9ac880944982c
2024-05-20 19:07:03 +01:00
Treehugger Robot
996710c4e3 Merge "Use waitForService in rkp_factory_extraction_tool" into main 2024-05-17 10:55:36 +00:00
Alice Wang
c1b568a0e9 Use waitForService in rkp_factory_extraction_tool
The original getService doesn't start the AVF HAL if it is
not already running. waitForService is used here with a timeout
of 10 seconds as it starts a service lazily.

Bug: 339118043
Test: m rkp_factory_extraction_tool
Change-Id: I942f4c5e1aae8b529895a51f19b525033609d0aa
2024-05-17 10:09:10 +00:00
Treehugger Robot
134da755b0 Merge "Clean up OWNERS" into main 2024-05-14 02:13:28 +00:00
Max Bires
a78e7c5727 Clean up OWNERS
Remove OWNERS entry for person no longer working on the project.

Test: N/A
Change-Id: Icbfba05512e1e1c85593ed58ef88ff15b6673ecc
2024-05-13 19:08:39 -07:00
David Drysdale
e85693c603 Merge "Adjust keystore2_client_tests" into main 2024-05-03 05:28:28 +00:00
David Drysdale
40e41f1088 Adjust keystore2_client_tests
Adjust the keystore2 client tests to cope with a wider variety of
underlying KeyMint / Keymaster devices.

A couple of these changes involve test modifications to match the
behaviour of the KeyMint VTS tests:

- `keystore2_gen_key_device_unique_attest_with_default_sec_level_unimplemented`:
  Allow an extra error code, to match
  `DeviceUniqueAttestationTest.EcdsaNonStrongBoxUnimplemented`.
- `keystore2_import_ec_key_success`: Skip the check that EC keys can be
  imported without an explicitly specified `EC_CURVE` on pre-VSR-V
  devices, to match the equivalent logic in the VTS tests
  (`ImportKeyTest.EcdsaSuccessCurveNotSpecified`).

The other two changes are:

- `keystore2_gen_key_auth_boot_loader_only_op_fail`: Drop this test, as
  it's the first/only place that exercises the optional
  `BOOTLOADER_ONLY` tag. (The KeyMint VTS tests would be the best place
  to exercise this for the first time.)
- `keystore2_ec_25519_generate_key_fail`: For now, skip the check that
  an Ed25519 key should reject use of any digest value other than `NONE`
  (on account of Ed25519 having its own internal digest). That behaviour
  isn't quite right, but which is not currently tested by the KeyMint
  VTS tests and so we can't require existing devices to be modified to
  pass the check.

Bug: 336695416
Test: keystore2_client_tests
Change-Id: I06e90c859f33d8b4125541a67709ec67e8898c60
2024-05-01 18:16:46 +01:00
David Drysdale
98e175b6f8 Merge "Drop unused PerBootDbKeepAlive type" into main 2024-04-15 05:35:59 +00:00
David Drysdale
e2b37b6c62 Drop unused PerBootDbKeepAlive type
Looks like the DB was moved out of SQLite in aosp/1699645 but the
connection-holding type was missed.

Bug: 333894699
Test: TreeHugger
Change-Id: I4b87690343bc890cb1aa1c6e1595ac4b42c11670
2024-04-12 14:38:28 +00:00
Frederick Mayle
e5b6854fb8 Merge "Upgrade nix to 0.28.0" into main 2024-04-11 15:44:35 +00:00
Seth Moore
5c5a412b3c Merge "Cope with rkp-only devices in legacy keyblob test" into main 2024-04-10 15:51:45 +00:00
David Drysdale
b0914ea70a Cope with rkp-only devices in legacy keyblob test
On a rkp-only device it is not possible to generate an attestation
on a bare key generation (attestations can only be generated if an
ATTEST_KEY is provided).

Bug: 329409739
Test: keystore2_legacy_blobs_test
Change-Id: Icdc4037466ab32366c34feeb42b58822ea110ebf
2024-04-10 12:58:23 +01:00
Frederick Mayle
42632079aa Upgrade nix to 0.28.0
Bug: 333427576
Test: TreeHugger
Change-Id: I549be37c37e99b4a73da2a12758675ad3191716b
2024-04-09 16:05:43 -07:00
Treehugger Robot
3acb6db524 Merge "Update needed for Rust v1.77.1" into main 2024-04-02 17:22:36 +00:00
Charisee
4339115a79 Update needed for Rust v1.77.1
error: initializer for `thread_local` value can be made `const`
    --> system/security/keystore2/src/database.rs:5022:47
     |
5022 |         static RANDOM_COUNTER: RefCell<i64> = RefCell::new(0);
     |                                               ^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(0) }`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
     = note: `-D clippy::thread-local-initializer-can-be-made-const` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::thread_local_initializer_can_be_made_const)]`

error: aborting due to 1 previous error


Bug: http://b/330185853
Test: ./test_compiler.py --prebuilt-path dist/rust-dev.tar.xz  --target aosp_cf_x86_64_phone --image
Change-Id: Ic583a76f7ea7fc27ce6c214b3247748d7dbaa1b4
2024-04-02 16:18:23 +00:00
Inseob Kim
8717347ce2 Merge "Add support for rsp inputs" into main 2024-04-02 07:19:32 +00:00
Inseob Kim
218d48409c Add support for rsp inputs
... because there can be many many inputs for fsverity manifest
generator.

Bug: 330282551
Test: m aosp_cf_system_x86_64
Change-Id: Ic84205342a07002f2a72a2b412a14e7e01b46af3
2024-04-02 00:45:43 +00:00
Treehugger Robot
2fc36745c1 Merge "Remove unnecessary "_external" suffix from libcppbor" into main 2024-03-29 21:18:28 +00:00
Shawn Willden
387187d179 Remove unnecessary "_external" suffix from libcppbor
Test: Build
Change-Id: If61f49d36ea954f8385012172d454cc803141a60
2024-03-28 20:42:37 -06:00
Charisee Chiw
5eb0727bc0 Merge "Update needed for Rust v1.77.0" into main 2024-03-28 16:12:07 +00:00
Charisee
95ea3ceef5 Update needed for Rust v1.77.0
error: field `0` is never read
   --> system/security/keystore2/src/database.rs:848:31
    |
848 | pub struct PerBootDbKeepAlive(Connection);
    |            ------------------ ^^^^^^^^^^
    |            |
    |            field in this struct
    |
    = 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 wh
ile preserving the field numbering, or remove the field
    |
848 | pub struct PerBootDbKeepAlive(());
    |                               ~~

error: aborting due to 1 previous error


Bug: 330185853
 ./test_compiler.py --prebuilt-path dist/rust-dev.tar.xz  --target aosp_cf_x86_64_phone --image

Test: m rust
Change-Id: I4cb81c955372c4f8f50b940b389f2d7cfc5d3ce9
2024-03-27 23:46:39 +00:00
Treehugger Robot
23f9c84b32 Merge "Remove obsolete TODO from IKeystoreAuthorization.aidl" into main 2024-03-23 06:39:35 +00:00
Eric Biggers
0361bbf664 Remove obsolete TODO from IKeystoreAuthorization.aidl
IKeystoreAuthorization already has @SensitiveData.

Bug: 176110256
Test: N/A
Change-Id: Ia59bb2d9e2154c51b5ab7568a321359ff096c59f
2024-03-22 21:03:11 +00:00
Eric Biggers
d60e2b6964 Merge "Remove broken and unused support for expiring keys when off-body" into main 2024-03-19 00:35:43 +00:00
Eric Biggers
b5613dae22 Remove broken and unused support for expiring keys when off-body
Remove IKeystoreMaintenance#onDeviceOffBody(), as it's no longer called.

In addition, remove the code that tried to enforce the AllowWhileOnBody
key parameter.  This code was broken during the rewrite of Keystore in
Android 12, and as a result, AllowWhileOnBody has no user-visible
effect.  AllowWhileOnBody is *supposed* to cause the key's
authentication timeout, if it has one, to automatically expire when the
device is removed from the user's body.  (A better name for it might
have been something like UserAuthenticationExpiresWhenRemovedFromBody.)
Android 11 Keystore implemented this behavior; see
https://android.googlesource.com/platform/system/security/+/refs/heads/android11-release/keystore/auth_token_table.cpp#165

Android 12 Keystore changed AllowWhileOnBody to have no effect.
Apparently due to a misunderstanding, the (incorrect) behavior that was
attempted to be implemented was "The key may be used after
authentication timeout if device is still on-body".  But what was
actually implemented was that the Keystore daemon stopped enforcing
authentication timeouts for AllowWhileOnBody keys entirely, except after
a wearable device was removed from the body in which case the timeout is
enforced for any earlier authentications.  Yet, this has no user-visible
effect because KeyMint still enforces the authentication timeout as
usual.  So, AllowWhileOnBody has really been a no-op since Android 12.

We can always bring this code back, fixed and with tests, if this
feature comes back.  But for now there is no reason to keep it around.

Bug: 289849354
Test: atest -p --include-subdirs system/security/keystore2
Test: atest CtsKeystoreTestCases
Change-Id: I4a7b3a90b56dacbb5316e30a30bf3fabc0debe48
2024-03-14 17:43:49 +00:00
Markus Vill
e2ce4fd642 Merge "Migrate structured logging for audit logging to the Rust macro." into main 2024-03-08 08:18:26 +00:00
Markus Vill
fdf431762f Migrate structured logging for audit logging to the Rust macro.
This uses the new macro for structured logging that simplifies the usage
of structured logging.

Bug: 290589708

Test: Run keystore client and checked the log
Change-Id: I4d941d8b03c09d0541cf1159c38f4eba60e07292
2024-03-07 16:56:22 +00:00
Treehugger Robot
90eadc655f Merge "Added not_multi_abi configuration for keystore2_client_tests module." into main 2024-03-06 20:37:33 +00:00
Shaquille Johnson
b484dc1ce5 Merge "Update authorization log to be more clear" into main 2024-03-06 14:42:56 +00:00
Shaquille Johnson
dae62efa2c Merge "Update globals to log security levels on fail" into main 2024-03-06 14:40:26 +00:00
Eran Messeri
15a04c4d1f Merge "Updated the logic to determine the VSR API level for device ID attestation tests." into main 2024-03-06 11:54:17 +00:00
Rajesh Nyamagoud
a8cf68ef41 Added not_multi_abi configuration for keystore2_client_tests module.
Changes made to avoid running keystore2_client_tests of armeabi-v7a
builds on arm64-v8a platforms.

Bug: 322112515
Test: run vts -m keystore2_client_tests
Change-Id: Ic7205ecc80146cdd36b1a618c9c5cde114b98e71
2024-03-05 18:37:12 +00:00
Shaquille Johnson
a4d10dbee0 Update authorization log to be more clear
Based on examinations in go/keystore-error-logs-overhaul
we want to update the logs to allow keystore errors
to be properly routed.

Test: atest keystore2_test
Change-Id: I704ca5bdeaf32acdd6a619ca778b04b3df72bcfd
2024-03-05 12:39:58 +00:00
Rajesh Nyamagoud
3f6c8a250d Updated the logic to determine the VSR API level for device ID
attestation tests.

The following order of precedence is used to determine the VSR API level:
1. If the `ro.vendor.api_level` property is present, then use it as the
   VSR API level.
2. Otherwise, determine the VSR API level with the following logic:
  - Get the vendor API level using the `ro.board.api_level` property if
    present; otherwise, use the `ro.board.first_api_level` property.
  - Get the product API level using the `ro.product.first_api_level`
    property if present; otherwise, use the `ro.build.version.sdk`
    property.
  - If it is unable to determine the vendor API level, then use the
    product API level as the VSR API level.
  - If both the vendor API level and product API level are available,
    then use the minimum of `vendor_api_level` and `product_api_level`
    as the VSR API level.
  - Otherwise, the vendor API level will be used as the VSR API level.

Bug: 326675646
Test: atest keystore2_client_tests
Change-Id: I3aa48d05f367fafab5151fa7eb6dd447840dae0d
2024-02-29 19:02:11 +00:00
Shaquille Johnson
972ca7c73e Merge "Change the log level from error to warn" into main am: a83982159f
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2972492

Change-Id: I8acbcfaf3c288167d4e02d15276c93ae3ef270c1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-29 15:12:13 +00:00
Shaquille Johnson
a83982159f Merge "Change the log level from error to warn" into main 2024-02-29 14:26:44 +00:00
Treehugger Robot
840a062c1f Merge "Fix style warnings for rustc 1.76.0" into main am: d25c50c909
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2983289

Change-Id: I56a4c76b182c34152fdc7f83145c07b11dd23ac3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-29 01:44:48 +00:00
Treehugger Robot
d25c50c909 Merge "Fix style warnings for rustc 1.76.0" into main 2024-02-29 01:05:11 +00:00