private BooleanResult mountCloud(string guid, Config.Clouds cloudSelected, string cloudPath) { // Get password from user // var promptPassword = new PromptPassword(); if (promptPassword.ShowDialog() != DialogResult.OK) { // Cancelled return(new BooleanResult() { Success = true }); } string password = promptPassword.CloudPassword; // * // // GET NEXT FREE DRIVE LETTER string targetDrive = Toolbox.GetNextFreeDriveLetter(); if (targetDrive == null) { return(new BooleanResult() { Success = false, Message = "ERROR: Cannot find a free drive letter!" }); } // * // // Helper result object BooleanResult res = null; // Check to see if it is already mounted // Dictionary <string, string> mounts = EncryptFS.GetAllMountedEncFS(); if (mounts == null) { return(new BooleanResult() { Success = false, Message = "ERROR: Cannot figure out which EncFS instances are mounted!" }); } if (mounts.ContainsKey(guid)) { return(new BooleanResult() { Success = false, Message = "This encrypted folder appears to already be mounted!" }); } // * // // Get and decrypt user's master key (using user password) // string masterKey = null; string encHeader = (string)Registry.GetValue(Config.CURR_USR_REG_DRIVE_ROOT + guid, "encHeader", null); if (string.IsNullOrEmpty(encHeader)) { return(new BooleanResult() { Success = false, Message = "ERROR: User's header information could not be found!" }); } masterKey = Toolbox.PasswordDecryptKey(encHeader, password); // Make sure we got a key back if (masterKey == null) { return(new BooleanResult() { Success = false, Message = "ERROR: Failed to decrypt master key!" }); } // * // // Mount their freshly-created encrypted drive res = EncryptFS.MountEncryptedFS(guid, targetDrive, masterKey, "Secure " + cloudSelected.ToString()); if (res == null || !res.Success) { return(res); } // * // return(new BooleanResult() { Success = true }); }
private BooleanResult mountCloud(string guid, Config.Clouds cloudSelected, string cloudPath) { // Get password from user // var promptPassword = new PromptPassword(); if (promptPassword.ShowDialog() != DialogResult.OK) { // Cancelled return new BooleanResult() { Success = true }; } string password = promptPassword.CloudPassword; // * // // GET NEXT FREE DRIVE LETTER string targetDrive = Toolbox.GetNextFreeDriveLetter(); if (targetDrive == null) { return new BooleanResult() { Success = false, Message = "ERROR: Cannot find a free drive letter!" }; } // * // // Helper result object BooleanResult res = null; // Check to see if it is already mounted // Dictionary<string, string> mounts = EncryptFS.GetAllMountedEncFS(); if (mounts == null) { return new BooleanResult() { Success = false, Message = "ERROR: Cannot figure out which EncFS instances are mounted!" }; } if (mounts.ContainsKey(guid)) { return new BooleanResult() { Success = false, Message = "This encrypted folder appears to already be mounted!" }; } // * // // Get and decrypt user's master key (using user password) // string masterKey = null; string encHeader = (string)Registry.GetValue(Config.CURR_USR_REG_DRIVE_ROOT + guid, "encHeader", null); if (string.IsNullOrEmpty(encHeader)) { return new BooleanResult() { Success = false, Message = "ERROR: User's header information could not be found!" }; } masterKey = Toolbox.PasswordDecryptKey(encHeader, password); // Make sure we got a key back if (masterKey == null) { return new BooleanResult() { Success = false, Message = "ERROR: Failed to decrypt master key!" }; } // * // // Mount their freshly-created encrypted drive res = EncryptFS.MountEncryptedFS(guid, targetDrive, masterKey, "Secure " + cloudSelected.ToString()); if (res == null || !res.Success) { return res; } // * // return new BooleanResult() { Success = true }; }