private static void DecryptInputFile(FileStream inputFile, byte[] ephemeralPublicKey, byte[] keyEncryptionKey) { string inputFilePath = inputFile.Name; string outputFilePath = FileDecryption.GetOutputFilePath(inputFilePath); DecryptFile.Initialize(inputFile, outputFilePath, ephemeralPublicKey, keyEncryptionKey); FileDecryption.DecryptionSuccessful(inputFilePath, outputFilePath); }
private static void FileDecryptionWithPassword(char[] password, string keyfilePath, string[] filePaths) { bool validUserInput = FileEncryptionValidation.FileEncryptionWithPassword(password, keyfilePath, filePaths); if (!validUserInput) { return; } byte[] passwordBytes = Password.Hash(password, keyfilePath); FileDecryption.DecryptEachFileWithPassword(filePaths, passwordBytes); }
private static void FileDecryptionWithPrivateKey(string privateKeyPath, string[] filePaths) { bool validUserInput = FileEncryptionValidation.FileEncryptionWithPrivateKey(privateKeyPath, filePaths); if (!validUserInput) { return; } byte[] privateKey = AsymmetricKeyValidation.EncryptionPrivateKeyFile(privateKeyPath); if (privateKey == null) { return; } FileDecryption.DecryptEachFileWithPrivateKey(filePaths, privateKey); }
private static void DecryptInputFile(string inputFilePath, byte[] keyEncryptionKey) { try { string outputFilePath = FileDecryption.GetOutputFilePath(inputFilePath); DecryptFile.Initialize(inputFilePath, outputFilePath, keyEncryptionKey); FileDecryption.DecryptionSuccessful(inputFilePath, outputFilePath); } catch (Exception ex) when(ExceptionFilters.Cryptography(ex)) { Logging.LogException(ex.ToString(), Logging.Severity.Error); if (ex is ArgumentException || ex is ArgumentOutOfRangeException) { DisplayMessage.FilePathMessage(inputFilePath, ex.Message); return; } DisplayMessage.FilePathException(inputFilePath, ex.GetType().Name, "Unable to decrypt the file."); } }
private static void FileDecryptionWithPublicKey(string recipientPrivateKeyPath, char[] senderPublicKeyString, string[] filePaths) { bool validUserInput = FileEncryptionValidation.FileEncryptionWithPublicKey(recipientPrivateKeyPath, senderPublicKeyString, filePaths); if (!validUserInput) { return; } byte[] recipientPrivateKey = AsymmetricKeyValidation.EncryptionPrivateKeyFile(recipientPrivateKeyPath); if (recipientPrivateKey == null) { return; } byte[] senderPublicKey = AsymmetricKeyValidation.EncryptionPublicKeyString(senderPublicKeyString); if (senderPublicKey == null) { return; } FileDecryption.DecryptEachFileWithPublicKey(filePaths, recipientPrivateKey, senderPublicKey); }