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

[Feature Request] Encrypted Backups #40

Closed
TheLastProject opened this issue Oct 24, 2020 · 12 comments · Fixed by #494
Closed

[Feature Request] Encrypted Backups #40

TheLastProject opened this issue Oct 24, 2020 · 12 comments · Fixed by #494
Assignees
Labels
good first issue Good for newcomers hacktoberfest type: enhancement New feature or request

Comments

@TheLastProject
Copy link
Member

Issue by trymeouteh
Wednesday Dec 12, 2018 at 21:36 GMT
Originally opened as brarcher/loyalty-card-locker#285


When you export a file it is not encrypted and this can be a concert when your backing this file up to cloud storage. Please add the ability to encrypt a file when it is backed up with a password and when you import the file it will as for the password to import the data.

@TheLastProject TheLastProject added type: enhancement New feature or request state: help wanted I looked into this issue but couldn't solve it quickly labels Oct 24, 2020
@TheLastProject
Copy link
Member Author

Comment by trymeouteh
Tuesday Sep 17, 2019 at 02:37 GMT


I would like to suggest using 7z. 7z are compressed files, therefore all you will need to do is integrate 7zip into the app and when it does the export, you will set a password and it will create the backup file and then out it inside a compressed 7z file with a password.

@trymeouteh
Copy link

I would like to suggest 7z or gz as an option since they both support encrypted password protection.

@djechelon
Copy link
Contributor

Shouldn't be Google Drive backups encrypted with the old phone's PIN? I am definitely sure about it. If privacy is a concern, one would not (as I did before A10) enable GDrive backups

@TheLastProject
Copy link
Member Author

I am thinking it may make most sense to add an option to send the backup data to another app instead of writing it to SD card directly. Something like OpenKeyChain. That way we can also be sure the encrypting and decrypting is done by an app following best security practices.

@IllusiveMan196
Copy link
Contributor

Maybe Aegis Authenticator can be used as a reference? It has password encrypted backup option, scheduled backups and biometric unlock. Before doing it all though best would be to contact devs - beemdevelopment. Basically you could solve this issue and app password protection as well.

@seniorm0ment
Copy link

Yes, I would agree. The encryption would be best to be sent and handled to another app such as OpenKeychain with PGP.

Another more complicated idea would be to offer the data as an export into a format that can be imported into Keepass (CSV?). But it would allow more universability if a user wanted to migrate the data away from Catima for whatever reason.

@TheLastProject
Copy link
Member Author

Well, it looks like I'm going to implement this as a way to password-protect a .zip export. Reason as follows:

  1. Stocard supplies password-protected zip files when you ask for your data, so I have to support opening password protected zip files
  2. Next Catima release will support images (see Store photographs of the card #15) and it just makes sense to change exporting from .csv to .zip to make it easier for end-users to use their data in other programs if wanted (and it will take less space than base64-encoding the image as text)
  3. The library I chose to read password-protected zip files (zip4j) supports using AES encryption mode to create password protected zips too very easily: https://github.com/srikanth-lingala/zip4j#creating-a-password-protected-zip-file--adding-files-to-an-existing-zip-with-password-protection

Not quite sure how secure the AES implementation is though, but I hope this will still make y'all happy anyway without making me spend a lot of time on this?

@TheLastProject TheLastProject added good first issue Good for newcomers and removed state: help wanted I looked into this issue but couldn't solve it quickly labels Jul 11, 2021
@TheLastProject
Copy link
Member Author

I am tagging this as "good first issue" because the only things needed to implement this would be a dialog to enter the desired password and setting the password for zip4j to use in the export. Should not be very hard for anyone interested in this feature to pick up.

@ankittiwari101
Copy link
Contributor

Hii.. I want to take up this issue as it is both good-first-issue and hacktoberfest tagged.

Could you please quickly get me upto speed on what needs to be done and the concerned Activity(s) where I would need to focus my energies?

Also I am new to this whole Encryption business so please provide resources/links for me to be able to learn the required basics.

@TheLastProject
Copy link
Member Author

Well, in this case the easiest thing would probably be to start with the unit test. That way you can try your changes very quickly.

So first, copy the multipleCardsExportImport to multipleCardsExportImportPasswordProtected or something like that: https://github.com/TheLastProject/Catima/blob/2128f0a601b5affd660ad6dd15e88026f6e3b92d/app/src/test/java/protect/card_locker/ImportExportTest.java#L326-L355

Make up some password, replace null in the importData line with that password and add a new password parameter with the same password to exportData.

Then, modify the exportData function to encrypt the data with a password if the password value is not null, as written in the zip4j documentation: https://github.com/srikanth-lingala/zip4j#creating-a-password-protected-zip-file--adding-files-to-an-existing-zip-with-password-protection.

After that, expand the export code to create a dialog and ask the user for a password they want to use: https://github.com/TheLastProject/Catima/blob/2128f0a601b5affd660ad6dd15e88026f6e3b92d/app/src/main/java/protect/card_locker/ImportExportActivity.java#L408-L422.

Feel free to make the pull request early in development and mark it as Draft so I can guide you along the way.

@ankittiwari101
Copy link
Contributor

Hii..Thanks for the detailed guidelines!

So just as per your advice above, I -

  1. Created a new method multipleCardsExportImportPasswordProtected() in ImportExportTest.java
  2. Added a 5th Parameter char[] password in exportData() method of MultiFormatExporter Class.
  3. Stored a final String password = "some_password" within the multipleCardsExportImportPasswordProtected() method itself and passed it as a parameter to importData() as well as exportData() method calls of this method.
  4. Everywhere else that exportData() is called in the project, password parameter being passed is null.

Now where I am facing some difficulty is passing password to zip4j.
From the examples I saw on zip4j github page, all have one particular line in common -
new ZipFile("filename.zip").addFile("filename.ext");

Password parameters can be added but this line seems to be non - optional. However, I couldn't find this line anywhere in the project. So I am having hard time determining where to add the encryption code. Please guide me on this.

@TheLastProject
Copy link
Member Author

The zip4j documentation indeed seems to be slightly lacking. Looking at https://github.com/srikanth-lingala/zip4j/blob/2ec68db8b7dcac1e6867362c3cb1c80d5d793762/src/main/java/net/lingala/zip4j/io/outputstream/ZipOutputStream.java#L52-L54, it seems you can define a password in ZipOutputStream. Maybe that'll work?

@TheLastProject TheLastProject linked a pull request Oct 14, 2021 that will close this issue
@bors bors bot closed this as completed in #494 Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants