Compare commits
11 Commits
all-contri
...
nfc_confor
Author | SHA1 | Date | |
---|---|---|---|
01b8503495 | |||
5d3914bc5e | |||
abe306a649 | |||
41ceb78f6c | |||
8e192f2363 | |||
affc256ca2 | |||
b3ac739a35 | |||
3b53537077 | |||
3fad9a7a7d | |||
8973608f59 | |||
8af6505f6d |
@ -168,6 +168,16 @@
|
|||||||
"infra",
|
"infra",
|
||||||
"tool"
|
"tool"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "kimusan",
|
||||||
|
"name": "Kim Schulz",
|
||||||
|
"avatar_url": "https://avatars1.githubusercontent.com/u/1150049?v=4",
|
||||||
|
"profile": "http://www.schulz.dk",
|
||||||
|
"contributions": [
|
||||||
|
"business",
|
||||||
|
"ideas"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
@ -134,6 +134,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<td align="center"><a href="http://1bitsquared.com"><img src="https://avatars3.githubusercontent.com/u/17334?v=4" width="100px;" alt="Piotr Esden-Tempski"/><br /><sub><b>Piotr Esden-Tempski</b></sub></a><br /><a href="#business-esden" title="Business development">💼</a></td>
|
<td align="center"><a href="http://1bitsquared.com"><img src="https://avatars3.githubusercontent.com/u/17334?v=4" width="100px;" alt="Piotr Esden-Tempski"/><br /><sub><b>Piotr Esden-Tempski</b></sub></a><br /><a href="#business-esden" title="Business development">💼</a></td>
|
||||||
<td align="center"><a href="https://github.com/m3hm00d"><img src="https://avatars1.githubusercontent.com/u/42179593?v=4" width="100px;" alt="f.m3hm00d"/><br /><sub><b>f.m3hm00d</b></sub></a><br /><a href="https://github.com/solokeys/solo/commits?author=m3hm00d" title="Documentation">📖</a></td>
|
<td align="center"><a href="https://github.com/m3hm00d"><img src="https://avatars1.githubusercontent.com/u/42179593?v=4" width="100px;" alt="f.m3hm00d"/><br /><sub><b>f.m3hm00d</b></sub></a><br /><a href="https://github.com/solokeys/solo/commits?author=m3hm00d" title="Documentation">📖</a></td>
|
||||||
<td align="center"><a href="http://blogs.gnome.org/hughsie/"><img src="https://avatars0.githubusercontent.com/u/151380?v=4" width="100px;" alt="Richard Hughes"/><br /><sub><b>Richard Hughes</b></sub></a><br /><a href="#ideas-hughsie" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/solokeys/solo/commits?author=hughsie" title="Code">💻</a> <a href="#infra-hughsie" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#tool-hughsie" title="Tools">🔧</a></td>
|
<td align="center"><a href="http://blogs.gnome.org/hughsie/"><img src="https://avatars0.githubusercontent.com/u/151380?v=4" width="100px;" alt="Richard Hughes"/><br /><sub><b>Richard Hughes</b></sub></a><br /><a href="#ideas-hughsie" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/solokeys/solo/commits?author=hughsie" title="Code">💻</a> <a href="#infra-hughsie" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#tool-hughsie" title="Tools">🔧</a></td>
|
||||||
|
<td align="center"><a href="http://www.schulz.dk"><img src="https://avatars1.githubusercontent.com/u/1150049?v=4" width="100px;" alt="Kim Schulz"/><br /><sub><b>Kim Schulz</b></sub></a><br /><a href="#business-kimusan" title="Business development">💼</a> <a href="#ideas-kimusan" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@ -167,7 +168,7 @@ You can buy Solo, Solo Tap, and Solo for Hackers at [solokeys.com](https://solok
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
[](https://github.com/solokeys/solo/blob/master/LICENSE)
|
[](https://github.com/solokeys/solo/blob/master/LICENSE)
|
||||||
[](#contributors)
|
[](#contributors)
|
||||||
[](https://travis-ci.com/solokeys/solo)
|
[](https://travis-ci.com/solokeys/solo)
|
||||||
[](https://discourse.solokeys.com)
|
[](https://discourse.solokeys.com)
|
||||||
[](https://keybase.io/team/solokeys.public)
|
[](https://keybase.io/team/solokeys.public)
|
||||||
|
18
fido2/apdu.c
18
fido2/apdu.c
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
|
|
||||||
int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
uint16_t apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
||||||
{
|
{
|
||||||
EXT_APDU_HEADER *hapdu = (EXT_APDU_HEADER *)data;
|
EXT_APDU_HEADER *hapdu = (EXT_APDU_HEADER *)data;
|
||||||
|
|
||||||
@ -62,6 +62,11 @@ int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
|||||||
if (len >= 7 && b0 == 0)
|
if (len >= 7 && b0 == 0)
|
||||||
{
|
{
|
||||||
uint16_t extlen = (hapdu->lc[1] << 8) + hapdu->lc[2];
|
uint16_t extlen = (hapdu->lc[1] << 8) + hapdu->lc[2];
|
||||||
|
|
||||||
|
if (len - 7 < extlen)
|
||||||
|
{
|
||||||
|
return SW_WRONG_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
// case 2E (Le) - extended
|
// case 2E (Le) - extended
|
||||||
if (len == 7)
|
if (len == 7)
|
||||||
@ -103,9 +108,18 @@ int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
|||||||
apdu->le = 0x10000;
|
apdu->le = 0x10000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((len > 5) && (len - 5 < hapdu->lc[0]))
|
||||||
|
{
|
||||||
|
return SW_WRONG_LENGTH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!apdu->case_type)
|
if (!apdu->case_type)
|
||||||
return 1;
|
{
|
||||||
|
return SW_COND_USE_NOT_SATISFIED;
|
||||||
|
}
|
||||||
|
|
||||||
if (apdu->lc)
|
if (apdu->lc)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ typedef struct
|
|||||||
uint8_t case_type;
|
uint8_t case_type;
|
||||||
} __attribute__((packed)) APDU_STRUCT;
|
} __attribute__((packed)) APDU_STRUCT;
|
||||||
|
|
||||||
extern int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu);
|
extern uint16_t apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu);
|
||||||
|
|
||||||
#define APDU_FIDO_U2F_REGISTER 0x01
|
#define APDU_FIDO_U2F_REGISTER 0x01
|
||||||
#define APDU_FIDO_U2F_AUTHENTICATE 0x02
|
#define APDU_FIDO_U2F_AUTHENTICATE 0x02
|
||||||
|
43
fido2/ctap.c
43
fido2/ctap.c
@ -437,7 +437,19 @@ static unsigned int get_credential_id_size(CTAP_credentialDescriptor * cred)
|
|||||||
static int ctap2_user_presence_test()
|
static int ctap2_user_presence_test()
|
||||||
{
|
{
|
||||||
device_set_status(CTAPHID_STATUS_UPNEEDED);
|
device_set_status(CTAPHID_STATUS_UPNEEDED);
|
||||||
return ctap_user_presence_test(CTAP2_UP_DELAY_MS);
|
int ret = ctap_user_presence_test(CTAP2_UP_DELAY_MS);
|
||||||
|
if ( ret > 0 )
|
||||||
|
{
|
||||||
|
return CTAP1_ERR_SUCCESS;
|
||||||
|
}
|
||||||
|
else if (ret < 0)
|
||||||
|
{
|
||||||
|
return CTAP2_ERR_KEEPALIVE_CANCEL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CTAP2_ERR_ACTION_TIMEOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * auth_data_buf, uint32_t * len, CTAP_credInfo * credInfo)
|
static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * auth_data_buf, uint32_t * len, CTAP_credInfo * credInfo)
|
||||||
@ -470,19 +482,11 @@ static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * au
|
|||||||
int but;
|
int but;
|
||||||
|
|
||||||
but = ctap2_user_presence_test(CTAP2_UP_DELAY_MS);
|
but = ctap2_user_presence_test(CTAP2_UP_DELAY_MS);
|
||||||
|
check_retr(but);
|
||||||
if (!but)
|
|
||||||
{
|
|
||||||
return CTAP2_ERR_OPERATION_DENIED;
|
|
||||||
}
|
|
||||||
else if (but < 0) // Cancel
|
|
||||||
{
|
|
||||||
return CTAP2_ERR_KEEPALIVE_CANCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
device_set_status(CTAPHID_STATUS_PROCESSING);
|
device_set_status(CTAPHID_STATUS_PROCESSING);
|
||||||
|
|
||||||
authData->head.flags = (but << 0);
|
authData->head.flags = (1 << 0); // User presence
|
||||||
authData->head.flags |= (ctap_is_pin_set() << 2);
|
authData->head.flags |= (ctap_is_pin_set() << 2);
|
||||||
|
|
||||||
|
|
||||||
@ -707,10 +711,7 @@ uint8_t ctap_make_credential(CborEncoder * encoder, uint8_t * request, int lengt
|
|||||||
}
|
}
|
||||||
if (MC.pinAuthEmpty)
|
if (MC.pinAuthEmpty)
|
||||||
{
|
{
|
||||||
if (!ctap2_user_presence_test(CTAP2_UP_DELAY_MS))
|
check_retr( ctap2_user_presence_test(CTAP2_UP_DELAY_MS) );
|
||||||
{
|
|
||||||
return CTAP2_ERR_OPERATION_DENIED;
|
|
||||||
}
|
|
||||||
return ctap_is_pin_set() == 1 ? CTAP2_ERR_PIN_AUTH_INVALID : CTAP2_ERR_PIN_NOT_SET;
|
return ctap_is_pin_set() == 1 ? CTAP2_ERR_PIN_AUTH_INVALID : CTAP2_ERR_PIN_NOT_SET;
|
||||||
}
|
}
|
||||||
if ((MC.paramsParsed & MC_requiredMask) != MC_requiredMask)
|
if ((MC.paramsParsed & MC_requiredMask) != MC_requiredMask)
|
||||||
@ -1143,10 +1144,7 @@ uint8_t ctap_get_assertion(CborEncoder * encoder, uint8_t * request, int length)
|
|||||||
|
|
||||||
if (GA.pinAuthEmpty)
|
if (GA.pinAuthEmpty)
|
||||||
{
|
{
|
||||||
if (!ctap2_user_presence_test(CTAP2_UP_DELAY_MS))
|
check_retr( ctap2_user_presence_test(CTAP2_UP_DELAY_MS) );
|
||||||
{
|
|
||||||
return CTAP2_ERR_OPERATION_DENIED;
|
|
||||||
}
|
|
||||||
return ctap_is_pin_set() == 1 ? CTAP2_ERR_PIN_AUTH_INVALID : CTAP2_ERR_PIN_NOT_SET;
|
return ctap_is_pin_set() == 1 ? CTAP2_ERR_PIN_AUTH_INVALID : CTAP2_ERR_PIN_NOT_SET;
|
||||||
}
|
}
|
||||||
if (GA.pinAuthPresent)
|
if (GA.pinAuthPresent)
|
||||||
@ -1656,14 +1654,11 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
|||||||
break;
|
break;
|
||||||
case CTAP_RESET:
|
case CTAP_RESET:
|
||||||
printf1(TAG_CTAP,"CTAP_RESET\n");
|
printf1(TAG_CTAP,"CTAP_RESET\n");
|
||||||
if (ctap2_user_presence_test(CTAP2_UP_DELAY_MS))
|
status = ctap2_user_presence_test(CTAP2_UP_DELAY_MS);
|
||||||
|
if (status == CTAP1_ERR_SUCCESS)
|
||||||
{
|
{
|
||||||
ctap_reset();
|
ctap_reset();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
status = CTAP2_ERR_OPERATION_DENIED;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GET_NEXT_ASSERTION:
|
case GET_NEXT_ASSERTION:
|
||||||
printf1(TAG_CTAP,"CTAP_NEXT_ASSERTION\n");
|
printf1(TAG_CTAP,"CTAP_NEXT_ASSERTION\n");
|
||||||
|
@ -131,7 +131,7 @@
|
|||||||
#define PIN_LOCKOUT_ATTEMPTS 8 // Number of attempts total
|
#define PIN_LOCKOUT_ATTEMPTS 8 // Number of attempts total
|
||||||
#define PIN_BOOT_ATTEMPTS 3 // number of attempts per boot
|
#define PIN_BOOT_ATTEMPTS 3 // number of attempts per boot
|
||||||
|
|
||||||
#define CTAP2_UP_DELAY_MS 5000
|
#define CTAP2_UP_DELAY_MS 29000
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#define CTAP2_ERR_PIN_POLICY_VIOLATION 0x37
|
#define CTAP2_ERR_PIN_POLICY_VIOLATION 0x37
|
||||||
#define CTAP2_ERR_PIN_TOKEN_EXPIRED 0x38
|
#define CTAP2_ERR_PIN_TOKEN_EXPIRED 0x38
|
||||||
#define CTAP2_ERR_REQUEST_TOO_LARGE 0x39
|
#define CTAP2_ERR_REQUEST_TOO_LARGE 0x39
|
||||||
|
#define CTAP2_ERR_ACTION_TIMEOUT 0x3A
|
||||||
#define CTAP1_ERR_OTHER 0x7F
|
#define CTAP1_ERR_OTHER 0x7F
|
||||||
#define CTAP2_ERR_SPEC_LAST 0xDF
|
#define CTAP2_ERR_SPEC_LAST 0xDF
|
||||||
#define CTAP2_ERR_EXTENSION_FIRST 0xE0
|
#define CTAP2_ERR_EXTENSION_FIRST 0xE0
|
||||||
|
@ -55,11 +55,43 @@ static int is_physical_button_pressed()
|
|||||||
|
|
||||||
static int is_touch_button_pressed()
|
static int is_touch_button_pressed()
|
||||||
{
|
{
|
||||||
return tsc_read_button(0) || tsc_read_button(1);
|
int is_pressed = (tsc_read_button(0) || tsc_read_button(1));
|
||||||
|
#ifndef IS_BOOTLOADER
|
||||||
|
if (is_pressed)
|
||||||
|
{
|
||||||
|
// delay for debounce, and longer than polling timer period.
|
||||||
|
delay(95);
|
||||||
|
return (tsc_read_button(0) || tsc_read_button(1));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return is_pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int (*IS_BUTTON_PRESSED)() = is_physical_button_pressed;
|
int (*IS_BUTTON_PRESSED)() = is_physical_button_pressed;
|
||||||
|
|
||||||
|
static void edge_detect_touch_button()
|
||||||
|
{
|
||||||
|
static uint8_t last_touch = 0;
|
||||||
|
uint8_t current_touch = 0;
|
||||||
|
if (is_touch_button_pressed == IS_BUTTON_PRESSED)
|
||||||
|
{
|
||||||
|
current_touch = (tsc_read_button(0) || tsc_read_button(1));
|
||||||
|
|
||||||
|
// 1 sample per 25 ms
|
||||||
|
if ((millis() - __last_button_bounce_time) > 25)
|
||||||
|
{
|
||||||
|
// Detect "touch / rising edge"
|
||||||
|
if (!last_touch && current_touch)
|
||||||
|
{
|
||||||
|
__last_button_press_time = millis();
|
||||||
|
}
|
||||||
|
__last_button_bounce_time = millis();
|
||||||
|
last_touch = current_touch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void request_from_nfc(bool request_active) {
|
void request_from_nfc(bool request_active) {
|
||||||
_RequestComeFromNFC = request_active;
|
_RequestComeFromNFC = request_active;
|
||||||
}
|
}
|
||||||
@ -78,19 +110,7 @@ void TIM6_DAC_IRQHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edge_detect_touch_button();
|
||||||
if (is_touch_button_pressed == IS_BUTTON_PRESSED)
|
|
||||||
{
|
|
||||||
if (IS_BUTTON_PRESSED())
|
|
||||||
{
|
|
||||||
// Only allow 1 press per 25 ms.
|
|
||||||
if ((millis() - __last_button_bounce_time) > 25)
|
|
||||||
{
|
|
||||||
__last_button_press_time = millis();
|
|
||||||
}
|
|
||||||
__last_button_bounce_time = millis();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef IS_BOOTLOADER
|
#ifndef IS_BOOTLOADER
|
||||||
// NFC sending WTX if needs
|
// NFC sending WTX if needs
|
||||||
@ -142,7 +162,6 @@ void device_set_status(uint32_t status)
|
|||||||
|
|
||||||
int device_is_button_pressed()
|
int device_is_button_pressed()
|
||||||
{
|
{
|
||||||
|
|
||||||
return IS_BUTTON_PRESSED();
|
return IS_BUTTON_PRESSED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,9 +703,6 @@ void apdu_process(uint8_t buf0, uint8_t *apduptr, APDU_STRUCT *apdu)
|
|||||||
// WTX_on(WTX_TIME_DEFAULT);
|
// WTX_on(WTX_TIME_DEFAULT);
|
||||||
request_from_nfc(true);
|
request_from_nfc(true);
|
||||||
ctap_response_init(&ctap_resp);
|
ctap_response_init(&ctap_resp);
|
||||||
delay(1);
|
|
||||||
printf1(TAG_NFC,"[%d] ", apdu->lc);
|
|
||||||
dump_hex1(TAG_NFC, apdu->data, apdu->lc);
|
|
||||||
status = ctap_request(apdu->data, apdu->lc, &ctap_resp);
|
status = ctap_request(apdu->data, apdu->lc, &ctap_resp);
|
||||||
request_from_nfc(false);
|
request_from_nfc(false);
|
||||||
// if (!WTX_off())
|
// if (!WTX_off())
|
||||||
@ -759,7 +756,8 @@ void apdu_process(uint8_t buf0, uint8_t *apduptr, APDU_STRUCT *apdu)
|
|||||||
case APDU_SOLO_RESET:
|
case APDU_SOLO_RESET:
|
||||||
if (apdu->lc == 4 && !memcmp(apdu->data, "\x12\x56\xab\xf0", 4)) {
|
if (apdu->lc == 4 && !memcmp(apdu->data, "\x12\x56\xab\xf0", 4)) {
|
||||||
printf1(TAG_NFC, "Reset...\r\n");
|
printf1(TAG_NFC, "Reset...\r\n");
|
||||||
delay(10);
|
nfc_write_response(buf0, SW_SUCCESS);
|
||||||
|
delay(20);
|
||||||
device_reboot();
|
device_reboot();
|
||||||
while(1);
|
while(1);
|
||||||
} else {
|
} else {
|
||||||
@ -786,9 +784,10 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
APDU_STRUCT apdu;
|
APDU_STRUCT apdu;
|
||||||
if (apdu_decode(buf + block_offset, len - block_offset, &apdu)) {
|
uint16_t ret = apdu_decode(buf + block_offset, len - block_offset, &apdu);
|
||||||
|
if (ret != 0) {
|
||||||
printf1(TAG_NFC,"apdu decode error\r\n");
|
printf1(TAG_NFC,"apdu decode error\r\n");
|
||||||
nfc_write_response(buf[0], SW_COND_USE_NOT_SATISFIED);
|
nfc_write_response(buf[0], ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf1(TAG_NFC,"apdu ok. %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%d le=%d\r\n",
|
printf1(TAG_NFC,"apdu ok. %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%d le=%d\r\n",
|
||||||
@ -804,7 +803,6 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
|
|
||||||
memmove(&chain_buffer[chain_buffer_len], apdu.data, apdu.lc);
|
memmove(&chain_buffer[chain_buffer_len], apdu.data, apdu.lc);
|
||||||
chain_buffer_len += apdu.lc;
|
chain_buffer_len += apdu.lc;
|
||||||
delay(1);
|
|
||||||
nfc_write_response(buf[0], SW_SUCCESS);
|
nfc_write_response(buf[0], SW_SUCCESS);
|
||||||
printf1(TAG_NFC, "APDU chaining ok. %d/%d\r\n", apdu.lc, chain_buffer_len);
|
printf1(TAG_NFC, "APDU chaining ok. %d/%d\r\n", apdu.lc, chain_buffer_len);
|
||||||
return;
|
return;
|
||||||
@ -812,7 +810,6 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
|
|
||||||
// if we have ISO 7816 APDU chain - move there all the data
|
// if we have ISO 7816 APDU chain - move there all the data
|
||||||
if (!chain_buffer_tx && chain_buffer_len > 0) {
|
if (!chain_buffer_tx && chain_buffer_len > 0) {
|
||||||
delay(1);
|
|
||||||
memmove(&apdu.data[chain_buffer_len], apdu.data, apdu.lc);
|
memmove(&apdu.data[chain_buffer_len], apdu.data, apdu.lc);
|
||||||
memmove(apdu.data, chain_buffer, chain_buffer_len);
|
memmove(apdu.data, chain_buffer, chain_buffer_len);
|
||||||
apdu.lc += chain_buffer_len; // here apdu struct does not match with memory!
|
apdu.lc += chain_buffer_len; // here apdu struct does not match with memory!
|
||||||
|
Reference in New Issue
Block a user