support metadata signature verification using otacerts.zip #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #7
Needs to be looked at with GrapheneOS/script#8
This PR adds metadata signature verification. It also verifies the new added device model
field in the metadata as noted in #7.
For RSA, we sign using RSASSA-PSS as recommended for new applications in PKCS #`1
v2.2 (RFC 8017) [1]. SHA256withRSA/PSS is supported on Android [2].
Test: With a self-hosted server, a GeneralSecurityException is thrown in
Service when the metadata doesn't match with the original contents, and
no GeneralSecurityException when it matches.
Test: The following steps were done successfully with an RSA-2048
release key and then repeated with an RSA-4096 release key and an
ECDSA release key (generated from
development/tools/make_key
):latest version also on the server
signature to get the "targetBuildDate: ... not higher than
sourceBuildDate" message
again for updates in the app. The logcat shows
java.security.GeneralSecurityException: verifier.verify returned false
value; the same exception from step 3 shows up
correctly.
Test: A previous version of the Updater app was able to download and
verify the new metadata format without issues.
[1] https://tools.ietf.org/html/rfc8017#section-8
[2] https://developer.android.com/reference/java/security/Signature