From b2c432416eaaa918dcc42b2223442f81316f86db Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 23 Aug 2024 17:00:31 +0200 Subject: [PATCH 1/3] Add description for Bio key import --- lib/l10n/app_de.arb | 1 + lib/l10n/app_en.arb | 1 + lib/l10n/app_fr.arb | 1 + lib/l10n/app_ja.arb | 1 + lib/l10n/app_pl.arb | 1 + lib/piv/views/import_file_dialog.dart | 28 ++++++++++++++++----------- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index dfd1c554..69bd71c7 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -660,6 +660,7 @@ "s_allow_fingerprint": null, "p_cert_options_desc": "Verwendeter Schlüssel-Algorithmus, Ausgabeformat und Ablaufdatum (nur Zertifikat).", "p_cert_options_bio_desc": null, + "p_key_options_bio_desc": null, "s_overwrite_slot": "Slot überschreiben", "p_overwrite_slot_desc": "Damit wird vorhandener Inhalt im Slot {slot} dauerhaft überschrieben.", "@p_overwrite_slot_desc": { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 8cca4659..e938113c 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -660,6 +660,7 @@ "s_allow_fingerprint": "Allow fingerprint", "p_cert_options_desc": "Key algorithm to use, output format, and expiration date (certificate only).", "p_cert_options_bio_desc": "Key algorithm to use, output format, expiration date (certificate only), and if biometrics can be used instead of PIN.", + "p_key_options_bio_desc": "Allow biometrics to be used instead of PIN.", "s_overwrite_slot": "Overwrite slot", "p_overwrite_slot_desc": "This will permanently overwrite existing content in slot {slot}.", "@p_overwrite_slot_desc": { diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 2ad889f3..057ef137 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -660,6 +660,7 @@ "s_allow_fingerprint": null, "p_cert_options_desc": "Algorithme clé à utiliser, format de sortie et date d'expiration (certificat uniquement).", "p_cert_options_bio_desc": null, + "p_key_options_bio_desc": null, "s_overwrite_slot": "Écraser slot", "p_overwrite_slot_desc": "Cela écrasera définitivement le contenu du slot {slot}.", "@p_overwrite_slot_desc": { diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index 3609ae84..a8600482 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -660,6 +660,7 @@ "s_allow_fingerprint": null, "p_cert_options_desc": "使用する鍵アルゴリズム、出力形式、および有効期限(証明書のみ)。", "p_cert_options_bio_desc": null, + "p_key_options_bio_desc": null, "s_overwrite_slot": "スロットを上書き", "p_overwrite_slot_desc": "これにより、スロット{slot}内の既存コンテンツが完全に上書きされます。", "@p_overwrite_slot_desc": { diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index f227a5c0..48ab53a5 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -660,6 +660,7 @@ "s_allow_fingerprint": null, "p_cert_options_desc": "Algorytm klucza do użycia, format wyjściowy i data wygaśnięcia (tylko certyfikat).", "p_cert_options_bio_desc": null, + "p_key_options_bio_desc": null, "s_overwrite_slot": "Nadpisz slot", "p_overwrite_slot_desc": "Spowoduje to trwałe nadpisanie istniejącej zawartości w slocie {slot}.", "@p_overwrite_slot_desc": { diff --git a/lib/piv/views/import_file_dialog.dart b/lib/piv/views/import_file_dialog.dart index 448caa3e..c328ef8d 100644 --- a/lib/piv/views/import_file_dialog.dart +++ b/lib/piv/views/import_file_dialog.dart @@ -292,16 +292,6 @@ class _ImportFileDialogState extends ConsumerState { ), ], ), - if (!unsupportedKey && widget.showMatch) - FilterChip( - label: Text(l10n.s_allow_fingerprint), - selected: _allowMatch, - onSelected: (value) { - setState(() { - _allowMatch = value; - }); - }, - ), ], if (certInfo != null) ...[ Text( @@ -315,7 +305,23 @@ class _ImportFileDialogState extends ConsumerState { 140, // Needed for layout, adapt if text sizes changes child: CertInfoTable(certInfo, null), ), - ] + ], + if (keyType != null && !unsupportedKey && widget.showMatch) ...[ + Text( + l10n.s_options, + style: textTheme.bodyLarge, + ), + Text(l10n.p_key_options_bio_desc), + FilterChip( + label: Text(l10n.s_allow_fingerprint), + selected: _allowMatch, + onSelected: (value) { + setState(() { + _allowMatch = value; + }); + }, + ), + ], ] .map((e) => Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), From e0c0b2ae2dae0ebd78be8b1270b83f3c97c2a47a Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 23 Aug 2024 17:14:44 +0200 Subject: [PATCH 2/3] PIV bio additions Disable dialog buttons when busy. Show MATCH status in details view. --- lib/l10n/app_de.arb | 1 + lib/l10n/app_en.arb | 1 + lib/l10n/app_fr.arb | 1 + lib/l10n/app_ja.arb | 1 + lib/l10n/app_pl.arb | 1 + lib/piv/keys.dart | 1 + lib/piv/views/cert_info_view.dart | 11 ++++++++++- lib/piv/views/generate_key_dialog.dart | 12 +++++++----- lib/piv/views/import_file_dialog.dart | 12 +++++++----- lib/piv/views/piv_screen.dart | 1 + lib/piv/views/slot_dialog.dart | 1 + 11 files changed, 32 insertions(+), 11 deletions(-) diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 69bd71c7..28c5a47d 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -500,6 +500,7 @@ } }, "@_fingerprints": {}, + "s_biometrics": null, "l_fingerprint": "Fingerabdruck: {label}", "@l_fingerprint": { "placeholders": { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e938113c..9c277ef5 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -500,6 +500,7 @@ } }, "@_fingerprints": {}, + "s_biometrics": "Biometrics", "l_fingerprint": "Fingerprint: {label}", "@l_fingerprint": { "placeholders": { diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 057ef137..7c0c86cb 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -500,6 +500,7 @@ } }, "@_fingerprints": {}, + "s_biometrics": null, "l_fingerprint": "Empreinte digitale\u00a0: {label}", "@l_fingerprint": { "placeholders": { diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index a8600482..9a9f680d 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -500,6 +500,7 @@ } }, "@_fingerprints": {}, + "s_biometrics": null, "l_fingerprint": "指紋:{label}", "@l_fingerprint": { "placeholders": { diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index 48ab53a5..eba4cb44 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -500,6 +500,7 @@ } }, "@_fingerprints": {}, + "s_biometrics": null, "l_fingerprint": "Odcisk palca: {label}", "@l_fingerprint": { "placeholders": { diff --git a/lib/piv/keys.dart b/lib/piv/keys.dart index 33293c12..f822b172 100644 --- a/lib/piv/keys.dart +++ b/lib/piv/keys.dart @@ -99,6 +99,7 @@ const appListItem95 = Key('$_prefix.95.applistitem'); // SlotMetadata body keys const slotMetadataKeyType = Key('$_prefix.slotMetadata.keyType'); +const slotMetadataBiometrics = Key('$_prefix.slotMetadata.biometrics'); // CertInfo body keys const certInfoKeyType = Key('$_prefix.certInfo.keyType'); diff --git a/lib/piv/views/cert_info_view.dart b/lib/piv/views/cert_info_view.dart index 72b1c08b..88018a19 100644 --- a/lib/piv/views/cert_info_view.dart +++ b/lib/piv/views/cert_info_view.dart @@ -28,9 +28,10 @@ class CertInfoTable extends ConsumerWidget { final CertInfo? certInfo; final SlotMetadata? metadata; final bool alwaysIncludePrivate; + final bool supportsBio; const CertInfoTable(this.certInfo, this.metadata, - {super.key, this.alwaysIncludePrivate = false}); + {super.key, this.alwaysIncludePrivate = false, this.supportsBio = false}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -46,6 +47,14 @@ class CertInfoTable extends ConsumerWidget { metadata.keyType.getDisplayName(l10n), keys.slotMetadataKeyType ), + if (metadata != null && supportsBio) + l10n.s_biometrics: ( + [PinPolicy.matchAlways, PinPolicy.matchOnce] + .contains(metadata.pinPolicy) + ? l10n.s_enabled + : l10n.s_disabled, + keys.slotMetadataBiometrics + ), if (metadata == null && alwaysIncludePrivate) l10n.s_private_key: (l10n.s_none, keys.slotMetadataKeyType), if (certInfo != null) ...{ diff --git a/lib/piv/views/generate_key_dialog.dart b/lib/piv/views/generate_key_dialog.dart index 5d12de51..92630c37 100644 --- a/lib/piv/views/generate_key_dialog.dart +++ b/lib/piv/views/generate_key_dialog.dart @@ -249,11 +249,13 @@ class _GenerateKeyDialogState extends ConsumerState { FilterChip( label: Text(l10n.s_allow_fingerprint), selected: _allowMatch, - onSelected: (value) { - setState(() { - _allowMatch = value; - }); - }, + onSelected: _generating + ? null + : (value) { + setState(() { + _allowMatch = value; + }); + }, ), ]), Padding( diff --git a/lib/piv/views/import_file_dialog.dart b/lib/piv/views/import_file_dialog.dart index c328ef8d..6fc4baa8 100644 --- a/lib/piv/views/import_file_dialog.dart +++ b/lib/piv/views/import_file_dialog.dart @@ -315,11 +315,13 @@ class _ImportFileDialogState extends ConsumerState { FilterChip( label: Text(l10n.s_allow_fingerprint), selected: _allowMatch, - onSelected: (value) { - setState(() { - _allowMatch = value; - }); - }, + onSelected: _importing + ? null + : (value) { + setState(() { + _allowMatch = value; + }); + }, ), ], ] diff --git a/lib/piv/views/piv_screen.dart b/lib/piv/views/piv_screen.dart index 65c28f17..e4a8139f 100644 --- a/lib/piv/views/piv_screen.dart +++ b/lib/piv/views/piv_screen.dart @@ -158,6 +158,7 @@ class _PivScreenState extends ConsumerState { selected.metadata, alwaysIncludePrivate: pivState.supportsMetadata, + supportsBio: pivState.supportsBio, ), if (selected.certInfo == null) const SizedBox(height: 16) diff --git a/lib/piv/views/slot_dialog.dart b/lib/piv/views/slot_dialog.dart index 8b30f7aa..c1cabe4e 100644 --- a/lib/piv/views/slot_dialog.dart +++ b/lib/piv/views/slot_dialog.dart @@ -98,6 +98,7 @@ class SlotDialog extends ConsumerWidget { certInfo, metadata, alwaysIncludePrivate: pivState.supportsMetadata, + supportsBio: pivState.supportsBio, ), if (certInfo == null) const SizedBox(height: 16), ], From 6e20ee198ff4b28106814ef00f4ed1e241322b04 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 23 Aug 2024 17:27:11 +0200 Subject: [PATCH 3/3] Don't show bio status for PinPolicy.never --- lib/piv/views/cert_info_view.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/piv/views/cert_info_view.dart b/lib/piv/views/cert_info_view.dart index 88018a19..945b1a7c 100644 --- a/lib/piv/views/cert_info_view.dart +++ b/lib/piv/views/cert_info_view.dart @@ -47,7 +47,9 @@ class CertInfoTable extends ConsumerWidget { metadata.keyType.getDisplayName(l10n), keys.slotMetadataKeyType ), - if (metadata != null && supportsBio) + if (metadata != null && + metadata.pinPolicy != PinPolicy.never && + supportsBio) l10n.s_biometrics: ( [PinPolicy.matchAlways, PinPolicy.matchOnce] .contains(metadata.pinPolicy)