Cryptography service now handles random byte generation

Protected strings are now protected in memory
This commit is contained in:
Geoffroy BONNEVILLE
2020-05-18 14:14:28 +02:00
parent ceaf7dabd3
commit 9126307b4c
22 changed files with 134 additions and 105 deletions

View File

@@ -126,7 +126,12 @@ namespace ModernKeePass.ViewModels
{
AdditionalFields =
new ObservableCollection<EntryFieldVm>(
SelectedItem.AdditionalFields.Select(f => new EntryFieldVm(f.Name, f.Value, f.IsProtected)));
SelectedItem.AdditionalFields.Select(f =>
{
var field = new EntryFieldVm(_cryptography);
field.Initialize(f.Name, f.Value, f.IsProtected);
return field;
}));
Attachments = new ObservableCollection<Attachment>(SelectedItem.Attachments.Select(f => new Attachment
{
Name = f.Key,
@@ -161,8 +166,7 @@ namespace ModernKeePass.ViewModels
DeleteAdditionalField.RaiseCanExecuteChanged();
}
}
public string Title
{
get { return SelectedItem.Title.Value; }
@@ -186,11 +190,12 @@ namespace ModernKeePass.ViewModels
public string Password
{
get { return SelectedItem.Password.Value; }
get { return _cryptography.UnProtect(SelectedItem.Password.Value).GetAwaiter().GetResult(); }
set
{
SelectedItem.Password.Value = value;
SetFieldValue(nameof(Password), value, true).Wait();
var protectedPassword = _cryptography.Protect(value).GetAwaiter().GetResult();
SelectedItem.Password.Value = protectedPassword;
SetFieldValue(nameof(Password), protectedPassword, true).Wait();
RaisePropertyChanged(nameof(Password));
RaisePropertyChanged(nameof(PasswordComplexityIndicator));
}
@@ -316,6 +321,7 @@ namespace ModernKeePass.ViewModels
private readonly INotificationService _notification;
private readonly IFileProxy _file;
private readonly ISettingsProxy _settings;
private readonly ICryptographyClient _cryptography;
private GroupVm _parent;
private EntryVm _selectedItem;
private int _selectedIndex;
@@ -324,7 +330,7 @@ namespace ModernKeePass.ViewModels
private bool _isRevealPassword;
private bool _isDirty;
public EntryDetailVm(IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog, INotificationService notification, IFileProxy file, ISettingsProxy settings)
public EntryDetailVm(IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog, INotificationService notification, IFileProxy file, ISettingsProxy settings, ICryptographyClient cryptography)
{
_mediator = mediator;
_navigation = navigation;
@@ -333,6 +339,7 @@ namespace ModernKeePass.ViewModels
_notification = notification;
_file = file;
_settings = settings;
_cryptography = cryptography;
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
@@ -417,7 +424,7 @@ namespace ModernKeePass.ViewModels
private void AddField()
{
AdditionalFields.Add(new EntryFieldVm(string.Empty, string.Empty, false));
AdditionalFields.Add(new EntryFieldVm(_cryptography));
AdditionalFieldSelectedIndex = AdditionalFields.Count - 1;
}

View File

@@ -140,7 +140,7 @@ namespace ModernKeePass.ViewModels
Entries = new ObservableCollection<EntryVm>(_group.Entries);
Entries.CollectionChanged += Entries_CollectionChanged;
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
Groups = new ObservableCollection<GroupVm>(_group.Groups);
Groups.CollectionChanged += Groups_CollectionChanged;
}
@@ -222,7 +222,7 @@ namespace ModernKeePass.ViewModels
{
case NotifyCollectionChangedAction.Remove:
var oldIndex = e.OldStartingIndex;
_reorderedGroup = _group.SubGroups[oldIndex];
_reorderedGroup = _group.Groups[oldIndex];
break;
case NotifyCollectionChangedAction.Add:
if (_reorderedGroup == null)
@@ -251,7 +251,7 @@ namespace ModernKeePass.ViewModels
private async Task SortGroupsAsync()
{
await _mediator.Send(new SortGroupsCommand {Group = _group});
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
Groups = new ObservableCollection<GroupVm>(_group.Groups);
RaisePropertyChanged(nameof(Groups));
SaveCommand.RaiseCanExecuteChanged();
}

View File

@@ -128,7 +128,7 @@
<MenuFlyoutItem x:Uid="EntryItemCopyPassword">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<actions:ClipboardAction Text="{Binding Password}" />
<actions:ClipboardAction Text="{Binding Password}" IsProtected="True" />
<actions:ToastAction x:Uid="ToastCopyPassword" Title="{Binding Title}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>

View File

@@ -1,8 +1 @@
Support for additional fields
Support for attachments
Add an expiration timer for clipboard data
Ability to manually reorder groups
Ability to set max history count and size
Design changes
Update to KeePassLib version 2.45
Bug corrections
Data is now protected in memory as well as at rest

View File

@@ -1,8 +1 @@
Ajout des champs additionnels
Ajout des pi<70>ces-jointes
Ajout d'une expiration du presse papier
Possibilite de reorganiser les groupes manuellement
Possibilite de parametrer le nombre max et la taille de l'historique
Quelques changements de design
Mise a jour de la KeePassLib version 2.45
Correction de bugs
Protection des donnees en memoire en plus du chiffrement de la base de donnees