Commit graph

3769 commits

Author SHA1 Message Date
Joel Galenson
7ead3a249f Migrate to the librustutils system property bindings.
Bug: 182498247
Test: Build
Change-Id: Ic16033d7f5e302a3cb7e591a0fa2ae403755fc2e
2021-07-29 15:27:34 -07:00
Treehugger Robot
8125bace85 Merge "Fix warnings in preparation for Rust 1.54.0" 2021-07-29 18:14:08 +00:00
Martijn Coenen
5c19d23b52 Merge "Don't mark odsign as oneshot." 2021-07-28 11:50:22 +00:00
Martijn Coenen
2e8a9845e3 Don't mark odsign as oneshot.
If odsign is marked as oneshot, and it crashes (eg due to a coding
error), the device will not boot completely, because init keeps waiting
for the odsign.key.done / odsign.verification.done properties. So
instead, we don't mark it as oneshot, but stop the service manually in
the exit paths of the code. This ensures that if a bad OTA / module
update causes odsign to crash, we will automatically start it again; if
it crashes repeatedly, apexd will detect this, and roll back any module
update.

In the good path, there's no difference - odsign will run just once and
be stopped.

Bug: 194334176
Test: manually make odsign crash; inspect output
Change-Id: I7015f291888d6b8066e4c526a7e8cf3c9c7ea618
2021-07-28 11:06:06 +02:00
Chris Wailes
d5aaaef8df Fix warnings in preparation for Rust 1.54.0
This CL fixes several new warnings generated by rustc 1.54.0.

Bug: 194812675
Test: m rust
Change-Id: I3076313ea51c6f4e74029ad9fb45d6f0b6dea460
2021-07-27 16:10:08 -07:00
Treehugger Robot
04f835ad2f Merge "Fix warnings in preparation for Rust 1.53.0" 2021-07-27 20:35:22 +00:00
Seth Moore
2cc752164d Merge "Print device keys in test mode" 2021-07-27 18:20:14 +00:00
Seth Moore
9a4bc972c0 Print device keys in test mode
When using the rkp_factory_extraction_tool in test mode, a fake device
key is generated on the fly. This makes verifying the output difficult
as the key is permanently lost.

In test mode, print out the generated keys so that we can test if the
output data is good or not.

Test: Manually tested against backend service tooling not in AOSP
Change-Id: Ibc30044c03f5107990da6d3a03b17aa652d4b1bc
2021-07-27 11:19:46 -07:00
Chris Wailes
3877f29382 Fix warnings in preparation for Rust 1.53.0
This CL fixes several new warnings generated by rustc 1.53.0.

Bug: 194400612
Test: m rust
Change-Id: I599b7c4ee083085735841c5a739d8af74f52fb4a
2021-07-26 19:24:18 -07:00
Treehugger Robot
f2a9f3d234 Merge "Add jbires to system/security OWNERS" 2021-07-23 19:17:19 +00:00
Max Bires
6c8622e916 Add jbires to system/security OWNERS
The number of times I've said "Oh yeah, I'll put a change in later to
add myself to OWNERS" has become embarassing.

Test: I can give OWNERS +2
Change-Id: If24b192fe0f2ca65f6cac58602c0b2b63f2df094
2021-07-23 11:07:13 -07:00
Treehugger Robot
cf01ebfba6 Merge "Fix ill-formed certificate request" 2021-07-23 18:05:21 +00:00
Seth Moore
9ea08f23c2 Fix ill-formed certificate request
1. The MAC tag value was not being included in the uploaded data, so
   it was previosly impossible to verify the keys to sign mac.
2. The device info is supposed to be an array with [Verified,
   Unverified] info. It was previously just the verified info.

Test: Manual. Uploaded sample data to device info service.
Change-Id: I096bc5ded0b38fc56864e75c5e06dfbef62e9a74
Bug: 194492359
2021-07-23 15:48:49 +00:00
Joel Galenson
ff936383f8 Merge "Use fully-qualified names instead of read and write." 2021-07-23 14:47:24 +00:00
Joel Galenson
5840ab9829 Merge changes from topic "rust-property-bindings"
* changes:
  Use the newly-added function to read a property.
  Migrate keystore2's Rust system library bindings to bionic.
2021-07-23 14:46:55 +00:00
Treehugger Robot
3244ae5574 Merge "Keystore 2.0: Fix convertStorageKeyToEphemenral" 2021-07-23 02:11:59 +00:00
Janis Danisevskis
84af4d1bf9 Keystore 2.0: Fix convertStorageKeyToEphemenral
Version binding of storage keys was broken in that the old keyblob was
passed to the KM backed instead of the upgraded key blob when an upgrade
was required.

Bug: 194444841
Bug: 187304488
Test: N/A
Change-Id: Iad3e9d4c0de2f8c7121147c81590e56663fe596f
2021-07-22 18:55:15 -07:00
Treehugger Robot
25d11e809d Merge "Update keystore2 for new linter warnings" 2021-07-23 01:11:01 +00:00
Chris Wailes
3583a5108b Update keystore2 for new linter warnings
This CL updates files used in the keystore2 tests to address new linter
warnings from the 1.52.1 compiler.

Bug: 194309655
Test: m keystore2_tests
Change-Id: Ibfa7c20ddaecbe70c7e62f8a01d93bf7d6aecee0
2021-07-22 16:23:54 -07:00
Martijn Coenen
2f503e5971 Merge "Fix makeUniqueWithTrailingData." 2021-07-22 15:15:38 +00:00
Martijn Coenen
d7b63d2c5c Fix makeUniqueWithTrailingData.
And do some additional checking on the generated verity digest size.

Bug: 194334498
Test: TH
Change-Id: If2ae3edc5427b4315d4be63663ab3ac4006f91e8
2021-07-22 10:55:55 +02:00
Treehugger Robot
a68ba13323 Merge "Replace if statement with call to Option::map" 2021-07-21 23:31:14 +00:00
Joel Galenson
d83784a478 Use fully-qualified names instead of read and write.
This one's for you, Paul!

Test: Build
Change-Id: I44d0c05427a897e7d3d35ae2c8b9aa952920e661
2021-07-21 16:19:17 -07:00
Joel Galenson
4f444299d7 Use the newly-added function to read a property.
Bug: 182498247
Test: keystore2_test
Change-Id: I11fe7e86ada3bac254e8b4f0625a5d926a338c6c
2021-07-21 16:18:52 -07:00
Chris Wailes
fe0abfe4ea Replace if statement with call to Option::map
This CL replaces an if-statement with a call to the Option::map
function.  Having manual implementations of Option::map became a warning
with the 1.52.1 compiler update, and this was promoted to an error by
the build system.

Test: TH
Change-Id: I13e4adfbc84fbe855fd7d573e43e65bf602e0a5b
2021-07-21 11:43:41 -07:00
Joel Galenson
f235706b14 Migrate keystore2's Rust system library bindings to bionic.
This is purely a port: it does not add or change any functionality
(other than renaming the library).

Bug: 182498247
Test: Use library.
Change-Id: Ice0c07d5afcbdd2029775fd61eb04a6f7058fdcf
2021-07-21 09:47:40 -07:00
Max Bires
339e3c3e89 Merge changes from topic "full_spec_upgrade"
* changes:
  Always fall back to factory key on any RKP error
  Adding plumbing for supported EC curve on impl
2021-07-16 14:13:45 +00:00
Alan Stokes
3ed67acaa0 Merge "Support pending CompOS keys." 2021-07-14 10:00:15 +00:00
Alan Stokes
d2bfee0043 Support pending CompOS keys.
When CompOS generates new artifacts it may also need to generate a new
keypair. Modify odsign to account for this. It needs to start up
CompOS to find out if the pending key is now the correct one; if so it
replaces the existing key, otherwise we keep the current key (if there
is one).

The pending keys are stored in /data/misc/apexdata/com.android.compos
since they are created & written by CompOS.

Fixed another RsaPublicKey bug.

