├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── TrezorSymmetricFileEncryption.py
├── basics.py
├── comments.md
├── dialog.ui
├── dialogs.py
├── encoding.py
├── icons
├── TrezorSymmetricFileEncryption.176x60.png
├── TrezorSymmetricFileEncryption.216x100.svg
├── TrezorSymmetricFileEncryption.ico
├── TrezorSymmetricFileEncryption.icon.ico
├── TrezorSymmetricFileEncryption.icon.png
├── TrezorSymmetricFileEncryption.icon.svg
├── TrezorSymmetricFileEncryption.png
├── TrezorSymmetricFileEncryption.svg
├── file.svg
├── trezor.bg.png
├── trezor.bg.svg
└── trezor.svg
├── processing.py
├── screenshots
├── screenshot_TrezorSymmetricFileEncryption_aboutWindow.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow1.version01a.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow1.version02b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow1.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow1.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow2.version01a.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow2.version02b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow2.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow2.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow3.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow3.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow4.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow4.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow5.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow5.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow6.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow6.version04b.png
├── screenshot_TrezorSymmetricFileEncryption_mainWindow7.version03b.png
├── screenshot_TrezorSymmetricFileEncryption_passphraseEntryWindow.png
└── screenshot_TrezorSymmetricFileEncryption_pinEntryWindow.png
├── settings.py
├── singleFileExecutableLinuxCreate.sh
├── singleFileExecutableLinuxReadme.txt
├── testTrezorSymmetricFileEncryption.sh
├── trezor_app_generic.py
├── trezor_app_specific.py
├── trezor_chooser_dialog.ui
├── trezor_gui.py
├── trezor_passphrase_dialog.ui
├── trezor_pin_dialog.ui
└── utils.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 |
27 | # PyInstaller
28 | # Usually these files are written by a python script from a template
29 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
30 | *.manifest
31 | *.spec
32 |
33 | # Installer logs
34 | pip-log.txt
35 | pip-delete-this-directory.txt
36 |
37 | # Unit test / coverage reports
38 | htmlcov/
39 | .tox/
40 | .coverage
41 | .coverage.*
42 | .cache
43 | nosetests.xml
44 | coverage.xml
45 | *,cover
46 | .hypothesis/
47 |
48 | # Translations
49 | *.mo
50 | *.pot
51 |
52 | # Django stuff:
53 | *.log
54 | local_settings.py
55 |
56 | # Flask stuff:
57 | instance/
58 | .webassets-cache
59 |
60 | # Scrapy stuff:
61 | .scrapy
62 |
63 | # Sphinx documentation
64 | docs/_build/
65 |
66 | # PyBuilder
67 | target/
68 |
69 | # IPython Notebook
70 | .ipynb_checkpoints
71 |
72 | # pyenv
73 | .python-version
74 |
75 | # celery beat schedule file
76 | celerybeat-schedule
77 |
78 | # dotenv
79 | .env
80 |
81 | # virtualenv
82 | venv/
83 | ENV/
84 |
85 | # Spyder project settings
86 | .spyderproject
87 |
88 | # Rope project settings
89 | .ropeproject
90 |
91 | # UI auto-generated files
92 | ui_*.py
93 |
94 | # Misc
95 | *.org
96 | *.bak
97 |
98 | # Left over test files
99 | __*img*
100 | *.tsfe
101 | __*.test.txt
102 | __*.random.bin
103 | TQFYqK1nha1IfLy_qBxdGwlGRytelGRJ
104 | __time_measurements__.txt
105 |
106 | test.log
107 |
108 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | UI_GENERATED := \
2 | ui_trezor_chooser_dialog.py \
3 | ui_trezor_pin_dialog.py \
4 | ui_trezor_passphrase_dialog.py \
5 | ui_dialog.py \
6 | #end of UI_GENERATED
7 |
8 | all: $(UI_GENERATED)
9 |
10 | ui_%.py: %.ui
11 | pyuic5 -o $@ $<
12 |
13 | clean:
14 | rm -f $(UI_GENERATED)
15 | rm -rf __pycache__
16 | rm -f *.pyc
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 
2 |
3 | # Trezor Symmetric File Encryption
4 |
5 | **:star: :star: :star: Use your [Trezor](http://www.trezor.io/) device to symmetrically encrypt and decrypt files :star: :star: :star:**
6 |
7 | **:lock: :unlock: :key: Hardware-backed file encryption with Trezor :key: :unlock: :lock:**
8 |
9 | `TrezorSymmetricFileEncryption` is a small, simple tool that
10 | allows you to symmetrically encrypt and decrypt files.
11 |
12 | # Features
13 |
14 | * Trezor convenience
15 | * Trezor security
16 | * One Trezor for all your needs: [gpg](https://github.com/romanz/trezor-agent), [ssh](https://github.com/romanz/trezor-agent), **symmetric encryption**, etc.
17 | * Encrypt your files for your use, guarantee your privacy
18 | * Requires confirmation button click on Trezor device to perform decrypt operation.
19 | * For the paranoid there is now an option to encrypt the file(s) twice.
20 | In any mode, the file is first AES encrypted on the PC with a key generated
21 | and en/decrypted by the Trezor device requiring a click on the `Confirm`
22 | button of the Trezor. In the paranoid mode, the file is then encrypted
23 | a second time. This second encryption is done within the Trezor device
24 | and not on the PC, with no key ever touching the memory of the PC.
25 | The PC just feeds the file
26 | to the Trezor and receives the results, but the PC is not doing any actual
27 | encryption. The actual en/decryption takes place on the Trezor chip.
28 | This paranoid mode is significantly slower than the regular mode.
29 | * It supports both GUI mode and Terminal mode.
30 | * Since it is a program that has a full CLI (command line interface)
31 | it is easy to create scripts or to automate workflows. Keep in mind though
32 | that you will have to confirm on the Trezor by clicking its `Confirm` button.
33 | * Optionally obfuscates/encrypts filenames on encryption to hide meta-data
34 | (i.e. the file names)
35 | * Use it before and after you store sensitive information on
36 | DropBox, Google Drive or similar.
37 |
38 | # Screenshot
39 |
40 | Below a sample screenshot. More screenshots [here](screenshots).
41 |
42 | 
43 |
44 | # Runtime requirements
45 |
46 | * Use of passphrases must have been already enabled on your [Trezor](https://www.trezor.io) device.
47 | * [Trezor](https://www.trezor.io) device
48 | * [Python](https://www.python.org/) v2.7 or 3.4+
49 | * [PyCrypto](https://pypi.python.org/pypi/pycrypto)
50 | * [PyQt5](https://pypi.python.org/pypi/PyQt5)
51 | * [Qt5](https://doc.qt.io/qt-5/)
52 | * [trezorlib from python-trezor](https://github.com/trezor/python-trezor)
53 | * [Versions 0.5.0 and older used PyQy4 instead of PyQy5. Read the README.md
54 | file of v0.5.0 for build requirements, dependencies, etc. Basically anything
55 | relating to PyQt5 has to be replaced with the corresponding component in PyQt4.
56 | `pyuic5` becomes `pyuic4`. `pyqt5-dev-tools` becomes `pyqt4-dev-tools`
57 | and so forth.]
58 |
59 | # Building
60 |
61 | Even though the whole code is in Python, there are few Qt5 `.ui` form files that
62 | need to be transformed into Python files. There is `Makefile`, you just need to run
63 |
64 | make
65 |
66 | ## Build requirements
67 |
68 | * PyQt5 development tools are necessary, namely `pyuic5` (look for a package named
69 | `pyqt5-dev-tools`, `PyQt5-devel` or similar). Required to run `make`.
70 | * Depending on one's set-up one might need: `qttools5-dev-tools`
71 | (also sets up some of the Qt5 environment variables)
72 | * Depending on one's set-up one might need: `python-pyqt5` (Qt5 bindings for Python 2)
73 | * Depending on one's set-up one might need: `python3-pyqt5` (Qt5 bindings for Python 3)
74 | * Depending on one's set-up one might need: `python-pyqt5.qtsvg` (to display SVG logos in Python 2)
75 | * Depending on one's set-up one might need: `python3-pyqt5.qtsvg` (to display SVG logos in Python 3)
76 |
77 | # Running
78 |
79 | Run:
80 |
81 | python TrezorSymmetricFileEncryption.py
82 | or
83 |
84 | python3 TrezorSymmetricFileEncryption.py
85 |
86 | Run-time command line options are
87 |
88 | ```
89 | TrezorSymmetricFileEncryption.py [-v] [-h] [-l ] [-t]
90 | [-e | -o | -d | -m | -n]
91 | [-2] [-s] [-w] [-p ] [-r] [-R] [q]
92 | -v, --version
93 | print the version number
94 | -h, --help
95 | print short help text
96 | -l, --logging
97 | set logging level, integer from 1 to 5, 1=full logging, 5=no logging
98 | -t, --terminal
99 | run in the terminal, except for a possible PIN query
100 | and a Passphrase query this avoids the GUI
101 | -e, --encrypt
102 | encrypt file and keep output filename as plaintext
103 | (appends .tsfe suffix to input file)
104 | -o, --obfuscatedencrypt
105 | encrypt file and obfuscate output file name
106 | -d, --decrypt
107 | decrypt file
108 | -m, --encnameonly
109 | just encrypt the plaintext filename, show what the obfuscated
110 | filename would be; does not encrypt the file itself;
111 | incompaible with `-d` and `-n`
112 | -n, --decnameonly
113 | just decrypt the obfuscated filename;
114 | does not decrypt the file itself;
115 | incompaible with `-o`, `-e`, and `-m`
116 | -2, --twice
117 | paranoid mode; encrypt file a second time on the Trezor chip itself;
118 | only relevant for `-e` and `-o`; ignored in all other cases.
119 | Consider filesize: The Trezor chip is slow. 1M takes roughly 75 seconds.
120 | -p, --passphrase
121 | master passphrase used for Trezor.
122 | It is recommended that you do not use this command line option
123 | but rather give the passphrase through a small window interaction.
124 | -r, --readpinfromstdin
125 | read the PIN, if needed, from the standard input, i.e. terminal,
126 | when in terminal mode `-t`. By default, even with `-t` set
127 | it is read via a GUI window.
128 | -R, --readpassphrasefromstdin
129 | read the passphrase, when needed, from the standard input,
130 | when in terminal mode `-t`. By default, even with `-t` set
131 | it is read via a GUI window.
132 | -s, --safety
133 | doublechecks the encryption process by decrypting the just
134 | encrypted file immediately and comparing it to original file;
135 | doublechecks the decryption process by encrypting the just
136 | decrypted file immediately and comparing it to original file;
137 | Ignored for `-m` and `-n`.
138 | Primarily useful for testing.
139 | -w, --wipe
140 | shred the inputfile after creating the output file
141 | i.e. shred the plaintext file after encryption or
142 | shred the encrypted file after decryption;
143 | only relevant for `-d`, `-e` and `-o`; ignored in all other cases.
144 | Use with extreme caution. May be used together with `-s`.
145 | -q, --noconfirm
146 | Eliminates the `Confirm` click on the Trezor button.
147 | This was only added to facilitate batch testing.
148 | It should be used EXCLUSIVELY for testing purposes.
149 | Do NOT use this option with real files!
150 | Furthermore, files encryped with `-n` cannot be decrypted
151 | without `-n`.
152 |
153 |
154 | one or multiple files to be encrypted or decrypted
155 |
156 | All arguments are optional.
157 |
158 | All output files are always placed in the same directory as the input files.
159 |
160 | By default the GUI will be used.
161 |
162 | You can avoid the GUI by using `-t`, forcing the Terminal mode.
163 | If you specify filename, possibly some `-o`, `-e`, or `-d` option, then
164 | only PIN and Passphrase will be collected through windows.
165 |
166 | Most of the time TrezorSymmetricFileEncryption can detect automatically if
167 | it needs to decrypt or encrypt by analyzing the given input file name.
168 | So, in most of the cases you do not need to specify any
169 | de/encryption option.
170 | TrezorSymmetricFileEncryption will simply do the right thing.
171 | In the very rare case that TrezorSymmetricFileEncryption determines
172 | the wrong encrypt/decrypt operation you can force it to use the right one
173 | by using either `-e` or `-d` or selecting the appropriate option in the GUI.
174 |
175 | If TrezorSymmetricFileEncryption automatically determines
176 | that it has to encrypt of file, it will chose by default the
177 | `-e` option, and create a plaintext encrypted files with an `.tsfe` suffix.
178 |
179 | If you want the output file name to be obfuscated you
180 | must use the `-o` (obfuscate) flag or select that option in the GUI.
181 |
182 | Be aware of computation time and file sizes when you use `-2` option.
183 | Encrypting on the Trezor takes time: 1M roughtly 75sec. 50M about 1h.
184 | Without `-2` it is very fast, a 1G file taking roughly 15 seconds.
185 |
186 | For safety the file permission of encrypted files is set to read-only.
187 |
188 | Examples:
189 | # specify everything in the GUI
190 | TrezorSymmetricFileEncryption.py
191 |
192 | # specify everything in the GUI, set logging to verbose Debug level
193 | TrezorSymmetricFileEncryption.py -l 1
194 |
195 | # encrypt contract producing contract.doc.tsfe
196 | TrezorSymmetricFileEncryption.py contract.doc
197 |
198 | # encrypt contract and obfuscate output producing e.g. TQFYqK1nha1IfLy_qBxdGwlGRytelGRJ
199 | TrezorSymmetricFileEncryption.py -o contract.doc
200 |
201 | # encrypt contract and obfuscate output producing e.g. TQFYqK1nha1IfLy_qBxdGwlGRytelGRJ
202 | # performs safety check and then shreds contract.doc
203 | TrezorSymmetricFileEncryption.py -e -o -s -w contract.doc
204 |
205 | # decrypt contract producing contract.doc
206 | TrezorSymmetricFileEncryption.py contract.doc.tsfe
207 |
208 | # decrypt obfuscated contract producing contract.doc
209 | TrezorSymmetricFileEncryption.py TQFYqK1nha1IfLy_qBxdGwlGRytelGRJ
210 |
211 | # shows plaintext name of encrypted file, e.g. contract.doc
212 | TrezorSymmetricFileEncryption.py -n TQFYqK1nha1IfLy_qBxdGwlGRytelGRJ
213 |
214 | Keyboard shortcuts of GUI:
215 | Apply, Save: Control-A, Control-S
216 | Cancel, Quit: Esc, Control-Q
217 | Copy to clipboard: Control-C
218 | Version, About: Control-V
219 | Set encrypt operation: Control-E
220 | Set decrypt operation: Control-D
221 | Set obfuscate option: Control-O
222 | Set twice option: Control-2
223 | Set safety option: Control-T
224 | Set wipe option: Control-W
225 | ```
226 |
227 | # Testing
228 |
229 | Run the `Bash` script
230 |
231 | ./testTrezorSymmetricFileEncryption.sh 1K
232 |
233 | or for a full lengthy test
234 |
235 | ./testTrezorSymmetricFileEncryption.sh
236 |
237 | # FAQ - Frequently Asked Questions
238 |
239 | **Question:** Shouldn't there be two executables? One for encrypting
240 | and another one for decrypting?
241 |
242 | **Answer:** No. There is only one Python file which does both encryption and decryption.
243 | - - -
244 | **Question:** What are the command line options?
245 |
246 | **Answer:** See description above. But in the vast majority of cases you
247 | do not need to set or use any command line options.
248 | TrezorSymmetricFileEncryption will in most cases automatically detect
249 | if it needs to encrypt or decrypt.
250 | - - -
251 | **Question:** Are there any RSA keys involved somewhere?
252 |
253 | **Answer:** No. There are no RSA keys, there is no asymmetric encryption.
254 | - - -
255 | **Question:** Can I send encrypted files to my friends and have them decrypt them?
256 |
257 | **Answer:** No. Only you have the Trezor that can decrypt the files.
258 | **You** encrypt the files, and **you** decrypt them later.
259 | TrezorSymmetricFileEncryption is not built for sharing.
260 | For sharing encrypted files use asymmetric encryption
261 | like [gpg](https://gnupg.org/).
262 | By the way, Trezor supports gpg encryption/decryption.
263 | In short, only the holder of the Trezor who also knows the PIN and the
264 | TrezorSymmetricFileEncryption master password (= Trezor passphrase) can
265 | decrypt the file(s).
266 | - - -
267 | **Question:** What crypto technology is used?
268 |
269 | **Answer:** At the heart of it all is the
270 | python-trezor/trezorlib/client.py/encrypt_keyvalue()
271 | function of the Python client library of [Trezor](https://www.trezor.io)
272 | and AES-CBC encryption.
273 | - - -
274 | **Question:** Is there a config file or a settings file?
275 |
276 | **Answer:** No, there are no config and no settings files.
277 | - - -
278 | **Question:** Does TrezorSymmetricFileEncryption require online connectivity,
279 | Internet access?
280 |
281 | **Answer:** No.
282 | - - -
283 | **Question:** How many files are there?
284 |
285 | **Answer:** If you have Python installed, then there are just a
286 | handful of Python files. Alternatively, if you don't want to
287 | install Python one can create a single-file-executable
288 | with tools like [pyinstaller](www.pyinstaller.org). In that case you just have a
289 | single-file-executablefile.
290 | - - -
291 | **Question:** In which language is TrezorSymmetricFileEncryption written?
292 |
293 | **Answer:** [Python](https://www.python.org/). It runs on Python 2.7 and 3.4+.
294 | - - -
295 | **Question:** Do I need to have a [Trezor](https://www.trezor.io/) in
296 | order to use TrezorSymmetricFileEncryption?
297 |
298 | **Answer:** Yes, a Trezor is required.
299 | - - -
300 | **Question:** Is there any limit on the file size for encryption or decryption?
301 |
302 | **Answer:** Yes. Currently it is 2G minus a few bytes. On old computers
303 | with very little memory, it might be less than 2G due to memory limitations.
304 | - - -
305 | **Question:** Can I see the source code?
306 |
307 | **Answer:** Yes, this is an open source software project.
308 | You can find and download all source code from
309 | [Github](https://github.com/8go/TrezorSymmetricFileEncryption) or
310 | any of its forks.
311 | - - -
312 | **Question:** Does the TrezorSymmetricFileEncryption contain ads?
313 |
314 | **Answer:** No.
315 | - - -
316 | **Question:** Does TrezorSymmetricFileEncryption cost money?
317 |
318 | **Answer:** No. It is free, libre, and open source.
319 | - - -
320 | **Question:** Does TrezorSymmetricFileEncryption call home?
321 | Send any information anywhere?
322 |
323 | **Answer:** No. Never. You can also use it on an air-gapped computer if you
324 | want to. It does not contain any networking code at all. It does not update
325 | itself automatically. It cannot send anything anywhere.
326 | - - -
327 | **Question:** Does TrezorSymmetricFileEncryption have a backdoor?
328 |
329 | **Answer:** No. Read the source code to convince yourself.
330 | - - -
331 | **Question:** How can I know that TrezorSymmetricFileEncryption does not contain a virus?
332 |
333 | **Answer:** Download the source from
334 | [Github](https://github.com/8go/TrezorSymmetricFileEncryption)
335 | and inspect the source code for viruses. Don't download it from unreliable sources.
336 | - - -
337 | **Question:** Can someone steal or duplicate the key used for encryption or decryption?
338 |
339 | **Answer:** No, the key never leaves the Trezor.
340 | - - -
341 | **Question:** Can a keyboard logger steal a key?
342 |
343 | **Answer:** No, it never leaves the Trezor.
344 | - - -
345 | **Question:** Can a screen grabber or a person looking over my shoulder steal a key?
346 |
347 | **Answer:** No, it never leaves the Trezor.
348 | - - -
349 | **Question:** What can be stolen? How can it be stolen?
350 |
351 | **Answer:** A virus or malware could steal your plain text file before you
352 | encrypt it or after you decrypt it. Once you have a safe encrypted copy
353 | you can consider shredding the plain text copy of the file(s). For extremely
354 | sensitive information consider using an air-gapped computer or
355 | a [LiveDvd OS](https://en.wikipedia.org/wiki/Live_DVD) if you have one available.
356 | - - -
357 | **Question:** Is TrezorSymmetricFileEncryption portable?
358 |
359 | **Answer:** Yes. It is just a handful of Python files
360 | or a single-file-executable.
361 | You can move it around via an USB stick, SD card, email or cloud service.
362 | - - -
363 | **Question:** Can I contribute to the project?
364 |
365 | **Answer:** Yes. It is open source.
366 | Go to [Github](https://github.com/8go/TrezorSymmetricFileEncryption).
367 | You can also help by getting the word out.
368 | If you like it or like the idea please spread the word on Twitter, Reddit,
369 | Facebook, etc. It will be appreciated.
370 | - - -
371 | **Question:** What if I lose my Trezor and my 24 Trezor seed words or
372 | my TrezorSymmetricFileEncryption master password (= Trezor passphrase)?
373 |
374 | **Answer:** Then you will not be able to decrypt your previously encrypted
375 | file. For practical purposes you have lost those files. Brute-forcing is
376 | not a viable work-around.
377 | - - -
378 | **Question:** What if I lose my Trezor or someone steals my Trezor?
379 |
380 | **Answer:** As long as the thief cannot guess your TrezorSymmetricFileEncryption master
381 | password (= Trezor passphrase) the thief cannot use it to decrypt your files.
382 | A good PIN helps too. If the thief can guess your PIN and thereafter is able
383 | to brute-force your TrezorSymmetricFileEncryption master password
384 | (= Trezor passphrase) then he can decrypt your files. So, use a good PIN and
385 | a good passphrase and you will be safe. After losing your Trezor you will need
386 | to get a new Trezor to decrypt your files. Decryption without a Trezor device
387 | could be done in pure software
388 | knowing the 24 seed words and the passphrase, but that software has not been
389 | written yet.
390 | - - -
391 | **Question:** On which platforms, operating systems is
392 | TrezorSymmetricFileEncryption available?
393 |
394 | **Answer:** On all platforms, operating systems where
395 | [Python](https://www.python.org/) and PyQt5 is available: Windows, Linux, Unix,
396 | Mac OS X. Internet searches show Python and PyQt5 for Android and iOS,
397 | but it has not been investigated, built, or tested on Android or iOS.
398 | Testing has only been done on Linux.
399 | - - -
400 | **Question:** Is it fast?
401 |
402 | **Answer:** Regular mode (encrypting once) is fast; like any AES implementation.
403 | Encrypting or decrypting a 1G file takes about 15 seconds, but
404 | your mileage may vary as speed depends on CPU and disk speed. If you
405 | encrypt a second time on the Trezor device itself, it is slow as the CPU
406 | performance on the Trezor device is limited. Encrypting a second time
407 | takes about 75 seconds per Megabyte.
408 | - - -
409 | **Question:** Are there any warranties or guarantees?
410 |
411 | **Answer:** No, there are no warranties or guarantees whatsoever.
412 | - - -
413 | **Question:** More questions?
414 |
415 | **Answer:** Let us know.
416 | - - -
417 |
418 | > on :octocat: with :heart:
419 |
--------------------------------------------------------------------------------
/TrezorSymmetricFileEncryption.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | '''
4 | Use TREZOR as a hardware device for symmetric file encryption
5 |
6 | Usage: python TrezorSymmetricFileEncryption.py
7 | Usage: python TrezorSymmetricFileEncryption.py --help
8 |
9 | Source and readme is on www.github.com, search for TrezorSymmetricFileEncryption
10 |
11 | '''
12 |
13 | from __future__ import absolute_import
14 | from __future__ import division
15 | from __future__ import print_function
16 |
17 | import sys
18 | import logging
19 | import codecs
20 |
21 | from PyQt5.QtWidgets import QApplication # for the clipboard and window
22 |
23 | from dialogs import Dialog
24 |
25 | import basics
26 | import settings
27 | import processing
28 | from trezor_app_specific import FileMap
29 | import trezor_app_generic
30 |
31 | """
32 | The file with the main function.
33 |
34 | Code should work on both Python 2.7 as well as 3.4.
35 | Requires PyQt5.
36 | (Old version supported PyQt4.)
37 | """
38 |
39 |
40 | def showGui(trezor, dialog, settings):
41 | """
42 | Initialize, ask for encrypt/decrypt options,
43 | ask for files to be decrypted/encrypted,
44 | ask for master passphrase = trezor passphrase.
45 |
46 | Makes sure a session is created on Trezor so that the passphrase
47 | will be cached until disconnect.
48 |
49 | @param trezor: Trezor client
50 | @param settings: Settings object to store command line arguments or
51 | items selected in GUI
52 | """
53 | settings.settings2Gui(dialog)
54 | if not dialog.exec_():
55 | # Esc or exception or Quit/Close/Done
56 | settings.mlogger.log("Shutting down due to user request "
57 | "(Done/Quit was called).", logging.DEBUG, "GUI IO")
58 | # sys.exit(4)
59 | settings.gui2Settings(dialog)
60 |
61 |
62 | def useTerminal(fileMap, settings):
63 | if settings.WArg:
64 | settings.mlogger.log("The option `--wipe` is set. In case of "
65 | "encryption, the original plaintext files will "
66 | "be shredded after encryption. In case of decryption, "
67 | "the encrypted files will be shredded after decryption. "
68 | "Abort if you are uncertain or don't understand.", logging.WARNING,
69 | "Dangerous arguments")
70 | processing.processAll(fileMap, settings, dialog=None)
71 |
72 |
73 | def main():
74 | if sys.version_info[0] < 3: # Py2-vs-Py3:
75 | # redirecting output to a file can cause unicode problems
76 | # read: https://stackoverflow.com/questions/5530708/
77 | # To fix it either run the scripts as: PYTHONIOENCODING=utf-8 python TrezorSymmetricFileEncryption.py
78 | # or add the following line of code.
79 | # Only shows up in python2 TrezorSymmetricFileEncryption.py >> log scenarios
80 | # Exception: 'ascii' codec can't encode characters in position 10-13: ordinal not in range(128)
81 | sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
82 |
83 | app = QApplication(sys.argv)
84 | if app is None: # just to get rid f the linter warning on above line
85 | print("Critical error: Qt cannot be initialized.")
86 | sets = settings.Settings() # initialize settings
87 | # parse command line
88 | args = settings.Args(sets)
89 | args.parseArgs(sys.argv[1:])
90 |
91 | trezor = trezor_app_generic.setupTrezor(sets.TArg, sets.mlogger)
92 | # trezor.clear_session() ## not needed
93 | trezor.prefillReadpinfromstdin(sets.RArg)
94 | trezor.prefillReadpassphrasefromstdin(sets.AArg)
95 | if sets.PArg is None:
96 | trezor.prefillPassphrase(u'')
97 | else:
98 | trezor.prefillPassphrase(sets.PArg)
99 |
100 | # if everything is specified in the command line then do not call the GUI
101 | if ((sets.PArg is None) or (len(sets.inputFiles) <= 0)) and (not sets.TArg):
102 | dialog = Dialog(trezor, sets)
103 | sets.mlogger.setQtextbrowser(dialog.textBrowser)
104 | sets.mlogger.setQtextheader(dialog.descrHeader())
105 | sets.mlogger.setQtextcontent(dialog.descrContent())
106 | sets.mlogger.setQtexttrailer(dialog.descrTrailer())
107 | else:
108 | sets.mlogger.log("Everything was specified or --terminal was set, "
109 | "hence the GUI will not be called.", logging.INFO, u"Arguments")
110 |
111 | sets.mlogger.log("Trezor label: %s" % trezor.features.label,
112 | logging.INFO, "Trezor IO")
113 | sets.mlogger.log("For each operation click 'Confirm' on Trezor "
114 | "to give permission.", logging.INFO, "Trezor IO")
115 |
116 | fileMap = FileMap(trezor, sets)
117 |
118 | if ((sets.PArg is None) or (len(sets.inputFiles) <= 0)) and (not sets.TArg):
119 | # something was not specified, so we call the GUI
120 | # or user wants GUI, so we call the GUI
121 | dialog.setFileMap(fileMap)
122 | dialog.setVersion(basics.VERSION_STR)
123 | showGui(trezor, dialog, sets)
124 | else:
125 | useTerminal(fileMap, sets)
126 | # cleanup
127 | sets.mlogger.log("Cleaning up before shutting down.", logging.DEBUG, "Info")
128 | trezor.close()
129 |
130 |
131 | if __name__ == '__main__':
132 | main()
133 |
--------------------------------------------------------------------------------
/basics.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | from __future__ import division
3 | from __future__ import print_function
4 |
5 | import logging
6 | from encoding import unpack
7 |
8 | """
9 | This file contains some constant variables like version numbers,
10 | default values, etc.
11 | """
12 |
13 | # Name of application
14 | NAME = u'TrezorSymmetricFileEncryption'
15 |
16 | # Name of software version, must be less than 16 bytes long
17 | VERSION_STR = u'v0.6.2'
18 |
19 | # Date of software version, only used in GUI
20 | VERSION_DATE_STR = u'June 2017'
21 |
22 | # default log level
23 | DEFAULT_LOG_LEVEL = logging.INFO # CRITICAL, ERROR, WARNING, INFO, DEBUG
24 |
25 | # short acronym used for name of logger
26 | LOGGER_ACRONYM = u'tsfe'
27 |
28 | # location of logo image
29 | LOGO_IMAGE = u'icons/TrezorSymmetricFileEncryption.216x100.svg'
30 |
31 | # file extension for encrypted files with plaintext filename
32 | FILEEXT = u'.tsfe'
33 |
34 | # Data storage version, format of TSFE file
35 | FILEFORMAT_VERSION = 1
36 |
37 |
38 | class Magic(object):
39 | """
40 | Few magic constant definitions so that we know which nodes to search
41 | for keys.
42 | """
43 |
44 | headerStr = b'TSFE'
45 | hdr = unpack("!I", headerStr)
46 |
47 | # first level encryption
48 | # unlock key for first level AES encryption, key from Trezor, en/decryption on PC
49 | levelOneNode = [hdr, unpack("!I", b'DEC1')]
50 | levelOneKey = "Decrypt file for first time?" # string to derive wrapping key from
51 |
52 | # second level encryption
53 | # second level AES encryption, de/encryption on trezor device
54 | levelTwoNode = [hdr, unpack("!I", b'DEC2')]
55 | levelTwoKey = "Decrypt file for second time?"
56 |
57 | # only used for filename encryption (no confirm button click desired)
58 | fileNameNode = [hdr, unpack("!I", b'FLNM')] # filename encryption for filename obfuscation
59 | fileNameKey = "Decrypt filename only?"
60 |
--------------------------------------------------------------------------------
/comments.md:
--------------------------------------------------------------------------------
1 | # Comments
2 |
3 | These are just internal comments taken during development.
4 |
5 | # Trezor limits
6 |
7 | In the function `trezor/python-trezor/trezorlib/client.py/encrypt_keyvalue(self, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b'')`
8 | the primary input is `value`. The length of `value` must be a multiple of 16
9 | (AES blocksize of 128 bits). It must be buffered to multiple-of-16-bytes if not.
10 | The same number of bytes that go in, come out, as usual for AES.
11 | E.g. The return of 144-bytes in, is 144-bytes out.
12 | Performance for encrypt and decrypt are the same, as usual for AES.
13 |
14 | # Crypto/Cipher/blockalgo.py limit
15 |
16 | The function `Crypto/Cipher/blockalgo.py/encrypt()` the input is limited to 2G (2**31).
17 |
18 | If a file larger than 2G is encrypted this exception is thrown
19 | ```
20 | ./TrezorSymmetricFileEncryption.py -t 4.4G.img # 4G input file
21 | Traceback (most recent call last):
22 | File "./TrezorSymmetricFileEncryption.py", line 1093, in
23 | doWork(trezor, settings, fileMap)
24 | File "./TrezorSymmetricFileEncryption.py", line 1051, in doWork
25 | convertFile(inputFile, fileMap)
26 | File "./TrezorSymmetricFileEncryption.py", line 1038, in convertFile
27 | encryptFile(inputFile, fileMap, False)
28 | File "./TrezorSymmetricFileEncryption.py", line 1012, in encryptFile
29 | fileMap.save(inputFile, obfuscate)
30 | File "/home/manfred/briefcase/workspace/src/github.com/8go/TrezorSymmetricFileEncryption/file_map.py", line 123, in save
31 | encrypted = self.encryptOuter(serialized, self.outerIv)
32 | File "/home/manfred/briefcase/workspace/src/github.com/8go/TrezorSymmetricFileEncryption/file_map.py", line 138, in encryptOuter
33 | return self.encrypt(plaintext, iv, self.outerKey)
34 | File "/home/manfred/briefcase/workspace/src/github.com/8go/TrezorSymmetricFileEncryption/file_map.py", line 146, in encrypt
35 | return cipher.encrypt(padded)
36 | File "/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py", line 244, in encrypt
37 | return self._cipher.encrypt(plaintext)
38 | OverflowError: size does not fit in an int
39 | ```
40 |
41 | In order to handle files larger than 2G, one would have to junk and reassemble to 2G junks before/after the `cipher.encrypt(padded)` call.
42 |
43 | # Size limits
44 |
45 | Currently files are limited to 2G minus a few bytes.
46 | There is also a limit in the fileformat used by TrezorSymmetricFileEncryption.
47 | It stores the data length as 4-bytes. So, if one would want to go beyond 4G one
48 | would have to change the TrezorSymmetricFileEncryption storage file format
49 | to store the data size as 8 bytes.
50 |
51 | # Performance
52 |
53 | ## 1-level En/Decryption
54 |
55 | AES is very fast.
56 | Most files take less than a seconds but depends on disk speed, CPU, etc.
57 | Encrypting/decrypting a 2G file with 1-level en/decryption took about 15 sec on a computer with a very slow disk but fast CPU.
58 | Encryption time and decryption time are usually the same.
59 |
60 | ## 2-level En/decryption
61 |
62 | The Trezor chip is slow. It takes the Trezor (model 1) device about 75 seconds to en/decrypt 1M. In other words, it can do 0.8MB/min. E.g. for a 20MB file that are 25 minutes.
63 | 50MB in about 1 hour.
64 |
65 | # To-do list
66 |
67 | - [x] file obfuscation
68 | - [x] inner, 2-nd round encryption, new GUI button for it
69 | - [x] add icon to PIN and passphrase GUIs
70 | - [x] add screenshots to README.md
71 | - [x] screenshots of v0.2alpha
72 | - [x] make the image smaller on main window
73 | - [x] more Testing
74 | - [ ] get help with getting the word out, anyone wants to spread the word on Twitter, Reddit, with Trezor, Facebook, etc.?
75 |
76 | # Migrating to Python3
77 |
78 | Doing only Python 2.7 or only 3.4 is okay, but making both work on the same code base is cumbersome.
79 | The combination would be Py2.7 | Py3.4 + PyQt4.11.
80 |
81 | * Basic description of the problem is [here](https://docs.python.org/3/howto/pyporting.html) with some pointers as how to start.
82 | * [2to3](https://docs.python.org/3/library/2to3.html) has been done. It was trivial. Only a few lines of code changed.
83 | * [modernize](https://python-modernize.readthedocs.io/en/latest/) has been done. Again, it was just suggesting a few new lines related to the `range` operator.
84 | * [futurize](http://python-future.org/automatic_conversion.html) was also done. It suggested only a few `import` lines. The 3 lines were added to all .py files.
85 | ```
86 | from __future__ import absolute_import
87 | from __future__ import division
88 | from __future__ import print_function
89 | ```
90 | * Changes related to GUI are:
91 | PyQt4.11 for Py3.4 does not have class QString. It expects unicode objects. Simple hacks like
92 | the folowing are not likely to work.
93 | ```
94 | try:
95 | from PyQt4.QtCore import QString
96 | except ImportError:
97 | # we are using Python3 so QString is not defined
98 | QString = type("")
99 | ```
100 | * Since Py2.7 does not have bytes and handles everything as strings. A common layer would have to be introduced
101 | that simulates bytes on Py2.7. Some good code starting points can be found at
102 | [python3porting.com](http://python3porting.com/problems.html#bytes-strings-and-unicode).
103 | * In Debian 9 Py2 will remain the default Py version, so Py2.7 does not seem to be going away.
104 | * According to Python.org Python 2.7 will be maintained till 2020.
105 |
106 | In short, for the time being it does not seem worth it to add code to make it run on both 2.7 and 3.4.
107 | It seems one can wait until 2.7 becomes outdated and then port to 3.5, breaking and leaving 2.7 behind.
108 |
--------------------------------------------------------------------------------
/dialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 840
10 | 820
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 |
21 | 800
22 | 700
23 |
24 |
25 |
26 |
27 | 16777215
28 | 16777215
29 |
30 |
31 |
32 | Trezor Symmetric File Encryption
33 |
34 |
35 |
36 | icons/trezor.bg.svgicons/trezor.bg.svg
37 |
38 |
39 |
40 |
41 |
42 |
43 | 0
44 | 0
45 |
46 |
47 |
48 |
49 |
50 |
51 | icons/TrezorSymmetricFileEncryption.216x100.svg
52 |
53 |
54 | false
55 |
56 |
57 | Qt::AlignCenter
58 |
59 |
60 | -10
61 |
62 |
63 | Qt::NoTextInteraction
64 |
65 |
66 |
67 |
68 |
69 |
70 | Choose one operation and multiple options (if empty all will be chosen automatically)
71 |
72 |
73 |
74 |
75 |
76 |
77 | Qt::Horizontal
78 |
79 |
80 |
81 |
82 |
83 |
84 | QLayout::SetDefaultConstraint
85 |
86 |
87 |
88 |
89 | 6
90 |
91 |
92 | QLayout::SetDefaultConstraint
93 |
94 |
95 |
96 |
97 |
98 | 0
99 | 0
100 |
101 |
102 |
103 |
104 | 0
105 | 0
106 |
107 |
108 |
109 |
110 | 75
111 | true
112 |
113 |
114 |
115 | Chose Encrypt Operation
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | 0
124 | 0
125 |
126 |
127 |
128 |
129 | 0
130 | 0
131 |
132 |
133 |
134 |
135 | 0
136 | 25
137 |
138 |
139 |
140 | Encrypt file
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 | 0
149 | 0
150 |
151 |
152 |
153 |
154 | 0
155 | 0
156 |
157 |
158 |
159 |
160 | 0
161 | 25
162 |
163 |
164 |
165 | Show only obfuscated filename (without encrypting file)
166 |
167 |
168 |
169 |
170 |
171 |
172 | Qt::Vertical
173 |
174 |
175 | QSizePolicy::Minimum
176 |
177 |
178 |
179 | 20
180 | 65
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | 6
191 |
192 |
193 | QLayout::SetDefaultConstraint
194 |
195 |
196 |
197 |
198 |
199 | 0
200 | 0
201 |
202 |
203 |
204 |
205 | 0
206 | 0
207 |
208 |
209 |
210 |
211 | 75
212 | true
213 |
214 |
215 |
216 | Chose Encrypt Options
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 | 0
225 | 0
226 |
227 |
228 |
229 |
230 | 0
231 | 0
232 |
233 |
234 |
235 |
236 | 0
237 | 25
238 |
239 |
240 |
241 | Obfuscate filename
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 | 0
250 | 0
251 |
252 |
253 |
254 |
255 | 0
256 | 0
257 |
258 |
259 |
260 |
261 | 0
262 | 25
263 |
264 |
265 |
266 | Encrypt twice (very slow on large files)
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 | 0
275 | 0
276 |
277 |
278 |
279 |
280 | 0
281 | 0
282 |
283 |
284 |
285 |
286 | 0
287 | 25
288 |
289 |
290 |
291 | Perform safety check on encrypted file
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 | 0
300 | 0
301 |
302 |
303 |
304 |
305 | 0
306 | 0
307 |
308 |
309 |
310 |
311 | 0
312 | 25
313 |
314 |
315 |
316 | Shred plaintext file after encryption
317 |
318 |
319 |
320 |
321 |
322 |
323 | Qt::Vertical
324 |
325 |
326 | QSizePolicy::Minimum
327 |
328 |
329 |
330 | 20
331 | 0
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 | Qt::Horizontal
344 |
345 |
346 |
347 |
348 |
349 |
350 | QLayout::SetMinimumSize
351 |
352 |
353 |
354 |
355 | 6
356 |
357 |
358 | QLayout::SetFixedSize
359 |
360 |
361 |
362 |
363 |
364 | 0
365 | 0
366 |
367 |
368 |
369 |
370 | 0
371 | 0
372 |
373 |
374 |
375 |
376 | 75
377 | true
378 |
379 |
380 |
381 | Chose Decrypt Operation
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 | 0
390 | 0
391 |
392 |
393 |
394 |
395 | 0
396 | 0
397 |
398 |
399 |
400 | Decrypt file
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 | 0
409 | 0
410 |
411 |
412 |
413 |
414 | 0
415 | 0
416 |
417 |
418 |
419 | Decrypt only obfuscated filename (but not the file)
420 |
421 |
422 |
423 |
424 |
425 |
426 | Qt::Vertical
427 |
428 |
429 | QSizePolicy::Minimum
430 |
431 |
432 |
433 | 20
434 | 0
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 | 6
445 |
446 |
447 | QLayout::SetFixedSize
448 |
449 |
450 |
451 |
452 |
453 | 0
454 | 0
455 |
456 |
457 |
458 |
459 | 0
460 | 0
461 |
462 |
463 |
464 |
465 | 75
466 | true
467 |
468 |
469 |
470 | Chose Decrypt Options
471 |
472 |
473 |
474 |
475 |
476 |
477 | Perform safety check on plaintext file
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 | 0
486 | 0
487 |
488 |
489 |
490 |
491 | 0
492 | 0
493 |
494 |
495 |
496 |
497 | 0
498 | 0
499 |
500 |
501 |
502 | Shred encrypted file after decryption
503 |
504 |
505 |
506 |
507 |
508 |
509 | Qt::Vertical
510 |
511 |
512 | QSizePolicy::Minimum
513 |
514 |
515 |
516 | 20
517 | 0
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 | Qt::Horizontal
530 |
531 |
532 |
533 |
534 |
535 |
536 | Select one or multiple files
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 | Select...
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 | Enter master passphrase for Trezor
558 |
559 |
560 |
561 |
562 |
563 |
564 | QLineEdit::Password
565 |
566 |
567 |
568 |
569 |
570 |
571 | Repeat master passphrase for Trezor
572 |
573 |
574 |
575 |
576 |
577 |
578 | QLineEdit::Password
579 |
580 |
581 |
582 |
583 |
584 |
585 | Status
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 | 50
594 | 50
595 |
596 |
597 |
598 |
599 | 16777215
600 | 16777215
601 |
602 |
603 |
604 |
605 | 0
606 | 150
607 |
608 |
609 |
610 | Qt::NoFocus
611 |
612 |
613 | false
614 |
615 |
616 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
617 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
618 | p, li { white-space: pre-wrap; }
619 | </style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;">
620 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:600;">Welcome to TrezorSymmetricFileEncryption. </span></p>
621 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">This is version 0.5.0.</span></p>
622 | <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;"><br /></p>
623 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:12pt;">You need to choose a master passphrase that will be used as a Trezor passphrase to encrypt and decrypt files. If forgotten, there's only bruteforcing left.</span></p></body></html>
624 |
625 |
626 | Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
627 |
628 |
629 |
630 |
631 |
632 |
633 | Qt::Horizontal
634 |
635 |
636 | QDialogButtonBox::Apply|QDialogButtonBox::Close
637 |
638 |
639 |
640 |
641 |
642 |
643 | Apply
644 |
645 |
646 | Ctrl+A
647 |
648 |
649 |
650 |
651 | Done
652 |
653 |
654 | Ctrl+D
655 |
656 |
657 |
658 |
659 |
660 |
661 | buttonBox
662 | accepted()
663 | Dialog
664 | accept()
665 |
666 |
667 | 266
668 | 760
669 |
670 |
671 | 157
672 | 274
673 |
674 |
675 |
676 |
677 | buttonBox
678 | rejected()
679 | Dialog
680 | reject()
681 |
682 |
683 | 334
684 | 760
685 |
686 |
687 | 286
688 | 274
689 |
690 |
691 |
692 |
693 |
694 |
--------------------------------------------------------------------------------
/dialogs.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | from __future__ import division
3 | from __future__ import print_function
4 |
5 | import os
6 | import os.path
7 | import logging
8 | import sys
9 |
10 | from PyQt5.QtWidgets import QApplication, QDialog, QDialogButtonBox, QShortcut
11 | from PyQt5.QtWidgets import QMessageBox, QFileDialog
12 | from PyQt5.QtGui import QPixmap, QKeySequence
13 | from PyQt5.QtCore import QT_VERSION_STR, QDir
14 | from PyQt5.Qt import PYQT_VERSION_STR
15 |
16 | from ui_dialog import Ui_Dialog
17 |
18 | import basics
19 | import encoding
20 | from processing import processAll
21 |
22 | """
23 | This code should cover the GUI of the business logic of the application.
24 |
25 | Code should work on both Python 2.7 as well as 3.4.
26 | Requires PyQt5.
27 | (Old version supported PyQt4.)
28 | """
29 |
30 |
31 | class Dialog(QDialog, Ui_Dialog):
32 |
33 | DESCRHEADER = """
34 |
35 | Welcome to """ + basics.NAME + """, version """ + basics.VERSION_STR + """ from
36 | """ + basics.VERSION_DATE_STR + """
37 | En/decrypting once is fast.
38 | En/decrypting twice is slow on large files.
39 | If you lose your master passphrase you will not be able to
40 | decrypt your file(s). You may leave the master passphrase empty.
41 | """
42 | DESCRTRAILER = "
" + basics.NAME + " " +
124 | "is a file encryption and decryption tool using a Trezor hardware "
125 | "device for safety and security. Symmetric AES cryptography is used "
126 | "at its core.