public static bool IsKeyShared(this IDataStore dataStore, LogOnIdentity decryptIdentity) { if (!dataStore.IsEncrypted()) { return(false); } OpenFileProperties properties = OpenFileProperties.Create(dataStore); if (properties.IsLegacyV1 || properties.V2AsymetricKeyWrapCount <= 1) { return(false); } if (decryptIdentity == LogOnIdentity.Empty) { return(false); } using (Stream stream = dataStore.OpenRead()) { using (IAxCryptDocument document = New <AxCryptFactory>().CreateDocument(decryptIdentity.DecryptionParameters(), stream)) { if (!document.PassphraseIsValid) { return(false); } return(document.AsymmetricRecipients.Select(ar => ar.Email).Distinct().Skip(1).Any()); } } }
private static void UpdateListViewItem(ListViewItem item, ActiveFile activeFile) { OpenFileProperties openProperties = OpenFileProperties.Create(activeFile.EncryptedFileInfo); item.SubItems[nameof(ColumnName.EncryptedPath)].Text = activeFile.EncryptedFileInfo.FullName; item.SubItems[nameof(ColumnName.AccessedDate)].Text = activeFile.Properties.LastActivityTimeUtc.ToLocalTime().ToString(CultureInfo.CurrentCulture); item.SubItems[nameof(ColumnName.AccessedDate)].Tag = activeFile.Properties.LastActivityTimeUtc; item.SubItems[nameof(ColumnName.ModifiedDate)].Text = activeFile.EncryptedFileInfo.LastWriteTimeUtc.ToLocalTime().ToString(CultureInfo.CurrentCulture); item.SubItems[nameof(ColumnName.ModifiedDate)].Tag = activeFile.EncryptedFileInfo.LastWriteTimeUtc; LogOnIdentity decryptIdentity = ValidateActiveFileIdentity(activeFile.Identity); UpdateStatusDependentPropertiesOfListViewItem(item, activeFile, activeFile.EncryptedFileInfo.IsKeyShared(decryptIdentity)); try { if (activeFile.Properties.CryptoId != Guid.Empty) { item.SubItems[nameof(ColumnName.CryptoName)].Text = Resolve.CryptoFactory.Create(activeFile.Properties.CryptoId).Name; if (activeFile.VisualState.HasFlag(ActiveFileVisualStates.LowEncryption)) { item.SubItems[nameof(ColumnName.CryptoName)].ForeColor = Styling.WarningColor; } } } catch (ArgumentException aex) { New <IReport>().Exception(aex); item.SubItems[nameof(ColumnName.CryptoName)].Text = Texts.UnknownCrypto; } }
private static void EnsureConsistencyOfDestination(FileLock destinationFileLock) { try { OpenFileProperties.Create(destinationFileLock.DataStore); } catch (Exception ex) { HandleException(ex, destinationFileLock.DataStore); } }
public static bool IsLegacyV1(this IDataStore dataStore) { return(dataStore.IsEncrypted() && OpenFileProperties.Create(dataStore).IsLegacyV1); }