fix(android): USE_BIOMETRIC, and never lock the cache behind a door we cannot open
Opening the vault threw java.lang.SecurityException: USE_BIOMETRIC is not in Delphi default permission list, and CanAuthenticate raises instead of answering false. So the fault showed up neither at compile time nor at startup, but on the first unlock - after the cache had already been written under an auth-protected key. The permission is the shallow half. The deep half is that SaveVault was called with a hard-coded True: we asked for a key guarded by a prompt that could not be shown, producing a file that was unreadable forever. It now receives BiometricAvailable, evaluated on the main thread before the worker starts. BiometricAvailable and AuthenticateThen also swallow what comes up from the Java layer and map it to boUnavailable. The caller has a path for every TBioOutcome and none for an exception. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+12
-5
@@ -782,9 +782,17 @@ end;
|
||||
|
||||
procedure TForm8.FetchAndDecrypt(const AUrl, ATok, APwd: string;
|
||||
ASilent: Boolean);
|
||||
var
|
||||
LCanAuth: Boolean;
|
||||
begin
|
||||
SetBusy(True);
|
||||
if not ASilent then Status('Telechargement...');
|
||||
// NE JAMAIS FERMER LE CACHE DERRIERE UNE PORTE QU'ON NE SAIT PAS OUVRIR.
|
||||
// Demander une cle protegee par authentification alors que l'invite ne peut
|
||||
// pas s'afficher (permission absente, aucune protection configuree) produit
|
||||
// un fichier definitivement illisible. Evalue ici, sur le thread principal :
|
||||
// l'interrogation du service passe par la couche Java.
|
||||
LCanAuth := BiometricAvailable;
|
||||
TThread.CreateAnonymousThread(
|
||||
procedure
|
||||
var
|
||||
@@ -888,16 +896,15 @@ begin
|
||||
// Ecrit APRES un dechiffrement reussi seulement, et avec son ETag :
|
||||
// les deux doivent rester coherents.
|
||||
try
|
||||
// True : on DEMANDE la protection par authentification. PMA.Store
|
||||
// retombe tout seul sur une cle simple si l'appareil n'a ni
|
||||
// empreinte ni code, plutot que de renoncer au cache.
|
||||
// Le mot de passe part avec le coffre : c'est lui qui permettra au
|
||||
// prochain lancement de rafraichir sans rien demander.
|
||||
SaveVault(LPlain, FETag, APwd, True);
|
||||
SaveVault(LPlain, FETag, APwd, LCanAuth);
|
||||
if VaultNeedsAuth then
|
||||
Log(' cache ecrit - protege par biometrie/code')
|
||||
else if LCanAuth then
|
||||
Log(' cache ecrit - cle simple (Keystore a refuse la contrainte)')
|
||||
else
|
||||
Log(' cache ecrit - AUCUNE protection sur cet appareil');
|
||||
Log(' cache ecrit - AUCUNE protection : pas d''authentification ici');
|
||||
except
|
||||
// La classe compte autant que le message : "methode introuvable"
|
||||
// designe une signature JNI fausse, pas un probleme de stockage.
|
||||
|
||||
Reference in New Issue
Block a user