-
Notifications
You must be signed in to change notification settings - Fork 255
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
Added support of (open)hardware cryptographic module "Trezor One" #243
Conversation
Builds fails because there's a dependency on https://github.com/rfjakob/eme, but rfjakob/eme#3 is not merged, yet. |
Done some polising. Ready for merging. I can squash it if you want :) |
Hi, and thanks for this pull request! Some comments:
|
I think we should start much simpler: Using Trezor as a second factor (2FA) in addition to the password. Could work something like this, where the master key is decrypted by Trezor, and then decrypted by gocryptfs with a user password:
Note that the order is important: Step 3 has a bulletproof check if the key is valid or has been corrupted in some way due do AES-GCM Authentication. |
In my case the third step is skipped because Trezor already requires a password. |
It has non-zero overhead. I added 14 octets of
Ok. It is hacky (and I'm weak in cryptography), agreed. I'd like to preserve on-device encryption for myself (to continue experiments with Trezor), but I can support a fork of gocryptfs for that. The most important is master-key encryption, of course. But if I can improve on-device encryption to get it merged, please let me know.
I see, ok.
https://github.com/trezor/connect [see "cipherKeyValue"] It's an API function to a Trezor device (initially used to get master keys) [see SLIP-0011] |
@rfjakob I've fixed the PR. |
Trezor is disabled for all platforms except "linux"
BTW, should I squash this commits? |
Thanks for the update, looks better now! I have ordered a Trezor for development, should arrive next week. About on-device-encryption: It would be a nice use case, but may be hard to get right. I will look at what crypto APIs can be used on the Trezor. Squashing not yet neccessary, no. While looking at the Trezor, I noticed it supports U2F. I'm thinking about whether we can use U2F, this would add support for lots of other USB sticks. Not yet sure if possible from a crypto standpoint, I'll have to read the U2F spec. At least there seems to be a Go package for U2F ( https://github.com/flynn/u2f ). They have several devices tested, but not the Trezor - if you like you could test it and add the Trezor to the table? |
Hi! SatoshiLabs (makers of TREZOR) CTO here. Feel free to ask questions or suggest better API when needed. I think that TREZOR integration is much better than using TREZOR as a second factor. (Remember - TREZOR asks for PIN on display - it is already two-factor device). PIN entering might be a problem with TREZOR 1 (because the application would need to provide an interface), but it should work with TREZOR model T with no problem (as you can enter the PIN on the device). @xaionaro @rfjakob Do you have the new model T? If not, reach me via email at stick@satoshilabs.com and I'll get one to you (both). |
Hi @prusnak , thanks for chiming in! No, I have ordered a Trezor One and would be excited to get a model T as well! I'll email you shortly. |
Yep. I also use U2F to authenticate on my desktop with Trezor — it really works :)
I see. Interesting idea. However I'm not sure (yet) when I'll be able to try to implement that.
Ok, I'll test that golang library with Trezor One very soon.
No. "T" model was too expensive (I bought 7 pieces "Trezor One" and it already was quite expensive). I've emailed you, thank you :) |
U2F won't work because the signature we get back from the U2F stick is randomized. No way to use it as a key. I have both Trezors now (One and T). Testing with the Trezor One, I got this, probably because the device was not yet initialized?
In any case, we should give a nicer error message to the user. |
Considered the case if the Trezor device is not initialized
Conflicts: README.md
I've just tested on uninitilized Trezor One and got the same error, yes.
Fixed.
|
To pass builds (in Travis) you need to restart them (I forgot to push one commit to one of my repositories before pushing a commit to gocryptfs) |
Thanks for the updates, two more high-level comments:
|
Done. Travis failed, but the error is already fixed (after that). |
@xaionaro How do you feel about additionally using a gocryptfs password? Too inconvenient? Optional or mandatory? (On by default or not?) My concern is that it is about 1000$ to dump all memory out of a Trezor by shipping it to China to a specialized service. The PIN does not help here. See this post for example:
PS: I have restarted the Travis build: https://travis-ci.org/rfjakob/gocryptfs/builds/392302249 |
I think this article is FUD. While there are some papers about breaking Read Protection (RDP) level 1, so far no one has performed a RDP level 2 hack (this is what we use). Also we encourage people to use passphrase, which is added to the entropy mix, so even if you extract all secrets from the device you still need to passphrase to obtain any key. |
Are you talking about software-based attacks? I'm talking about cracking open the microcontroller and probing the chip. You can order it at http://www.ic-cracker.com/ or http://www.unlock-ic.com/ |
On the plus side, another service, https://russiansemiresearch.com/en/service/#read_prot , does not seem to have STM32F2 listed. |
Same for the other 2 providers you listed, they list just some really archaic STM chips. |
I have read through the presentation at https://www.aisec.fraunhofer.de/en/FirmwareProtection.html where they downgrade rdp level 2 to rdp level 1 using uv light on an stm32f0. They also say: Mitigation available Do you do that? |
Yes, I am aware of this attack. We set RDP always on start if it's not already set to level 2. |
I cannot find any rational reason for that. It already requires 3 factors: a Trezor, a PIN and a passphrase (which, in turn, is not stored on the Trezor). Also I worked with STM32 before and, IMHO, it's not so easy to crack it. On the other hand, the fact that I don't see a risk doesn't mean that there's no risk :). So I cannot suggest anything here.
Fixed. |
Good point about the possibility of having a passphrase on the Trezor. @xaionaro Pin entry does not seem to work?
|
PS: What is |
Oh dear, the tests of conejoninja/tesoro crap out with compile errors: conejoninja/tesoro#5 To get the code quality of all of this good enough to be merged into gocryptfs is going to be some work. |
It works on my computer. How did you get that error?
It's a "derivation path". I actually badly understand this paths, however it was told to me that:
So I just picked an arbitrary path (I used Pi) to do not intersect with other services (like a bitcoin wallet for example) and added apostrophes everywhere. |
Maybe we are on different versions? Care to run ver.sh ? I get this:
|
The CipherKeyValue function seems to be documented in SLIP-0011 . I have created a pull request to get a link added to https://doc.satoshilabs.com/trezor-tech/api-workflows.html#cipherkeyvalue . |
Seems to be the same commits:
BTW, I was able to get a very similar error when a Trezor device was already asking for a PIN code from a previous application (it was displaying a PIN matrix instead of the home screen). That's why I added a comment "(the trezor device is busy?)". |
@xaionaro , I have noticed that the mount still succeeds when the Trezor is wiped and recreated. But any file returns errors, of course. This is because we had no integrity check for the masterkey. I would like to re-use the infrastructure we already have for passwords: integrity check, scrypt brute-force protection. The idea is to encrypt a constant string like I have implemented a skeleton and pushed it to branch "trezor" at https://github.com/rfjakob/gocryptfs/commits/trezor . It should have everything but the actual communication with the Trezor. The Trezor code should go here: gocryptfs/internal/readpassword/trezor.go Line 15 in f02fa5c
|
No, please use |
I'll be able to take a look only on the weekend because my vacation is over :(
Can I also reserve an id for my projects, too?
Should I make a Pull Request for that? |
@rfjakob in my last commits I replaced "Trezor" by "cryptowallet" to be able to add other devices in future. You ignored that in branch "trezor". Should I lock-in into "trezor" or I should rename that? As for me both ways are good enough. |
I have seen the "cryptowallet" rename, but I was not completely sure if it is better. Until we actually support more than one kind of security module, I suggest to keep it simple and stupid, and just call it "trezor". |
Also, the Then there is the question what to do if multiple security modules are connected at the same time. I think for now it is good enough to detect the case and abort. |
@xaionaro Do you need always one key for gocryptfs/i2pfs/trezorLuks? I am thinking about creating just one SLIP and use different derivation paths for various purposes as opposed to creating one separate SLIP for each application. |
Yes, I thought to just use different derivation paths for my applications, too. One SLIP is the best way for me. UPD: |
Nice, thanks. Let's continue at #247 . |
No description provided.