PIV: Don't default to changing management key type

This commit is contained in:
Dain Nilsson 2024-01-26 16:37:23 +01:00
parent 4e5e25b4ae
commit ae65b99c6b
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -53,7 +53,7 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
bool _currentInvalidFormat = false; bool _currentInvalidFormat = false;
bool _newInvalidFormat = false; bool _newInvalidFormat = false;
int _attemptsRemaining = -1; int _attemptsRemaining = -1;
ManagementKeyType _keyType = ManagementKeyType.tdes; late ManagementKeyType _keyType;
final _currentController = TextEditingController(); final _currentController = TextEditingController();
final _keyController = TextEditingController(); final _keyController = TextEditingController();
bool _isObscure = true; bool _isObscure = true;
@ -63,6 +63,8 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
super.initState(); super.initState();
_hasMetadata = widget.pivState.metadata != null; _hasMetadata = widget.pivState.metadata != null;
_keyType = widget.pivState.metadata?.managementKeyMetadata.keyType ??
defaultManagementKeyType;
_defaultKeyUsed = _defaultKeyUsed =
widget.pivState.metadata?.managementKeyMetadata.defaultValue ?? false; widget.pivState.metadata?.managementKeyMetadata.defaultValue ?? false;
_usesStoredKey = widget.pivState.protectedKey; _usesStoredKey = widget.pivState.protectedKey;
@ -142,7 +144,7 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
final l10n = AppLocalizations.of(context)!; final l10n = AppLocalizations.of(context)!;
final currentType = final currentType =
widget.pivState.metadata?.managementKeyMetadata.keyType ?? widget.pivState.metadata?.managementKeyMetadata.keyType ??
ManagementKeyType.tdes; defaultManagementKeyType;
final hexLength = _keyType.keyLength * 2; final hexLength = _keyType.keyLength * 2;
final protected = widget.pivState.protectedKey; final protected = widget.pivState.protectedKey;
final currentKeyOrPin = _currentController.text; final currentKeyOrPin = _currentController.text;
@ -306,7 +308,7 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
ChoiceFilterChip<ManagementKeyType>( ChoiceFilterChip<ManagementKeyType>(
items: ManagementKeyType.values, items: ManagementKeyType.values,
value: _keyType, value: _keyType,
selected: _keyType != defaultManagementKeyType, selected: _keyType != currentType,
itemBuilder: (value) => Text(value.getDisplayName(l10n)), itemBuilder: (value) => Text(value.getDisplayName(l10n)),
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {