private static byte[] UseKeyfile(byte[] passwordBytes, string keyfilePath) { try { byte[] keyfileBytes = Keyfiles.ReadKeyfile(keyfilePath); return(passwordBytes == null ? keyfileBytes : CombineKeyfileAndPassword(passwordBytes, keyfileBytes)); } catch (Exception ex) when(ExceptionFilters.FileAccess(ex)) { DisplayMessage.Exception(ex.GetType().Name, "Unable to read keyfile. The keyfile has not been used."); return(passwordBytes); } }
private static byte[] GetKeyfileBytes(byte[] passwordBytes, string keyfilePath) { if (!string.IsNullOrEmpty(keyfilePath)) { byte[] keyfileBytes = Keyfiles.ReadKeyfile(keyfilePath); if (keyfileBytes != null) { MemoryEncryption.DecryptByteArray(ref passwordBytes); // Combine password and keyfile bytes passwordBytes = HashingAlgorithms.Blake2(passwordBytes, keyfileBytes); MemoryEncryption.EncryptByteArray(ref passwordBytes); Utilities.ZeroArray(keyfileBytes); } } return(passwordBytes); }
private static byte[] KeyfileAsPassword(string keyfilePath) { // If only a keyfile was selected, use the keyfile bytes as the password byte[] passwordBytes = Keyfiles.ReadKeyfile(keyfilePath); return(HashPasswordBytes(passwordBytes)); }