Removing trailing spaces.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2022-08-19 01:44:03 +02:00
parent 33b33fdbba
commit 8e5d33c4ba
22 changed files with 230 additions and 230 deletions

View File

@@ -1,17 +1,17 @@
# #
# This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). # This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
# Copyright (c) 2022 Pol Henarejos. # Copyright (c) 2022 Pol Henarejos.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3. # the Free Software Foundation, version 3.
# #
# This program is distributed in the hope that it will be useful, but # This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of # WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details. # General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
@@ -65,7 +65,7 @@ target_compile_options(pico_ccid PUBLIC
-Wall -Wall
-Werror -Werror
) )
pico_add_extra_outputs(pico_ccid) pico_add_extra_outputs(pico_ccid)
target_link_libraries(pico_ccid PRIVATE pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board) target_link_libraries(pico_ccid PRIVATE pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board)

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico HSM distribution (https://github.com/polhenarejos/pico-hsm). * This file is part of the Pico HSM distribution (https://github.com/polhenarejos/pico-hsm).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -61,7 +61,7 @@ int walk_tlv(const uint8_t *cdata, size_t cdata_len, uint8_t **p, uint16_t *tag,
if ((tg & 0x1f) == 0x1f) { if ((tg & 0x1f) == 0x1f) {
tg <<= 8; tg <<= 8;
tg |= *(*p)++; tg |= *(*p)++;
} }
tgl = *(*p)++; tgl = *(*p)++;
if (tgl == 0x82) { if (tgl == 0x82) {
tgl = *(*p)++ << 8; tgl = *(*p)++ << 8;

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico HSM distribution (https://github.com/polhenarejos/pico-hsm). * This file is part of the Pico HSM distribution (https://github.com/polhenarejos/pico-hsm).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -122,7 +122,7 @@ static bool wait_button() {
uint32_t start_button = board_millis(); uint32_t start_button = board_millis();
bool timeout = false; bool timeout = false;
led_set_blink((1000 << 16) | 100); led_set_blink((1000 << 16) | 100);
while (board_button_read() == false) { while (board_button_read() == false) {
execute_tasks(); execute_tasks();
//sleep_ms(10); //sleep_ms(10);
@@ -359,10 +359,10 @@ static void card_init(void) {
void card_thread() { void card_thread() {
card_init (); card_init ();
while (1) { while (1) {
uint32_t m; uint32_t m;
queue_remove_blocking(&ccid_to_card_q, &m); queue_remove_blocking(&ccid_to_card_q, &m);
if (m == EV_VERIFY_CMD_AVAILABLE || m == EV_MODIFY_CMD_AVAILABLE) if (m == EV_VERIFY_CMD_AVAILABLE || m == EV_MODIFY_CMD_AVAILABLE)
{ {
set_res_sw (0x6f, 0x00); set_res_sw (0x6f, 0x00);
@@ -376,7 +376,7 @@ void card_thread() {
} }
process_apdu(); process_apdu();
done:; done:;
uint32_t flag = EV_EXEC_FINISHED; uint32_t flag = EV_EXEC_FINISHED;
queue_add_blocking(&card_to_ccid_q, &flag); queue_add_blocking(&card_to_ccid_q, &flag);
@@ -389,7 +389,7 @@ void card_thread() {
void ccid_task(void) { void ccid_task(void) {
if (tud_vendor_mounted()) { if (tud_vendor_mounted()) {
if (usb_event_handle() != 0) { if (usb_event_handle() != 0) {
} }
usb_write_flush(); usb_write_flush();
uint32_t m = 0x0; uint32_t m = 0x0;
@@ -513,7 +513,7 @@ void led_blinking_task() {
#else #else
uint32_t interval = led_state ? blink_interval_ms & 0xffff : blink_interval_ms >> 16; uint32_t interval = led_state ? blink_interval_ms & 0xffff : blink_interval_ms >> 16;
#endif #endif
// Blink every interval ms // Blink every interval ms
if (board_millis() - start_ms < interval) if (board_millis() - start_ms < interval)
@@ -538,7 +538,7 @@ void led_off_all() {
} }
void init_rtc() { void init_rtc() {
rtc_init(); rtc_init();
datetime_t dt = { datetime_t dt = {
.year = 2020, .year = 2020,
@@ -566,11 +566,11 @@ int main(void) {
ccid_header = (struct ccid_header *)usb_get_rx(); ccid_header = (struct ccid_header *)usb_get_rx();
ccid_header->apdu = usb_get_rx()+10; ccid_header->apdu = usb_get_rx()+10;
apdu.header = ccid_header->apdu; apdu.header = ccid_header->apdu;
ccid_response = (struct ccid_header *)usb_get_tx(); ccid_response = (struct ccid_header *)usb_get_tx();
ccid_response->apdu = usb_get_tx()+10; ccid_response->apdu = usb_get_tx()+10;
apdu.rdata = ccid_response->apdu; apdu.rdata = ccid_response->apdu;
queue_init(&card_to_ccid_q, sizeof(uint32_t), 64); queue_init(&card_to_ccid_q, sizeof(uint32_t), 64);
queue_init(&ccid_to_card_q, sizeof(uint32_t), 64); queue_init(&ccid_to_card_q, sizeof(uint32_t), 64);
@@ -596,15 +596,15 @@ int main(void) {
tusb_init(); tusb_init();
//prepare_ccid(); //prepare_ccid();
random_init(); random_init();
low_flash_init(); low_flash_init();
init_rtc(); init_rtc();
//ccid_prepare_receive(&ccid); //ccid_prepare_receive(&ccid);
while (1) { while (1) {
execute_tasks(); execute_tasks();
neug_task(); neug_task();

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -21,7 +21,7 @@
#include "file.h" #include "file.h"
#include "pico/unique_id.h" #include "pico/unique_id.h"
#include "pico/util/queue.h" #include "pico/util/queue.h"
#include <string.h> #include <string.h>
#define USB_REQ_CCID 0xA1 #define USB_REQ_CCID 0xA1
@@ -55,7 +55,7 @@ extern const uint8_t historical_bytes[];
} }
#else #else
#define DEBUG_PAYLOAD(_p,_s) #define DEBUG_PAYLOAD(_p,_s)
#endif #endif
struct apdu { struct apdu {
uint8_t *header; uint8_t *header;
@@ -92,11 +92,11 @@ enum ccid_state {
CCID_STATE_NOCARD, /* No card available */ CCID_STATE_NOCARD, /* No card available */
CCID_STATE_START, /* Initial */ CCID_STATE_START, /* Initial */
CCID_STATE_WAIT, /* Waiting APDU */ CCID_STATE_WAIT, /* Waiting APDU */
CCID_STATE_EXECUTE, /* Executing command */ CCID_STATE_EXECUTE, /* Executing command */
CCID_STATE_ACK_REQUIRED_0, /* Ack required (executing)*/ CCID_STATE_ACK_REQUIRED_0, /* Ack required (executing)*/
CCID_STATE_ACK_REQUIRED_1, /* Waiting user's ACK (execution finished) */ CCID_STATE_ACK_REQUIRED_1, /* Waiting user's ACK (execution finished) */
CCID_STATE_EXITED, /* CCID Thread Terminated */ CCID_STATE_EXITED, /* CCID Thread Terminated */
CCID_STATE_EXEC_REQUESTED, /* Exec requested */ CCID_STATE_EXEC_REQUESTED, /* Exec requested */
}; };

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -35,12 +35,12 @@ void hash_multi(const uint8_t *input, size_t len, uint8_t output[32]) {
mbedtls_sha256_init(&ctx); mbedtls_sha256_init(&ctx);
int iters = 256; int iters = 256;
pico_unique_board_id_t unique_id; pico_unique_board_id_t unique_id;
pico_get_unique_board_id(&unique_id); pico_get_unique_board_id(&unique_id);
mbedtls_sha256_starts (&ctx, 0); mbedtls_sha256_starts (&ctx, 0);
mbedtls_sha256_update (&ctx, unique_id.id, sizeof(unique_id.id)); mbedtls_sha256_update (&ctx, unique_id.id, sizeof(unique_id.id));
while (iters > len) while (iters > len)
{ {
mbedtls_sha256_update (&ctx, input, len); mbedtls_sha256_update (&ctx, input, len);
@@ -55,7 +55,7 @@ void hash_multi(const uint8_t *input, size_t len, uint8_t output[32]) {
void hash256(const uint8_t *input, size_t len, uint8_t output[32]) { void hash256(const uint8_t *input, size_t len, uint8_t output[32]) {
mbedtls_sha256_context ctx; mbedtls_sha256_context ctx;
mbedtls_sha256_init(&ctx); mbedtls_sha256_init(&ctx);
mbedtls_sha256_starts (&ctx, 0); mbedtls_sha256_starts (&ctx, 0);
mbedtls_sha256_update (&ctx, input, len); mbedtls_sha256_update (&ctx, input, len);
@@ -64,7 +64,7 @@ void hash256(const uint8_t *input, size_t len, uint8_t output[32]) {
} }
void generic_hash(mbedtls_md_type_t md, const uint8_t *input, size_t len, uint8_t *output) { void generic_hash(mbedtls_md_type_t md, const uint8_t *input, size_t len, uint8_t *output) {
mbedtls_md(mbedtls_md_info_from_type(md), input, len, output); mbedtls_md(mbedtls_md_info_from_type(md), input, len, output);
} }
int aes_encrypt(const uint8_t *key, const uint8_t *iv, int key_size, int mode, uint8_t *data, int len) { int aes_encrypt(const uint8_t *key, const uint8_t *iv, int key_size, int mode, uint8_t *data, int len) {

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -94,7 +94,7 @@ int sm_unwrap() {
bool is87 = false; bool is87 = false;
uint16_t tag = 0x0; uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL; uint8_t *tag_data = NULL, *p = NULL;
size_t tag_len = 0; size_t tag_len = 0;
while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) { while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) {
if (tag == 0x87 || tag == 0x85) { if (tag == 0x87 || tag == 0x85) {
body = tag_data; body = tag_data;
@@ -184,7 +184,7 @@ int sm_wrap() {
int sm_get_le() { int sm_get_le() {
uint16_t tag = 0x0; uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL; uint8_t *tag_data = NULL, *p = NULL;
size_t tag_len = 0; size_t tag_len = 0;
while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) { while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) {
if (tag == 0x97) { if (tag == 0x97) {
uint32_t le = 0; uint32_t le = 0;
@@ -236,7 +236,7 @@ int sm_verify() {
size_t mac_len = 0; size_t mac_len = 0;
uint16_t tag = 0x0; uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL; uint8_t *tag_data = NULL, *p = NULL;
size_t tag_len = 0; size_t tag_len = 0;
while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) { while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) {
if (tag & 0x1) { if (tag & 0x1) {
input[input_len++] = tag; input[input_len++] = tag;

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -44,10 +44,10 @@ void process_fci(const file_t *pe, int fmd) {
res_APDU[res_APDU_size++] = 0x6f; res_APDU[res_APDU_size++] = 0x6f;
res_APDU[res_APDU_size++] = 0x00; //computed later res_APDU[res_APDU_size++] = 0x00; //computed later
} }
res_APDU[res_APDU_size++] = 0x62; res_APDU[res_APDU_size++] = 0x62;
res_APDU[res_APDU_size++] = 0x00; //computed later res_APDU[res_APDU_size++] = 0x00; //computed later
res_APDU[res_APDU_size++] = 0x81; res_APDU[res_APDU_size++] = 0x81;
res_APDU[res_APDU_size++] = 2; res_APDU[res_APDU_size++] = 2;
if (pe->data) { if (pe->data) {
@@ -65,7 +65,7 @@ void process_fci(const file_t *pe, int fmd) {
memset(res_APDU+res_APDU_size, 0, 2); memset(res_APDU+res_APDU_size, 0, 2);
res_APDU_size += 2; res_APDU_size += 2;
} }
res_APDU[res_APDU_size++] = 0x82; res_APDU[res_APDU_size++] = 0x82;
res_APDU[res_APDU_size++] = 1; res_APDU[res_APDU_size++] = 1;
res_APDU[res_APDU_size] = 0; res_APDU[res_APDU_size] = 0;
@@ -75,7 +75,7 @@ void process_fci(const file_t *pe, int fmd) {
res_APDU[res_APDU_size++] |= pe->ef_structure & 0x7; res_APDU[res_APDU_size++] |= pe->ef_structure & 0x7;
else if (pe->type == FILE_TYPE_DF) else if (pe->type == FILE_TYPE_DF)
res_APDU[res_APDU_size++] |= 0x38; res_APDU[res_APDU_size++] |= 0x38;
res_APDU[res_APDU_size++] = 0x83; res_APDU[res_APDU_size++] = 0x83;
res_APDU[res_APDU_size++] = 2; res_APDU[res_APDU_size++] = 2;
put_uint16_t(pe->fid, res_APDU+res_APDU_size); put_uint16_t(pe->fid, res_APDU+res_APDU_size);
@@ -130,7 +130,7 @@ file_t *search_by_name(uint8_t *name, uint16_t namelen) {
} }
file_t *search_by_fid(const uint16_t fid, const file_t *parent, const uint8_t sp) { file_t *search_by_fid(const uint16_t fid, const file_t *parent, const uint8_t sp) {
for (file_t *p = file_entries; p != file_last; p++) { for (file_t *p = file_entries; p != file_last; p++) {
if (p->fid != 0x0000 && p->fid == fid) { if (p->fid != 0x0000 && p->fid == fid) {
if (!parent || (parent && is_parent(p, parent))) { if (!parent || (parent && is_parent(p, parent))) {
@@ -190,7 +190,7 @@ bool authenticate_action(const file_t *ef, uint8_t op) {
// PIN required. // PIN required.
if (isUserAuthenticated) { if (isUserAuthenticated) {
return true; return true;
} }
else { else {
return false; return false;
} }
@@ -220,14 +220,14 @@ void scan_region(bool persistent) {
for (uintptr_t base = flash_read_uintptr(endp); base >= startp; base = flash_read_uintptr(base)) { for (uintptr_t base = flash_read_uintptr(endp); base >= startp; base = flash_read_uintptr(base)) {
if (base == 0x0) //all is empty if (base == 0x0) //all is empty
break; break;
uint16_t fid = flash_read_uint16(base+sizeof(uintptr_t)+sizeof(uintptr_t)); uint16_t fid = flash_read_uint16(base+sizeof(uintptr_t)+sizeof(uintptr_t));
printf("[%x] scan fid %x, len %d\r\n",base,fid,flash_read_uint16(base+sizeof(uintptr_t)+sizeof(uintptr_t)+sizeof(uint16_t))); printf("[%x] scan fid %x, len %d\r\n",base,fid,flash_read_uint16(base+sizeof(uintptr_t)+sizeof(uintptr_t)+sizeof(uint16_t)));
file_t *file = (file_t *)search_by_fid(fid, NULL, SPECIFY_EF); file_t *file = (file_t *)search_by_fid(fid, NULL, SPECIFY_EF);
if (!file) { if (!file) {
file = file_new(fid); file = file_new(fid);
} }
if (file) if (file)
file->data = (uint8_t *)(base+sizeof(uintptr_t)+sizeof(uintptr_t)+sizeof(uint16_t)); file->data = (uint8_t *)(base+sizeof(uintptr_t)+sizeof(uintptr_t)+sizeof(uint16_t));
if (flash_read_uintptr(base) == 0x0) { if (flash_read_uintptr(base) == 0x0) {
break; break;
@@ -237,7 +237,7 @@ void scan_region(bool persistent) {
void scan_flash() { void scan_flash() {
initialize_flash(false); //soft initialization initialize_flash(false); //soft initialization
if (*(uintptr_t *)end_data_pool == 0xffffffff && *(uintptr_t *)(end_data_pool+sizeof(uintptr_t)) == 0xffffffff) if (*(uintptr_t *)end_data_pool == 0xffffffff && *(uintptr_t *)(end_data_pool+sizeof(uintptr_t)) == 0xffffffff)
{ {
printf("First initialization (or corrupted!)\r\n"); printf("First initialization (or corrupted!)\r\n");
uint8_t empty[sizeof(uintptr_t)*2+sizeof(uint32_t)]; uint8_t empty[sizeof(uintptr_t)*2+sizeof(uint32_t)];

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -132,10 +132,10 @@ int flash_write_data_to_file_offset(file_t *file, const uint8_t *data, uint16_t
} }
} }
} }
uintptr_t new_addr = allocate_free_addr(len, (file->type & FILE_PERSISTENT) == FILE_PERSISTENT); uintptr_t new_addr = allocate_free_addr(len, (file->type & FILE_PERSISTENT) == FILE_PERSISTENT);
//printf("na %x\r\n",new_addr); //printf("na %x\r\n",new_addr);
if (new_addr == 0x0) if (new_addr == 0x0)
return CCID_ERR_NO_MEMORY; return CCID_ERR_NO_MEMORY;
file->data = (uint8_t *)new_addr+sizeof(uintptr_t)+sizeof(uint16_t)+sizeof(uintptr_t); //next addr+fid+prev addr file->data = (uint8_t *)new_addr+sizeof(uintptr_t)+sizeof(uint16_t)+sizeof(uintptr_t); //next addr+fid+prev addr
flash_program_halfword(new_addr+sizeof(uintptr_t)+sizeof(uintptr_t), file->fid); flash_program_halfword(new_addr+sizeof(uintptr_t)+sizeof(uintptr_t), file->fid);

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -66,8 +66,8 @@ void do_flash()
flash_range_program(flash_pages[r].address-XIP_BASE, flash_pages[r].page, FLASH_SECTOR_SIZE); flash_range_program(flash_pages[r].address-XIP_BASE, flash_pages[r].page, FLASH_SECTOR_SIZE);
restore_interrupts (ints); restore_interrupts (ints);
while (multicore_lockout_end_timeout_us(1000) == false); while (multicore_lockout_end_timeout_us(1000) == false);
//printf("WRITEN %X !\r\n",flash_pages[r].address); //printf("WRITEN %X !\r\n",flash_pages[r].address);
flash_pages[r].ready = false; flash_pages[r].ready = false;
ready_pages--; ready_pages--;
} }
@@ -139,10 +139,10 @@ page_flash_t *find_free_page(uintptr_t addr) {
int flash_program_block(uintptr_t addr, const uint8_t *data, size_t len) { int flash_program_block(uintptr_t addr, const uint8_t *data, size_t len) {
page_flash_t *p = NULL; page_flash_t *p = NULL;
if (!data || len == 0) if (!data || len == 0)
return CCID_ERR_NULL_PARAM; return CCID_ERR_NULL_PARAM;
mutex_enter_blocking(&mtx_flash); mutex_enter_blocking(&mtx_flash);
if (ready_pages == TOTAL_FLASH_PAGES) { if (ready_pages == TOTAL_FLASH_PAGES) {
mutex_exit(&mtx_flash); mutex_exit(&mtx_flash);
@@ -174,7 +174,7 @@ int flash_program_uintptr (uintptr_t addr, uintptr_t data) {
} }
uint8_t *flash_read(uintptr_t addr) { uint8_t *flash_read(uintptr_t addr) {
uintptr_t addr_alg = addr & -FLASH_SECTOR_SIZE; uintptr_t addr_alg = addr & -FLASH_SECTOR_SIZE;
mutex_enter_blocking(&mtx_flash); mutex_enter_blocking(&mtx_flash);
if (ready_pages > 0) { if (ready_pages > 0) {
for (int r = 0; r < TOTAL_FLASH_PAGES; r++) for (int r = 0; r < TOTAL_FLASH_PAGES; r++)
@@ -213,7 +213,7 @@ uint8_t flash_read_uint8(uintptr_t addr) {
int flash_erase_page (uintptr_t addr, size_t page_size) { int flash_erase_page (uintptr_t addr, size_t page_size) {
page_flash_t *p = NULL; page_flash_t *p = NULL;
mutex_enter_blocking(&mtx_flash); mutex_enter_blocking(&mtx_flash);
if (ready_pages == TOTAL_FLASH_PAGES) { if (ready_pages == TOTAL_FLASH_PAGES) {
mutex_exit(&mtx_flash); mutex_exit(&mtx_flash);
@@ -229,7 +229,7 @@ int flash_erase_page (uintptr_t addr, size_t page_size) {
p->ready = false; p->ready = false;
p->page_size = page_size; p->page_size = page_size;
mutex_exit(&mtx_flash); mutex_exit(&mtx_flash);
return CCID_OK; return CCID_OK;
} }

View File

@@ -1,20 +1,20 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
//Part of the code is taken from GnuK (GPLv3) //Part of the code is taken from GnuK (GPLv3)
@@ -72,7 +72,7 @@ static int ep_process () {
random_word *= 0x00000100000001B3; random_word *= 0x00000100000001B3;
if (++ep_round == 8) { if (++ep_round == 8) {
ep_round = 0; ep_round = 0;
return 2; //2 words return 2; //2 words
} }
return 0; return 0;
} }
@@ -122,7 +122,7 @@ static struct rng_rb the_ring_buffer;
void *neug_task() { void *neug_task() {
struct rng_rb *rb = &the_ring_buffer; struct rng_rb *rb = &the_ring_buffer;
int n; int n;
if ((n = ep_process())) { if ((n = ep_process())) {
@@ -147,15 +147,15 @@ void neug_init(uint32_t *buf, uint8_t size) {
struct rng_rb *rb = &the_ring_buffer; struct rng_rb *rb = &the_ring_buffer;
rb_init(rb, buf, size); rb_init(rb, buf, size);
adc_start(); adc_start();
ep_init(); ep_init();
} }
void neug_flush(void) { void neug_flush(void) {
struct rng_rb *rb = &the_ring_buffer; struct rng_rb *rb = &the_ring_buffer;
while (!rb->empty) while (!rb->empty)
rb_del (rb); rb_del (rb);
} }

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -35,4 +35,4 @@ void random_get_salt (uint8_t *p);
/* iterator returning a byta at a time */ /* iterator returning a byta at a time */
int random_gen (void *arg, unsigned char *output, size_t output_len); int random_gen (void *arg, unsigned char *output, size_t output_len);
#endif #endif

View File

@@ -106,7 +106,7 @@
#define CFG_TUD_VENDOR_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) #define CFG_TUD_VENDOR_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#define CFG_TUD_VENDOR_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) #define CFG_TUD_VENDOR_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#include "pico/types.h" #include "pico/types.h"
static inline uint16_t tu_u32_high16(uint32_t ui32) { return (uint16_t) (ui32 >> 16); } static inline uint16_t tu_u32_high16(uint32_t ui32) { return (uint16_t) (ui32 >> 16); }
static inline uint16_t tu_u32_low16 (uint32_t ui32) { return (uint16_t) (ui32 & 0x0000ffffu); } static inline uint16_t tu_u32_low16 (uint32_t ui32) { return (uint16_t) (ui32 & 0x0000ffffu); }

View File

@@ -1,18 +1,18 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -89,7 +89,7 @@ uint16_t usb_read(uint8_t *buffer, size_t buffer_size) {
r_offset += size; r_offset += size;
if (r_offset == w_offset) { if (r_offset == w_offset) {
r_offset = w_offset = 0; r_offset = w_offset = 0;
} }
return size; return size;
} }
return 0; return 0;

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -90,7 +90,7 @@ uint8_t const * tud_descriptor_device_cb(void)
return (uint8_t const *) &desc_device; return (uint8_t const *) &desc_device;
} }
tusb_desc_interface_t const desc_interface = tusb_desc_interface_t const desc_interface =
{ {
.bLength = sizeof(tusb_desc_interface_t), .bLength = sizeof(tusb_desc_interface_t),
.bDescriptorType = TUSB_DESC_INTERFACE, .bDescriptorType = TUSB_DESC_INTERFACE,
@@ -107,7 +107,7 @@ tusb_desc_interface_t const desc_interface =
// Configuration Descriptor // Configuration Descriptor
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
tusb_desc_configuration_t const desc_config = tusb_desc_configuration_t const desc_config =
{ {
.bLength = sizeof(tusb_desc_configuration_t), .bLength = sizeof(tusb_desc_configuration_t),
.bDescriptorType = TUSB_DESC_CONFIGURATION, .bDescriptorType = TUSB_DESC_CONFIGURATION,
@@ -119,7 +119,7 @@ tusb_desc_configuration_t const desc_config =
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(MAX_USB_POWER+1), .bMaxPower = TUSB_DESC_CONFIG_POWER_MA(MAX_USB_POWER+1),
}; };
tusb_desc_endpoint_t const desc_ep1 = tusb_desc_endpoint_t const desc_ep1 =
{ {
.bLength = sizeof(tusb_desc_endpoint_t), .bLength = sizeof(tusb_desc_endpoint_t),
.bDescriptorType = TUSB_DESC_ENDPOINT, .bDescriptorType = TUSB_DESC_ENDPOINT,
@@ -129,7 +129,7 @@ tusb_desc_endpoint_t const desc_ep1 =
.bInterval = 0 .bInterval = 0
}; };
tusb_desc_endpoint_t const desc_ep2 = tusb_desc_endpoint_t const desc_ep2 =
{ {
.bLength = sizeof(tusb_desc_endpoint_t), .bLength = sizeof(tusb_desc_endpoint_t),
.bDescriptorType = TUSB_DESC_ENDPOINT, .bDescriptorType = TUSB_DESC_ENDPOINT,
@@ -144,7 +144,7 @@ static uint8_t desc_config_extended[sizeof(tusb_desc_configuration_t) + sizeof(t
uint8_t const * tud_descriptor_configuration_cb(uint8_t index) uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
{ {
(void) index; // for multiple configurations (void) index; // for multiple configurations
static uint8_t initd = 0; static uint8_t initd = 0;
if (initd == 0) if (initd == 0)
{ {
@@ -205,7 +205,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) )
return NULL; return NULL;
const char* str = string_desc_arr[index]; const char* str = string_desc_arr[index];
@@ -218,7 +218,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
} }
chr_count = strlen(str); chr_count = strlen(str);
if ( chr_count > 31 ) if ( chr_count > 31 )
chr_count = 31; chr_count = 31;
// Convert ASCII string into UTF-16 // Convert ASCII string into UTF-16

View File

@@ -1,17 +1,17 @@
/* /*
* This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid). * This file is part of the Pico CCID distribution (https://github.com/polhenarejos/pico-ccid).
* Copyright (c) 2022 Pol Henarejos. * Copyright (c) 2022 Pol Henarejos.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */