Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [SIW-860,SIW-946] Add Android integrity implementation #5

Merged
merged 77 commits into from
Apr 5, 2024

Conversation

LazyAfternoons
Copy link
Contributor

@LazyAfternoons LazyAfternoons commented Mar 13, 2024

Important

Depends on #6

Short description

This PR adds the Android implementation to retrive a key attestation and to generate a Play Integrity standard request.
It also implements a basic backend server to verify these attestations.

List of Changes

Adds Android native implementation of the following functions:

  • isPlayServicesAvailable which checks whether or not Google Play Services are available on the device. They are request for Play Integrity API to work, along with Play Store;
  • prepareIntegrityToken is the first function which must be called for a Play Integrity standard request. It prepares the provider which is later used to obtain the integrity token. A Google Cloud Project Number is required and must be provided in the const declaration of AndroidApp.tsx;
  • requestIntegrityToken is the second function to be called for a Play Integrity standard request. A requestHash can be provided and will be later checked from the server which decrypts the integrity token;
  • getAttestation returns the key attestation which will be later checked from the server.

Adds backend endpoints implementation of:

  • /verifyIntegrityToken which verifies and decodes a Google Play Integrity integrity token and returns its verdict;
  • /verifyAttestation which verifies the attestation by checking if the root certificate is signed by Google; if each certificate in the chain is signed by the previous one; if there's any revoked certificate in the chain. Each step is implemented separately for clarity's sake, at the cost of cycling through the chain multiple times.

The AndroidApp.tsx component of the example app incapsulates the whole UI needed to test these function and thus is only rendered if the platform is Android.
On iOS these functions are rejected by default.

The androidRouter.ts component of the backend exposes any Android related endpoint.

How Has This Been Tested?

Run the Android example app by following the instructions in the README.md.

You can test the generated tokens and attestation with the local backend. Read the README.md for more information.

The flow to test a Google Play Integrity check is:

  • Prepare;
  • Get Token;
  • Verify Token (optional, requires the dev server which only decodes the results and sends it to the example app).

The flow for the key attestation is:

  • Get attestation;
  • Verify attestation (optional, requires the dev server which performs some checks on the chain).

Contact me in private and I'll share my Google Cloud credentials to facilitate the review process.

backend/src/android/androidRouter.ts Outdated Show resolved Hide resolved
backend/src/android/androidIntegrity.ts Outdated Show resolved Hide resolved
backend/src/android/androidIntegrity.ts Show resolved Hide resolved
example/src/AndroidApp.tsx Outdated Show resolved Hide resolved
Copy link
Member

@shadowsheep1 shadowsheep1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from SIW-943-backend-component to main April 4, 2024 07:23
Copy link

dpulls bot commented Apr 4, 2024

🎉 All dependencies have been resolved !

backend/src/android/androidRouter.ts Dismissed Show dismissed Hide dismissed
backend/src/android/androidRouter.ts Dismissed Show dismissed Hide dismissed
backend/src/android/androidRouter.ts Fixed Show fixed Hide fixed
backend/src/android/androidRouter.ts Dismissed Show dismissed Hide dismissed
@LazyAfternoons LazyAfternoons merged commit c7f01c5 into main Apr 5, 2024
9 checks passed
@LazyAfternoons LazyAfternoons deleted the SIW-860-integrity-android branch April 5, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants