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] Filename decryption in the browser + File decryption #1452

Closed
FWeinb opened this issue May 30, 2017 · 23 comments
Closed

[Feature] Filename decryption in the browser + File decryption #1452

FWeinb opened this issue May 30, 2017 · 23 comments

Comments

@FWeinb
Copy link

FWeinb commented May 30, 2017

It would be great if it where possible to decrypt filenames using javascript in the browser. I made some initial tests using gopherjs to cross compile the cipher.go with some minimal wrapper code. You can see an example of it running in the browser here. This approach has some performance issues and the resulting javascript is very big (1MB bundle).
This is actually my very first go code so maybe there could be some improvements.

An implementation using something like the Web Crypto API or one of these crypto libs would be much better I think. I will try to implement the decryption schema rclone is using in pure javascript.

@yonjah
Copy link
Contributor

yonjah commented May 31, 2017

Sounds interesting.
Are you planning to create some kind of extension that will be able to decrypt file names on the cloud provider web app ?

If you are not using the built in crypto API ( which I think is only good for generating random values anyway) I would recommend using SJCL It seem to be the only library made by professionals. I only compared it to CryptoJS ( which you should never use any way) and the performance were much better.

@ncw
Copy link
Member

ncw commented May 31, 2017

That is fun! Webassembly suport for go would probably be the best way of approaching this in the long run.

What are your plans for this? Are you planning to develop this further?

@FWeinb
Copy link
Author

FWeinb commented May 31, 2017

My initial idea was to just make a little script that would decrypt all names in the browser. This could be used as a user script to improve browsing experiences on acd/gdrive.

The current implementation is to slow for that. I will try to implement it using pure JS next.
As I understand it the steps needed to have a pure JS implementation would be:

  • 1. Decrypting pass1 and pass2 using AES and the internal key bytes of rclone
  • 2. Construct a key using pass1 and pass2 out of it using scrypt
  • 3. Transform using EME
  • 4. Pad using pkcs7

Step 1. and 2. are done. I did not find a suitable way to use EME with sjcl. Maybe this needs to be ported from here.

Edit: It is working!

@FWeinb
Copy link
Author

FWeinb commented May 31, 2017

I did a port of the EME go module to javascript. The whole think got quite fast with just a few performance tricks. Generating the key using scrypt is the slowest but that part can be cached for the userscript I have in mind.

Here is a new little web app. The js used is approx. 40kb. This is only currently tested in latest Chrome.

I do think it would be possible to build a streaming decrypter for decrypting files in the web browser but I did not look into it much further.

@FWeinb FWeinb changed the title [Feature] Filename decryption in the browser [Feature] Filename decryption in the browser + File decryption Jun 2, 2017
@FWeinb
Copy link
Author

FWeinb commented Jun 2, 2017

File decryption is possible too. That was actual easy than implementing EME in javascript. Will tidy up the code. Here is a gif:

rclone
Click for better quality

@Cadish
Copy link

Cadish commented Jun 8, 2017

Looks promising! Would indeed be great to have an extension/userscript to automatically decrypt file names.

@Cadish
Copy link

Cadish commented Jul 4, 2017

Any update on this?

@2600box
Copy link

2600box commented Jul 4, 2017

there is certainly demand

@FWeinb
Copy link
Author

FWeinb commented Jul 4, 2017

@Cadish @2600box
I am currently in the middle of exams till the end of this weeks. After that I will have some time to publish this.

@Cadish
Copy link

Cadish commented Aug 11, 2017

How are you progressing on this? Anything you can share, so we can try to help you on this?

@MulverineX
Copy link

Any progress on this?

@FWeinb
Copy link
Author

FWeinb commented Jan 31, 2018

Sorry for the long delay, I had some time to work on this and got video streaming and general file handling working. Currently this is only working for local files (drag and drop) but I hope I can make this work for streaming files over http too.

I made a little video seeing it in action:
2018-01-31 03_22_58
(Click for better quality)

You can try it for yourself here but be aware that all browsers are very picky in what they take as input files. If the browser can't play the decrypted file it can't play an encrypted file.

@ncw
Copy link
Member

ncw commented Jan 31, 2018

@FWeinb looks great! I've been interested in gopherjs too recently so I have a branch where rclone completely compiles with gopherjs. It doesn't run though ;-) Not quite sure where I'm going, but having rclone run in the browser would be interesting.

Do you have code for your experiment you can show?

@FWeinb
Copy link
Author

FWeinb commented Jan 31, 2018

@ncw Thanks!
I just published a library to github rclone-js Documentation is needed but I got quite good test coverage.

[Edit]
The library is published on NPM now. I do need to write a little bit of documentation and will publish the simple test app I made.

@sscotth
Copy link

sscotth commented Feb 7, 2018

I threw a Chrome extension together to decrypt filenames on gdrive using @FWeinb 's work. Check it out and let me know how it works for you. I'll publish it if I can get a couple people to test it.

https://github.com/sscotth/rclone-chrome-extension

@Cadish
Copy link

Cadish commented Feb 7, 2018

noob-alert
@sscotth, how can I install this? I'm willing to test your extension

@sscotth
Copy link

sscotth commented Feb 7, 2018

@Cadish

Grab a copy either by cloning the repository or by downloading and extracting the zip file.
Next, open the chrome://extensions in chrome and turn on "Developer mode".
Then click "Load Unpacked" or "Load Unpacked Extension" and select the directory on your computer where you saved the source code.

@Cadish
Copy link

Cadish commented Feb 7, 2018

Was able to load the extension successfully, but I don't get a "RClone Decrypt" button :/

image

@Cadish
Copy link

Cadish commented Feb 8, 2018

@sscotth The button is there now, but it doesn't decrypt the filenames nor foldernames.

@ncw
Copy link
Member

ncw commented Feb 10, 2018

@sscotth that is very cool - and great job @FWeinb making a reusable library.

I could put a link to both projects in the crypt documentation - what do you think? Fancy sending a PR?

@gkgr
Copy link

gkgr commented Mar 14, 2019

Sorry for the necropost but it's sad to see that solution for online filename decryption have died. Could we get some renowned support for such a feature?

@FWeinb
Copy link
Author

FWeinb commented Mar 14, 2019

@kamenoccc
I made a library that handles the decryption of files in browser. It is available here: https://github.com/FWeinb/rclone-js

You can build a web ui with that. Integrating this with the web apis from google drive is up to the implementation I have not looked into that.

@Animosity022
Copy link
Collaborator

This looks answered. Closing out. If you still have a question, please feel free to post on the forums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants