Beispiel #1
0
        /// <summary>
        /// Decripta tutti i file tenendo traccia sulla griglia del vecchio AGL per ognuno
        /// Tale operazione può essere effettuata solo al collegamento del dispositivo
        /// </summary>
        void DecryptAllFiles()
        {
            for (int i = 0; i < dataGrid.Rows.Count; i++)
            {
                var row = dataGrid.Rows[i];
                if (row.Cells[0].Value == null)
                {
                    continue;
                }

                var filename = DevicePath + row.Cells[0].Value.ToString();

                var aglService = new Services.FileAGLService(filename);
                if (aglService.Exists() == false)
                {
                    continue;
                }
                var decryptoService = new Services.FileDecryptService(filename);

                string currentPassword = string.Empty;

                if (OwnerMode)
                {
                    // in tal caso mi basa una sola delle chiavi associate per accedere al file
                    var keys = GetKeysByRowIndex(i);
                    if (keys == null || keys.Count == 0)
                    {
                        dataGrid.Rows.RemoveAt(i);
                        continue;
                    }

                    currentPassword = keys[0];
                }
                else
                {
                    currentPassword = UserPassword;

                    // memorizza l'AGL del file
                    var restoreService = new Services.FileSSRestoreService(DeviceName, row.Cells[0].Value.ToString());
                    restoreService.Store(aglService.GetBytes());

                    RestoreData.Add(restoreService);
                }

                if (decryptoService.Decrypt(currentPassword, OwnerMode) && !OwnerMode)
                {
                    RestoreData[RestoreData.Count - 1].SetKey(decryptoService.Key);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Decripta tutti i file tenendo traccia sulla griglia del vecchio AGL per ognuno
        /// Tale operazione può essere effettuata solo al collegamento del dispositivo
        /// </summary>
        void DecryptAllFiles()
        {
            for (int i = 0; i < dataGrid.Rows.Count; i++)
            {
                var row = dataGrid.Rows[i];
                if (row.Cells[0].Value == null)
                    continue;

                var filename = DevicePath + row.Cells[0].Value.ToString();

                var aglService = new Services.FileAGLService(filename);
                if (aglService.Exists() == false)
                    continue;
                var decryptoService = new Services.FileDecryptService(filename);

                string currentPassword = string.Empty;

                if(OwnerMode)
                {
                    // in tal caso mi basa una sola delle chiavi associate per accedere al file
                    var keys = GetKeysByRowIndex(i);
                    if (keys == null || keys.Count == 0)
                    {
                        dataGrid.Rows.RemoveAt(i);
                        continue;
                    }

                    currentPassword = keys[0];
                }
                else
                {
                    currentPassword = UserPassword;

                    // memorizza l'AGL del file
                    var restoreService = new Services.FileSSRestoreService(DeviceName, row.Cells[0].Value.ToString());
                    restoreService.Store(aglService.GetBytes());

                    RestoreData.Add(restoreService);
                }

                if(decryptoService.Decrypt(currentPassword, OwnerMode) && !OwnerMode)
                {
                    RestoreData[RestoreData.Count - 1].SetKey(decryptoService.Key);
                }
            }
        }