Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.3.0 #55

Merged
merged 8 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ app.*.map.json
/android/app/release

# For missing translations
/missingTranslations.json
/missingTranslations.json
/test/assets/*
Binary file added android/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions android/app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="12.7"
android:viewportHeight="12.7">
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="3.175"
android:translateY="3.175">
<path
android:pathData="M6.35,8.229C7.135,7.514 7.64,7.014 7.865,6.727c0.225,-0.287 0.337,-0.575 0.337,-0.867 0,-0.282 -0.099,-0.523 -0.298,-0.721 -0.198,-0.198 -0.439,-0.298 -0.721,-0.298 -0.168,0 -0.324,0.033 -0.47,0.099 -0.146,0.066 -0.267,0.157 -0.364,0.271 -0.097,-0.115 -0.218,-0.205 -0.364,-0.271 -0.146,-0.066 -0.302,-0.099 -0.47,-0.099 -0.282,0 -0.523,0.099 -0.721,0.298 -0.198,0.198 -0.298,0.439 -0.298,0.721 0,0.141 0.02,0.276 0.06,0.403 0.04,0.128 0.126,0.276 0.258,0.443 0.132,0.168 0.32,0.37 0.562,0.609 0.243,0.238 0.567,0.542 0.972,0.913z"
android:strokeWidth="0.0132292"
android:fillColor="#d93235"/>
<path
android:pathData="m6.35,11.628c-1.235,-0.309 -2.249,-1.025 -3.043,-2.15 -0.794,-1.124 -1.191,-2.357 -1.191,-3.698v-3.149l4.233,-1.587 4.233,1.587v3.149c0,1.341 -0.397,2.573 -1.191,3.698 -0.794,1.124 -1.808,1.841 -3.043,2.15zM6.35,10.808c1.014,-0.335 1.841,-0.968 2.48,-1.898C9.47,7.979 9.79,6.936 9.79,5.781v-2.593l-3.44,-1.296 -3.44,1.296v2.593c0,1.155 0.32,2.198 0.959,3.129 0.639,0.93 1.466,1.563 2.48,1.898z"
android:strokeWidth="0.0132292"
android:fillColor="#000000"/>
</group>
</vector>
5 changes: 5 additions & 0 deletions android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions android/app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFD8D9</color>
</resources>
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/10300.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed bugs and improved stability. The video viewer is now stable although less secure but secure enough to be used.
1 change: 1 addition & 0 deletions fastlane/metadata/android/fr-FR/changelogs/10300.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bugs reglés et amelioration générale de la stabilité. Le lecteur vidéo est maintenant stable même si il est moins sécurisé mais assez pour être utilisé.
74 changes: 32 additions & 42 deletions lib/file_explorer/file_explorer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -447,61 +447,51 @@ class FileExplorerState extends State<FileExplorer> {

final receivePort = ReceivePort();

Isolate.spawn(exportEncryptedThumbnails, (
receivePort.sendPort,
List<FileExportArgs>.generate(
filesToExport.length, (index) {
FileThumbnail fileToExport =
filesToExport[index];
return (
fileToExport.localPath,
encryptionKey,
fileToExport.data,
List<FileExportArgs> dataToExport = [];

for(FileThumbnail fileToExport in filesToExport) {
String unsafeData = (await VaultsManager.nonceStorage.read(key: fileToExport.localPath))!;
Map<String, dynamic> unsafeDataClone = Map.from(fileToExport.data);
unsafeDataClone['nonce'] = unsafeData;
dataToExport.add((
fileToExport.localPath,
encryptionKey,
unsafeDataClone,
fileToExport.file.readAsBytesSync(),
widget.vault.unlockMechanismType,
widget.vault.additionalUnlockData
);
})
));
));
}

Isolate.spawn(exportEncryptedThumbnails,
(receivePort.sendPort, dataToExport));

List<Uint8List> decryptedFiles = [];

await for (List<int> decryptedFile
in receivePort) {
decryptedFiles
.add(Uint8List.fromList(decryptedFile));
await for(List<int> decryptedFile in receivePort) {
decryptedFiles.add(Uint8List.fromList(decryptedFile));
setState(() {
loaderCurrentLoad = decryptedFiles.length;
});
if (loaderTarget == loaderCurrentLoad)
break;
if(loaderTarget == loaderCurrentLoad) break;
}

setState(() {
loaderTarget = null;
loaderCurrentLoad = null;
});

DocumentFileSavePlus()
.saveMultipleFiles(
dataList: decryptedFiles,
fileNameList: [
for (FileThumbnail thumbnail
in filesToExport)
setExtension(
basenameWithoutExtension(
thumbnail.data['name']),
'.lcef')
],
mimeTypeList: List.filled(
filesToExport.length, 'plain'))
.then((value) {
DocumentFileSavePlus().saveMultipleFiles(
dataList: decryptedFiles,
fileNameList: [for (FileThumbnail thumbnail in filesToExport) setExtension(basenameWithoutExtension(thumbnail.data['name']), '.lcef')],
mimeTypeList: List.filled(filesToExport.length, 'plain')
).then((value) {
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(S
.of(context)
.savedToFolder)));
content: Text(S
.of(context)
.savedToFolderWarning, style: const TextStyle(color: Colors.amber))));
}
});
}
Expand Down Expand Up @@ -557,9 +547,10 @@ class FileExplorerState extends State<FileExplorer> {

for (FileThumbnail thumbnail in filesToExport) {
Stream<List<int>> exportedFile =
SingleThreadedRecovery.loadAndDecryptFile(
await SingleThreadedRecovery.loadAndDecryptFile(
widget.vault.encryptionKey!,
thumbnail.file);
thumbnail.file,
Mac(thumbnail.data['mac']));

File fileToSaveTo =
File(join(saveLocation.path, thumbnail.name));
Expand All @@ -570,8 +561,7 @@ class FileExplorerState extends State<FileExplorer> {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
Text(S.of(context).savedToFolder)));
content: Text(S.of(context).savedToFolder)));
}
},
child: Text(S.of(context).exportAsCleartext)),
Expand Down Expand Up @@ -739,8 +729,8 @@ class FileExplorerState extends State<FileExplorer> {
child: LinearProgressIndicator(
value: loaderCurrentLoad! / loaderTarget!)),
backgroundColor: isSelectionMode
? Theme.of(context).colorScheme.primaryContainer
: null),
? Theme.of(context).colorScheme.primaryContainer
: null),
floatingActionButton: GestureDetector(
onLongPress: () {
saveFolder(context);
Expand Down
8 changes: 6 additions & 2 deletions lib/file_explorer/file_thumbnail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ class FileThumbnail extends StatelessWidget {
return Column(
children: [
placeholder.gridIcon,
Text(name),
],
Expanded(child:
Center(
child: Text(name),
)
)
]
);
} else {
return Column(
Expand Down
5 changes: 3 additions & 2 deletions lib/file_explorer/file_unlock_wizard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ class FileUnlockWizardState extends State<FileUnlockWizard> {

Future<(Map<String, dynamic> metadata, List<int> data)> getOrUnlockFile(
List<int> fileToUnlock, SecretKey key) async {
print(unlockedMap);
for (List<int> unlockedFile in List.from(unlockedMap.keys)) {
if (listEquals(fileToUnlock, unlockedFile)) {
return unlockedMap[unlockedFile]!;
}
}

print(unlockedMap);
unlockedMap[fileToUnlock] =
(await FileExporter.importFile(fileToUnlock, key))!;

print(unlockedMap);
return unlockedMap[fileToUnlock]!;
}

Expand Down
18 changes: 10 additions & 8 deletions lib/file_recovery/file_exporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class FileExporter {
// Signature
finalExportedFile.addAll('Life Chest Encrypted File'.codeUnits);
String encodedMetadata = jsonEncode(fileMapData);
List<int> encryptedMetadata = (await VaultsManager.cipher.encrypt(
List<int> encryptedMetadata = (await VaultsManager.secondaryCipher.encrypt(
utf8.encode(encodedMetadata),
secretKey: encryptionKey,
nonce: Uint8List(VaultsManager.cipher.nonceLength)))
nonce: Uint8List(VaultsManager.secondaryCipher.nonceLength)))
.cipherText;
// The hash of the key to check if 2 files were encrypted using the same key (Always 64 chars long)
finalExportedFile.addAll(sha256
Expand All @@ -79,7 +79,7 @@ class FileExporter {

// The file fake name used internally by the app to identify it without giving its clear name, logically this isn't sensitive information so we can give the encrypted and clear file fake name so the app can say if a file is valid or not by detecting the "|" char and dividing the file name length by 2.
finalExportedFile.addAll(fileFakeName.codeUnits);
finalExportedFile.addAll((await VaultsManager.cipher.encrypt(
finalExportedFile.addAll((await VaultsManager.secondaryCipher.encrypt(
fileFakeName.codeUnits,
secretKey: encryptionKey,
nonce: Uint8List(VaultsManager.cipher.nonceLength)))
Expand Down Expand Up @@ -131,9 +131,9 @@ class FileExporter {
_splitListBySeparator(exportedFile, '|'.codeUnits[0], 4);
// No need to round, the length is even whatever happening because of the source multiplication by 2 rule
SecretBox encryptedName = SecretBox(List.from(elements[3].sublist(32, 64)),
nonce: Uint8List(VaultsManager.cipher.nonceLength), mac: Mac.empty);
nonce: Uint8List(VaultsManager.secondaryCipher.nonceLength), mac: Mac.empty);
return listEquals(
await VaultsManager.cipher
await VaultsManager.secondaryCipher
.decrypt(encryptedName, secretKey: encryptionKey),
elements[3].sublist(0, 32));
}
Expand All @@ -150,18 +150,20 @@ class FileExporter {
int metadataLength = int.parse(String.fromCharCodes(elements[2]));

Map<String, dynamic> metadata = jsonDecode(String.fromCharCodes(utf8
.decode(await VaultsManager.cipher.decrypt(
.decode(await VaultsManager.secondaryCipher.decrypt(
SecretBox(elements[3].sublist(64, 64 + metadataLength),
nonce: Uint8List(VaultsManager.cipher.nonceLength),
nonce: Uint8List(VaultsManager.secondaryCipher.nonceLength),
mac: Mac.empty),
secretKey: encryptionKey))
.codeUnits));

List<int> fileData = await VaultsManager.cipher.decrypt(
SecretBox(elements[3].sublist(64 + metadataLength),
nonce: Uint8List(VaultsManager.cipher.nonceLength), mac: Mac.empty),
nonce: metadata.containsKey('nonce') ? base64Decode(metadata['nonce']) : Uint8List(VaultsManager.secondaryCipher.nonceLength), mac: Mac(List.from(metadata['mac']))),
secretKey: encryptionKey);

metadata.remove('nonce');

return (metadata, fileData);
}

Expand Down
Loading