-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for including device info in attestation
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/app/attestation/auditor/KeyStoreExceptionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package app.attestation.auditor; | ||
|
||
import android.os.Build; | ||
import android.security.KeyStoreException; | ||
|
||
class KeyStoreExceptionUtils { | ||
|
||
// See KeymasterDefs#KM_ERROR_CANNOT_ATTEST_IDS | ||
private static final int PRIVATE_CANNOT_ATTEST_ID_ERROR_CODE = -66; | ||
// See KeymaserDefs#sErrorCodeToString | ||
private static final String CANNOT_ATTEST_ID_MESSAGE = "Unable to attest device ids"; | ||
|
||
static boolean isUnableToAttestDeviceInfoError(KeyStoreException exception) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
return exception.getNumericErrorCode() == KeyStoreException.ERROR_ID_ATTESTATION_FAILURE; | ||
} | ||
|
||
String localizedMessage = exception.getLocalizedMessage(); | ||
if (localizedMessage == null) { | ||
return false; | ||
} | ||
|
||
return localizedMessage.contains(CANNOT_ATTEST_ID_MESSAGE) | ||
|| localizedMessage.contains(Integer.toString(PRIVATE_CANNOT_ATTEST_ID_ERROR_CODE)); | ||
} | ||
} |