Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/u2f/u2f.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ typedef struct {
uint8_t appId[U2F_APPID_SIZE];
} U2F_REGISTER_REQ;


typedef struct {
uint8_t registerId;// U2F_REGISTER_ID_V2
U2F_EC_POINT pubKey;
uint8_t keyHandleLen;
uint8_t keyHandleCertSig[U2F_MAX_KH_SIZE + U2F_MAX_ATT_CERT_SIZE + U2F_MAX_EC_SIG_SIZE];
} U2F_REGISTER_RESP;


// U2F_AUTHENTICATE instruction defines
#define U2F_AUTH_ENFORCE 0x03// Enforce user presence and sign
#define U2F_AUTH_CHECK_ONLY 0x07
Expand Down
10 changes: 8 additions & 2 deletions src/u2f/u2f_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ typedef struct {
} U2FHID_INIT_REQ;


typedef struct {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
typedef struct __attribute__((__packed__))
{
uint8_t nonce[U2FHID_INIT_NONCE_SIZE];
uint32_t cid;
uint8_t versionInterface;
uint8_t versionMajor;
uint8_t versionMinor;
uint8_t versionBuild;
uint8_t capFlags;// Capabilities flags
} U2FHID_INIT_RESP;
}
U2FHID_INIT_RESP;
#pragma GCC diagnostic pop

#define U2FHID_INIT_RESP_SIZE 17

Expand Down
3 changes: 2 additions & 1 deletion src/u2f_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#define APDU_LEN(A) (uint32_t)(((A).lc1 << 16) + ((A).lc2 << 8) + ((A).lc3))
#define U2F_TIMEOUT 500// [msec]
#define U2F_KEYHANDLE_LEN (U2F_NONCE_LENGTH + SHA256_DIGEST_LENGTH)
#define U2F_READBUF_MAX_LEN COMMANDER_REPORT_SIZE// Max allowed by U2F specification = (57 + 128 * 59) = 7609.
#define U2F_READBUF_MAX_LEN COMMANDER_REPORT_SIZE// Max allowed by U2F specification = (57 + 128 * 59) = 7609.
// In practice, U2F commands do not need this much space.
// Therefore, reduce to save MCU memory.

Expand Down Expand Up @@ -452,6 +452,7 @@ static void u2f_device_init(const USB_FRAME *in)
f.init.bcnth = 0;
f.init.bcntl = U2FHID_INIT_RESP_SIZE;

utils_zero(&resp, sizeof(resp));
memcpy(resp.nonce, init_req->nonce, sizeof(init_req->nonce));
resp.cid = in->cid == U2FHID_CID_BROADCAST ? next_cid() : in->cid;
resp.versionInterface = U2FHID_IF_VERSION;
Expand Down