Bug: 190166662
Test: Manual: No keys at all, no pending key, valid pending key, invalid pending key.
Change-Id: I17871b1e59380d037d71e8065f4cad699374ecaf
2021-07-14 09:44:01 +01:00
Hasini Gunasinghe
978b373fb5 Merge "Log keystore2 crash events." 2021-07-12 19:00:16 +00:00
Hasini Gunasinghe
f80cad7543 Merge "Log metrics related to Remote Key Provisioning (RKP)." 2021-07-12 15:00:57 +00:00
Alan Stokes
1b40bb8057 Merge "Various fixes to CompOS signature handling." 2021-07-12 09:25:10 +00:00
Max Bires
31cdfb8ede Always fall back to factory key on any RKP error
This change cuts off the error propagation from attempting to assign or
fetch a remotely provisioned key for a given app. Instead of passing the
error back out to the framework, the error will be logged and KM will
instead use the factory provisioned key.

Bug:190645703
Test: Key generation never fails due to presence/lack of an attestation
key

Change-Id: I5234baf4649f40832798b25d3204a9a7397e457e
2021-07-11 22:37:56 -07:00
Max Bires
d2ce46b5f1 Adding plumbing for supported EC curve on impl
This change replaces getSecurityLevels() with getImplementationInfo().
Instead of returning an array of integers that only indicates which
security levels the underlying implementations are running as, the new
method returns a parcelable with additional info. Specifically, the
supported EC curve is now sent back to the caller in this Parcelable as
well as the security level.

This change is part of the alterations necessary to support P256 EEKs.
The component sitting between the provisioning server and keystore2 will
need to know which signed EEK certificate chain to pass down to keystore
for a given security level.

Bug: 189018262
Test: atest RemoteProvisionerUnitTests
Change-Id: I416922edad6e0d0245b65fb02983210e790c1221
2021-07-11 22:37:56 -07:00
Hasini Gunasinghe
365ce37460 Log keystore2 crash events.
Ignore-AOSP-First: Merge conflict resolution of a CL in the topic.
Bug: 188590587
Test: statsd TestDrive script.
Merged-In: I0ad7c94187060dca28469ba262e1e4d93fe3df83

Change-Id: I0ad7c94187060dca28469ba262e1e4d93fe3df83
2021-07-09 22:25:43 +00:00
Hasini Gunasinghe
e0912c95d5 Merge changes from topic "metrics_rerouting"
* changes:
  Add keystore API for metrics re-routing.
  Keystore2: Wait for statsd to be available before calling statsd_write()
2021-07-09 22:17:55 +00:00
Alan Stokes
8b4cb96942 Various fixes to CompOS signature handling.
Grant the CompOS APEX access to the signature proto. Switch to
protobuf-lite, since it is more generally available in APEX.

Modify the signature proto (and related code) to store the signature
of the fsverity_formatted_digest, not the raw digest.

Fix dozens of places where raw public key (modulus) and RsaPublicKey
were confused. (Who knew that having 2 different representations with
the same underlying type would cause bugs?)

Fix error in PKCS#7 generation.

All still behind if (false).

Bug: 190166662
Test: Manual: Valid pending artifacts are accepted & added to fs-v as needed.
Change-Id: I115a1e4d2267ca01887ba693e8e02a0bb7c9141a
2021-07-09 18:21:18 +01:00
Hasini Gunasinghe
8af67ea7de Log metrics related to Remote Key Provisioning (RKP).
This CL adds metrics related to attestation pool status and out of key
error, from keystore side.

Ignore-AOSP-First: No mergepath to AOSP.
Bug: 184301651
Test: Statsd test drive script.
Merged-In: I7025c897449e050dda42e2b290dea336c5ad0d52

Change-Id: I7025c897449e050dda42e2b290dea336c5ad0d52
2021-07-08 17:48:05 +00:00
Treehugger Robot
75e5dbdc8b Merge "Adding skeleton for a rust fuzzer for legacy_blob" 2021-07-07 21:34:35 +00:00
hamzeh
266abdb627 Adding skeleton for a rust fuzzer for legacy_blob
Test: m legacy_blob_fuzzer & adb sync data & adb shell
legacy_blob_fuzzer
The edge coverage after running for few minutes was about 15 percent.

