From 8120829c2f1b7ffccd453b772046aaf5ebbcc29c Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Sat, 26 May 2018 17:27:10 -0400 Subject: [PATCH] support max hid msg size, dont always abort on msg err --- ctaphid.c | 16 +++++----------- ctaphid.h | 7 +++---- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ctaphid.c b/ctaphid.c index 47473d0..a9f63b0 100644 --- a/ctaphid.c +++ b/ctaphid.c @@ -310,8 +310,7 @@ start_over: if (ctaphid_packet_len(pkt) > CTAPHID_BUFFER_SIZE) { printf("Error, internal buffer not big enough\n"); - ctaphid_send_error(pkt->cid, ERR_INVALID_LEN); - ctaphid_init(); + ctaphid_send_error(pkt->cid, CTAP1_ERR_INVALID_LENGTH); return; } } @@ -322,7 +321,6 @@ start_over: { printf("Sequence error\n"); ctaphid_send_error(pkt->cid, ERR_INVALID_SEQ); - ctaphid_init(); return; } } @@ -365,8 +363,7 @@ start_over: if (buffer_len() != 8) { printf("Error,invalid length field for init packet\n"); - ctaphid_send_error(pkt->cid, ERR_INVALID_LEN); - ctaphid_init(); + ctaphid_send_error(pkt->cid, CTAP1_ERR_INVALID_LENGTH); return; } @@ -412,8 +409,7 @@ start_over: if (buffer_len() != 0) { printf("Error,invalid length field for wink packet\n"); - ctaphid_send_error(pkt->cid, ERR_INVALID_LEN); - ctaphid_init(); + ctaphid_send_error(pkt->cid, CTAP1_ERR_INVALID_LENGTH); return; } @@ -431,8 +427,7 @@ start_over: if (buffer_len() == 0) { printf("Error,invalid 0 length field for cbor packet\n"); - ctaphid_send_error(pkt->cid, ERR_INVALID_LEN); - ctaphid_init(); + ctaphid_send_error(pkt->cid, CTAP1_ERR_INVALID_LENGTH); return; } @@ -454,8 +449,7 @@ start_over: if (buffer_len() == 0) { printf("Error,invalid 0 length field for MSG/U2F packet\n"); - ctaphid_send_error(pkt->cid, ERR_INVALID_LEN); - ctaphid_init(); + ctaphid_send_error(pkt->cid, CTAP1_ERR_INVALID_LENGTH); return; } diff --git a/ctaphid.h b/ctaphid.h index 64bc3ad..4db3fc4 100644 --- a/ctaphid.h +++ b/ctaphid.h @@ -2,6 +2,7 @@ #define _CTAPHID_H_H #include "usbhid.h" +#include "ctap_errors.h" #define TYPE_INIT 0x80 #define TYPE_CONT 0x00 @@ -17,7 +18,6 @@ #define ERR_INVALID_CMD 0x01 #define ERR_INVALID_PAR 0x02 - #define ERR_INVALID_LEN 0x03 #define ERR_INVALID_SEQ 0x04 #define ERR_MSG_TIMEOUT 0x05 #define ERR_CHANNEL_BUSY 0x06 @@ -28,15 +28,14 @@ #define CTAPHID_BROADCAST_CID 0xffffffff -#define CTAPHID_BUFFER_SIZE 4096 +#define CTAPHID_BUFFER_SIZE 7609 #define CAPABILITY_WINK 0x01 #define CAPABILITY_LOCK 0x02 #define CAPABILITY_CBOR 0x04 #define CAPABILITY_NMSG 0x08 -//#define CTAP_CAPABILITIES (CAPABILITY_WINK | CAPABILITY_CBOR) -#define CTAP_CAPABILITIES (CAPABILITY_WINK ) +#define CTAP_CAPABILITIES (CAPABILITY_WINK | CAPABILITY_CBOR) typedef struct {