I'm implementing App Attest server verification on a PHP server.
I'm stuck on step 5 of the Verify the assertion documentation:
Create the SHA256 hash of the public key in credCert, and verify that it matches the key identifier from your app.
At this point, I have the following variables:
$credentialId = ... ; // Bytes extracted from the attestation authData
$credCert = openssl_x509_read($x5c[0]); // The certificate chain is verified elsewhere
$pKey = openssl_pkey_get_public($credCert); // Extract the public key
$keyPem = openssl_pkey_get_details($pKey)['key'];
I don't uderstand what should be SHA-256 encoded to result in $credentialId
($credentialId is correctly validated against the key identifier, as described in step 9).
What I tried so far:
- base64 decoding the
$keyPem
after removing the pem header and footers - hashing the whole
$keyPem
altogether
Can someone point me in the right direction? What public key bytes should be extracted and hashed?