Commit graph

166 commits

Author SHA1 Message Date
Pol Henarejos
4919eb980f
Added a major refactoring to include Emulated interface.
It works in combination with virtualsmarcard module (vpcd). It properly installed, it creates a virtual reader that can be interfaced via PCSC+vcpd. At user app level, it has no difference of having a physical smart card.

At this moment, it only works emulating a CCID interface.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2023-01-09 18:06:21 +01:00
Pol Henarejos
2d511df5d8
Fix alternating CCID and HID. (IT DOES NOT WORK)
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2023-01-08 23:56:48 +01:00
Pol Henarejos
bc107de1b9
Restyled messages.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-30 01:55:16 +01:00
Pol Henarejos
411755dee4
Adding a secondary HID interface that emulates a keyboard.
With it, an app can send a password directly to the host, like it is typed by user.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-30 01:41:49 +01:00
Pol Henarejos
20bd2c8b41
Fix writting read buffer for itf > 0.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-30 01:40:22 +01:00
Pol Henarejos
70979da57a
Remove debug line.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-28 17:05:19 +01:00
Pol Henarejos
9e92b9d4ed
asn1_find_tag() may accept NULL tag_data and tag_len.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-26 21:37:42 +01:00
Pol Henarejos
026ce37c11
Fix returned type.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-24 01:40:53 +01:00
Pol Henarejos
36b2924036
If file functions are called with NULL arg silently return.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-24 01:39:26 +01:00
Pol Henarejos
a8fe504d14
No more discrimination related with core0/core1. using get_core_num() returns the core number.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-24 01:38:09 +01:00
Pol Henarejos
c0a540ae2b
Fix processing APDU when no app is selected.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-24 01:37:04 +01:00
Pol Henarejos
7deaa990d3
An app can be selected even if there is another selected previously.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-24 00:49:25 +01:00
Pol Henarejos
88b2978ae5
Fix ATR response.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-22 22:50:37 +01:00
Pol Henarejos
b0bfc410a4
Thread on CORE1 is reset at every call.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-22 20:39:01 +01:00
Pol Henarejos
3310b911fc
APDU header is defined at apdu_processing, depending on the interface.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-22 20:38:34 +01:00
Pol Henarejos
4682e5821f
Selecting an app by AID requires the AID as argument.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-22 19:33:02 +01:00
Pol Henarejos
24522b9db8
Fix selecting FIDO AID when MSG.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-22 19:32:02 +01:00
Pol Henarejos
cd3ab0682c
Fix initiating driver for CCID and buffers.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-22 19:31:39 +01:00
Pol Henarejos
e99757ed52
Fix with size of descriptor in single interface mode.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-20 23:51:14 +01:00
Pol Henarejos
6faebdf309
TUD options are declared on compile time depending on enabled interfaces.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-20 23:50:51 +01:00
Pol Henarejos
e5825df5cb
Added capability to add multiple interfaces: HID and CCID at compile time.
Depending on compiling flags, HID and/or CCID may be enabled independently and run simultaneously.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-12-20 23:41:24 +01:00
Pol Henarejos
fa54da973c
Added first step to Enterprise Attestation.
Once enabled, it allows to generate a CSR in the device, which is sent to our PKI. If valid, it returns a signed certificate by an intermediate CA that will be used for attestation.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-30 23:41:05 +01:00
Pol Henarejos
0bc13df1a2
Queues are emptied at begining of card thread.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-28 18:54:01 +01:00
Pol Henarejos
a3f060a79d
Setting own VID/PID (despite they are useless).
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-28 17:36:40 +01:00
Pol Henarejos
c4178fda4b
Fix when multiple shutdowns are sent
Thread queues are empty on every start to avoid ancient messages from previous sessions.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-24 20:21:06 +01:00
Pol Henarejos
3def9bff4f
Added PKCS5 source for key derivation.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-14 13:07:24 +01:00
Pol Henarejos
fccee34a1e
In asn1_find_tag(), tag_data and tag_len are not modified if not found.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-11 14:30:34 +01:00
Pol Henarejos
28170100cc
Adding support for Curve25519 and Curve448.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-11-09 16:49:45 +01:00
Pol Henarejos
74210d7af0
Fix chaining more than 2 chunks.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-10-30 23:41:56 +01:00
Pol Henarejos
b2c2980d73
Fix secure channel with no payload.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-10-30 21:10:35 +01:00
Pol Henarejos
4a8a6728c7
Adding support for specific vendor HID command (0x41).
It is a self implementation, based on CBOR command.
data[0] conveys the command and the contents mapped in CBOR encoding.
The map uses the authConfig template, where the fist item in the map is the subcommand (enable/disable at this moment), the second is a map of the parameters, the third and fourth are the pinUvParam and pinUvProtocol.

With this format only a single vendor HID command is necessary (0x41), which will be used for all my own commands, by using the command id in data[0] like with CBOR.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-10-29 19:41:00 +02:00
Pol Henarejos
5bdc7ab202
Adding specific vendor command to unlock the device.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-10-17 17:38:58 +02:00
Pol Henarejos
1e66e51595
Adding ENABLE_DELAYED_BOOT flag for delayed boot compilation.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-10-05 11:09:24 +02:00
Pol Henarejos
e5fe638c68
Fix related with reallocation under some optimization situations.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-10-05 09:33:18 +02:00
Pol Henarejos
8f14db677e
Fix strange bug when usb cannot write.
In this case, the buffer is kept until the next success call.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-29 23:11:49 +02:00
Pol Henarejos
d0fe447416
Fix PING with no data.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-29 16:59:30 +02:00
Pol Henarejos
27d897be6c
Adding delete_file().
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-29 09:05:39 +02:00
Pol Henarejos
c5095dfec6
Only send response apdu if sw != 0.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-27 22:10:47 +02:00
Pol Henarejos
2aff75a3ec
Fix keepalive msg.
Only sent when CBOR is initiatied.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-27 22:09:16 +02:00
Pol Henarejos
286858c907
Compact debug.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-27 22:07:15 +02:00
Pol Henarejos
815e865ced
Moving some defines.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-27 12:23:43 +02:00
Pol Henarejos
3912775ccb
Fix writting large packets.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-27 12:23:16 +02:00
Pol Henarejos
b70a7474f2
Possibly not necessary, as it returns 0 if there is no available.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 23:35:35 +02:00
Pol Henarejos
96641e79e5
Moving to MbedTLS 3.2.1
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 23:33:12 +02:00
Pol Henarejos
fa371643a1
Fix writing large usb buffers.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 23:23:07 +02:00
Pol Henarejos
52a2ff8b34
Adding chacha sources, as it is enabled in config.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 20:34:51 +02:00
Pol Henarejos
55d4839e21
Adding missing function to ccid driver.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 20:34:18 +02:00
Pol Henarejos
657913d29a
Upgrading version
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 18:14:18 +02:00
Pol Henarejos
18fa1d7f37
Reseting previous command if new arrives.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-25 18:09:37 +02:00
Pol Henarejos
f123108c3e
Added variable to cancel button press.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-09-23 18:07:38 +02:00