Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gorokhovdv/safetynetattestation
This lib helps develop server-based (PHP) SafetyNet Attestation from Google.
https://github.com/gorokhovdv/safetynetattestation
android composer google packagist php php-library safetynet server-side
Last synced: 9 days ago
JSON representation
This lib helps develop server-based (PHP) SafetyNet Attestation from Google.
- Host: GitHub
- URL: https://github.com/gorokhovdv/safetynetattestation
- Owner: GorokhovDV
- License: mit
- Created: 2020-09-20T19:38:22.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-15T11:32:39.000Z (almost 3 years ago)
- Last Synced: 2024-10-27T09:50:54.938Z (10 days ago)
- Topics: android, composer, google, packagist, php, php-library, safetynet, server-side
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 10
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SafetyNet offline/online attestation library
===============================
* **PHP version:** 7.4+
* **Packagist:** [gorokhovdv/safetynet-verification](https://packagist.org/packages/gorokhovdv/safetynet-verification) [![Total Downloads](https://poser.pugx.org/gorokhovdv/safetynet-verification/downloads.png)](https://packagist.org/packages/gorokhovdv/safetynet-verification)
* **Composer:** `composer require gorokhovdv/safetynet-verification`***
## Quick Start
### Install
If you use composer in your project then you can install SafetyNetAttestation as package.
`composer require gorokhovdv/safetynet-verification`
### Example for online verification
```php
VerifierType::ONLINE(),
Config::VERIFIER_TIMESTAMP_DIFF => 10 * 60 * 1000,
Config::VERIFIER_CERTIFICATE_DIGEST_SHA256 => ['SHA-256-FINGERPRINT'],
Config::VERIFIER_PACKAGE_NAME => ['APK-NAME-FOR-TEST'],
Config::VERIFIER_API_KEY => 'GOOGLE-API-KEY',
Config::VERIFIER_HARDWARE_BACKED => true,
]);$attestation = new Attestation($attestationConfig);
if ($attestation->verity($nonce, $attestationStatement)) {
echo 'Verification success!' . PHP_EOL;
} else {
echo 'Verification failed!' . PHP_EOL;
}
} catch (SafetyNetAttestationException $e) {
echo $e->getMessage() . PHP_EOL;
}
```### Example for offline verification
```php
VerifierType::OFFLINE(),
Config::VERIFIER_TIMESTAMP_DIFF => 10 * 60 * 1000,
Config::VERIFIER_CERTIFICATE_DIGEST_SHA256 => ['SHA-256-FINGERPRINT'],
Config::VERIFIER_PACKAGE_NAME => ['APK-NAME-FOR-TEST'],
Config::VERIFIER_HARDWARE_BACKED => true,
]);$attestation = new Attestation($attestationConfig);
if ($attestation->verity($nonce, $attestationStatement)) {
echo 'Verification success!' . PHP_EOL;
} else {
echo 'Verification failed!' . PHP_EOL;
}} catch (SafetyNetAttestationException $e) {
echo $e->getMessage() . PHP_EOL;
}
```