getinfo cmd filled in
This commit is contained in:
61
ctap.c
61
ctap.c
@@ -18,11 +18,49 @@ static void check_ret(CborError ret)
|
||||
}
|
||||
}
|
||||
|
||||
void ctap_get_info(CborEncoder * encoder)
|
||||
{
|
||||
int ret;
|
||||
CborEncoder array;
|
||||
CborEncoder map;
|
||||
|
||||
void ctap_handle_packet(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
||||
const int number_of_map_items = 2;
|
||||
const int number_of_versions = 2;
|
||||
|
||||
ret = cbor_encoder_create_map(encoder, &map, number_of_map_items);
|
||||
check_ret(ret);
|
||||
{
|
||||
|
||||
ret = cbor_encode_uint(&map, 0x01); // versions key
|
||||
check_ret(ret);
|
||||
{
|
||||
ret = cbor_encoder_create_array(&map, &array, number_of_versions);
|
||||
check_ret(ret);
|
||||
ret = cbor_encode_text_stringz(&array, "1.0");
|
||||
check_ret(ret);
|
||||
ret = cbor_encode_text_stringz(&array, "2.0");
|
||||
check_ret(ret);
|
||||
ret = cbor_encoder_close_container(&map, &array);
|
||||
check_ret(ret);
|
||||
}
|
||||
|
||||
ret = cbor_encode_uint(&map, 0x03); // aaguid key
|
||||
check_ret(ret);
|
||||
{
|
||||
ret = cbor_encode_byte_string(&map, CTAP_AAGUID, 16);
|
||||
check_ret(ret);
|
||||
}
|
||||
|
||||
}
|
||||
ret = cbor_encoder_close_container(encoder, &map);
|
||||
check_ret(ret);
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint8_t ctap_handle_packet(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
||||
{
|
||||
uint8_t cmd = *pkt_raw;
|
||||
int ret;
|
||||
pkt_raw++;
|
||||
|
||||
|
||||
@@ -33,7 +71,8 @@ void ctap_handle_packet(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
||||
resp->length = 0;
|
||||
|
||||
CborEncoder encoder;
|
||||
CborEncoder array;
|
||||
cbor_encoder_init(&encoder, buf, sizeof(buf), 0);
|
||||
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
@@ -48,20 +87,7 @@ void ctap_handle_packet(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
||||
break;
|
||||
case CTAP_GET_INFO:
|
||||
printf("CTAP_GET_INFO\n");
|
||||
|
||||
cbor_encoder_init(&encoder, buf, sizeof(buf), 0);
|
||||
|
||||
ret = cbor_encoder_create_array(&encoder, &array, 2);
|
||||
check_ret(ret);
|
||||
|
||||
ret = cbor_encode_text_stringz(&array, "1.0");
|
||||
check_ret(ret);
|
||||
ret = cbor_encode_text_stringz(&array, "2.0");
|
||||
check_ret(ret);
|
||||
|
||||
ret = cbor_encoder_close_container(&encoder, &array);
|
||||
check_ret(ret);
|
||||
|
||||
ctap_get_info(&encoder);
|
||||
dump_hex(buf, cbor_encoder_get_buffer_size(&encoder, buf));
|
||||
|
||||
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
||||
@@ -81,4 +107,5 @@ void ctap_handle_packet(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
||||
}
|
||||
|
||||
printf("cbor structure: %d bytes\n", length - 1);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user