Change-Id: I8a8a535319c6146c67980e6c31e5c85c420e40e7
2021-07-07 21:32:41 +00:00
Hasini Gunasinghe
15891e609f Add keystore API for metrics re-routing.
Keystore2 atoms need to be routed to statsd via a proxy.
The proxy needs to call this API in order to pull metrics from
keystore.

Bug: 188590587
Test: Statsd Testdrive script
Merged-In: I28f8675fe5467b0760418c4d2d87808e45657be1

Change-Id: I28f8675fe5467b0760418c4d2d87808e45657be1
2021-07-06 23:13:35 +00:00
Hasini Gunasinghe
69f0bc52a8 Keystore2: Wait for statsd to be available before calling statsd_write()
This is to avoid errors being printed at keystore2 startup due to
statsd not being available.
(refer b/185844285#comment13 for other options for avoiding this)

Also, removed watch dog watch point in async_task since waiting for
boot completion takes a lot of time, triggering watch dog.

Also changed register_pull_metrics_callbacks to use
wait_for_boot_completed and be called in async_task.

Bug: 188441750
Test: statsd Test Drive script for all three types of atoms.
keystore2 startup logs.
Merged-In: I41b48526aad9702dd29f93d139e5f2afba89be3a

Change-Id: I41b48526aad9702dd29f93d139e5f2afba89be3a
2021-07-06 23:11:49 +00:00
Treehugger Robot
1bca8c905e Merge "Skip FS_IOC_GETFLAGS." 2021-07-06 11:58:38 +00:00
Alan Stokes
8a47bfe7d9 Merge "Switch to RsaPublicKey." 2021-07-06 10:30:07 +00:00
Alan Stokes
378bfbe5b3 Merge "Trust CompOs-signed artifacts" 2021-07-06 10:23:51 +00:00
Alan Stokes
2553b56a82 Skip FS_IOC_GETFLAGS.
It's OK to just do an FS_IOC_MEASURE_VERITY on a file even if we don't
know it's in fs-verity; it returns an appropriate error code.

Bug: 190166662
Test: Create a spurious non-verity file, see it is detected.
Change-Id: I392289b11b674b760d9217258ca01b5305b0eee4
2021-07-06 10:24:26 +01:00
Alan Stokes
b85739d830 Switch to RsaPublicKey.
We have been storing the CompOS public key as the raw modulus. But on
the CompOS side we actually need it as a DER-encodedn RSAPublicKey
(which encodes both modulus and exponent).

Bug: 190166662
Test: Use compos_key_cmd to generate a key, odsign accepts it.
Test: Use FakeCompOs to generate a key, compos_key_cmd accepts it.
Change-Id: Ifdc9dc236d2b41ba2ee6a1a04cd7fd6dc4b1a241
2021-07-05 17:30:22 +01:00
Alan Stokes
35049b6100 Trust CompOs-signed artifacts
If the current artifacts are missing or invalid, and if we have
pending CompOs artifacts, then attempt to use them. This includes
verifying the signatures and adding them to fs-verity if need be.

This is largely a proposal in the form of a CL. Note specifically the
definition of what a signature file looks like
(compos_signature.proto, VerityUtils.cpp).

I rationalised the way we handle multiple certificate subjects because
it was starting to get messy & confusing.

Apart from various refactorings, the significant changes remain behind
an if (false). It is currently largely untestable (we don't have
anything to produce signatures) and there's a couple more CLs to come,
but I think this is a big enough CL as it stands.

Bug: 190166662
Test: Create pending directory, see it deleted.
Test: Create valid pending directory, it gets renamed, fails verification
Test: Invalid signature file is rejected
Test: Presubmit
Change-Id: I20ef65f3c382bcfd5db8747e73fc0148a4b978e9
2021-07-05 15:58:32 +01:00
Treehugger Robot
349020835e Merge "Optimize dependencies in rkp_factory_extraction_tool" 2021-07-02 21:36:10 +00:00
Treehugger Robot
a7b5a9cad5 Merge "Keystore 2.0 legacy Keystore: Cleanup when app/user removed." 2021-07-02 18:08:23 +00:00