Skip to content

Commit 6122951

Browse files
committed
More documentation
1 parent fb27936 commit 6122951

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

docs/FAQ.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ If you don't know what that is, you DEFINITELY don't need this.
1515
## Don't you need a CBOR parser to write a CTAP2 authenticator?
1616

1717
Apparently not. Instead of implementing a real CBOR parser I just
18-
poured more sweat into the implemnentation, and added a topping of
18+
poured more sweat into the implementation, and added a topping of
1919
non-standards-compliance.
2020

2121
As a result of not having a proper CBOR parser, the app will often
2222
return undesirable error codes on invalid input, but it should
2323
handle most valid input acceptably.
2424

25+
It does this by linearly scanning a byte-buffer with the CBOR object in it,
26+
and moving a read index forward the desired amount. Unknown objects get skipped.
27+
Any object declaring a length greater than two bytes long causes an error,
28+
because it's not possible to have >65535 of something in a 1,024-byte-long
29+
buffer, and the CTAP2 standard requires that CBOR be "canonical".
30+
2531
## Why did you write this, when someone else said they were almost done writing a better version?
2632

2733
Well, they said that, but they hadn't published the source code and I got impatient.
@@ -50,12 +56,31 @@ CTAP2.1 standard says it's okay to return level three if two was requested,
5056
but that breaks OpenSSH, so... credProtect is incorrectly implemented in
5157
that it always applies level three internally.
5258

59+
Finally, the CTAP API requires user presence detection, but there's really no
60+
way to do that on Javacard 3.0.4. We can't even use the "presence timeout"
61+
that is described in the spec for NFC devices. So you're always treated as
62+
being present, which is to some extent offset by the fact that anything real
63+
requires you type your PIN (if one is set)...
64+
65+
So set a PIN, and unplug your card when you're not using it.
66+
5367
## Why don't you implement U2F/CTAP1?
5468

5569
U2F doesn't support PINs, and requires an attestation certificate.
5670

57-
[the security model](security.md) requires PINs.
71+
[The security model](security.md) requires PINs.
72+
73+
It would be possible to implement U2F commands in non-standards-compliant ways,
74+
but implementing them the normal way would require turning off the `alwaysUv`
75+
key feature for U2F-accessible credentials.
5876

5977
## Isn't PBKDF2 on a smartcard a fig leaf?
6078

6179
Probably, yes, but it makes me feel better.
80+
81+
You can raise the iteration count, but really there's only so much that can be
82+
done here. At least it means off-the-shelf rainbow tables probably won't work.
83+
84+
## I hear bcrypt or Argon2id is better than PBKDF2
85+
86+
Good luck implementing those on a 16-bit microprocessor. I welcome you to try.

docs/requirements.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ others should work fine too.
3131
# Platform-side requirements
3232

3333
On the computer side of things, you'll likely want `libfido2` compiled
34-
with support for PC/SC, which is currently experimental, or `libnfc`.
34+
with support for PC/SC, which is currently experimental, or `libnfc`. On
35+
Arch this is not the default - out of the box `libfido2` only works with
36+
USB HID tokens, which this is **not**.
3537

36-
Without either of those two things options you will Have A Bad Day.
38+
Without one of those two options you will Have A Bad Day.
3739

3840
If you have them, you should see the card start showing up in the output
39-
of `fido2-token -L`.
41+
of `fido2-token -L`. You can see what gets sent to and from the card by
42+
setting `FIDO_DEBUG=1` before running your command.

docs/security.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ or used unless you provide your PIN...
3232
On boot, the device generates an AES256 key, the "wrapping key".
3333

3434
Each individual credential issued by the app is a SecP256r1 keypoint,
35-
generated randomly on-device for that credential. The private key
35+
generated randomly on-device for that credential. The cred private key
3636
is then AES256-CBC encrypted along with the RP ID, using a random
3737
IV, and the result is used as the "credential ID".
3838

39+
When using resident keys, the cred private key is only stored encrypted
40+
(after being initially generated). When not using resident keys, the
41+
cred private key isn't stored on the authenticator at all.
42+
3943
This means relying parties are holding their own encrypted private
4044
keys. The keypair itself provides approximately 128 bits of
4145
brute-force resistance. The wrapping key provides a strong 256 bits.
@@ -151,3 +155,24 @@ was faulty.
151155

152156
So, lock your smartcard ("set a transit key"), `gpp --lock <key>` or
153157
however you communicate with it.
158+
159+
### I deleted a resident key and then someone compromised my card
160+
161+
Deleting a credential doesn't currently wipe it from the flash, just
162+
marks it as trashed. But a compromised card is a compromised card...
163+
164+
### My smartcard's random number generator is not really random
165+
166+
Keys generated by the card will be weak, so the "wrapping key" will be weak.
167+
168+
This entirely breaks the security model of the card and you can't trust
169+
anything it does.
170+
171+
### I don't trust your code
172+
173+
You can see the code, and modify it until you do trust it. The only homespun
174+
crypto in the repository is an implementation of HMAC and an implementation
175+
of PBKDF2. Those were written because PBKDF2 isn't part of the Javacard API
176+
at all, and although HMA-SHA256 is it's not implemented on any of my cards.
177+
178+
Open source is open.

0 commit comments

Comments
 (0)