mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 00:51:25 +02:00
@@ -48,7 +48,7 @@ int process_apdu() {
|
|||||||
if (is_chaining) {
|
if (is_chaining) {
|
||||||
memmove(apdu.data + (chain_ptr - chain_buf), apdu.data, apdu.nc);
|
memmove(apdu.data + (chain_ptr - chain_buf), apdu.data, apdu.nc);
|
||||||
memcpy(apdu.data, chain_buf, chain_ptr - chain_buf);
|
memcpy(apdu.data, chain_buf, chain_ptr - chain_buf);
|
||||||
apdu.nc += chain_ptr - chain_buf;
|
apdu.nc += (uint16_t)(chain_ptr - chain_buf);
|
||||||
is_chaining = false;
|
is_chaining = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ uint16_t set_res_sw(uint8_t sw1, uint8_t sw2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ENABLE_EMULATION
|
#ifndef ENABLE_EMULATION
|
||||||
void apdu_thread() {
|
void apdu_thread(void) {
|
||||||
card_init_core1();
|
card_init_core1();
|
||||||
while (1) {
|
while (1) {
|
||||||
uint32_t m = 0;
|
uint32_t m = 0;
|
||||||
|
|||||||
@@ -71,12 +71,7 @@ void generic_hash(mbedtls_md_type_t md, const uint8_t *input, size_t len, uint8_
|
|||||||
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,
|
int aes_encrypt(const uint8_t *key, const uint8_t *iv, uint16_t key_size, int mode, uint8_t *data, uint16_t len) {
|
||||||
const uint8_t *iv,
|
|
||||||
int key_size,
|
|
||||||
int mode,
|
|
||||||
uint8_t *data,
|
|
||||||
int len) {
|
|
||||||
mbedtls_aes_context aes;
|
mbedtls_aes_context aes;
|
||||||
mbedtls_aes_init(&aes);
|
mbedtls_aes_init(&aes);
|
||||||
uint8_t tmp_iv[IV_SIZE];
|
uint8_t tmp_iv[IV_SIZE];
|
||||||
@@ -95,12 +90,7 @@ int aes_encrypt(const uint8_t *key,
|
|||||||
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_ENCRYPT, len, &iv_offset, tmp_iv, data, data);
|
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_ENCRYPT, len, &iv_offset, tmp_iv, data, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int aes_decrypt(const uint8_t *key,
|
int aes_decrypt(const uint8_t *key, const uint8_t *iv, uint16_t key_size, int mode, uint8_t *data, uint16_t len) {
|
||||||
const uint8_t *iv,
|
|
||||||
int key_size,
|
|
||||||
int mode,
|
|
||||||
uint8_t *data,
|
|
||||||
int len) {
|
|
||||||
mbedtls_aes_context aes;
|
mbedtls_aes_context aes;
|
||||||
mbedtls_aes_init(&aes);
|
mbedtls_aes_init(&aes);
|
||||||
uint8_t tmp_iv[IV_SIZE];
|
uint8_t tmp_iv[IV_SIZE];
|
||||||
@@ -120,10 +110,10 @@ int aes_decrypt(const uint8_t *key,
|
|||||||
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_DECRYPT, len, &iv_offset, tmp_iv, data, data);
|
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_DECRYPT, len, &iv_offset, tmp_iv, data, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len) {
|
int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, uint16_t len) {
|
||||||
return aes_encrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
|
return aes_encrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
|
||||||
}
|
}
|
||||||
int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len) {
|
int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, uint16_t len) {
|
||||||
return aes_decrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
|
return aes_decrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,20 +42,10 @@ extern void double_hash_pin(const uint8_t *pin, uint16_t len, uint8_t output[32]
|
|||||||
extern void hash_multi(const uint8_t *input, uint16_t len, uint8_t output[32]);
|
extern void hash_multi(const uint8_t *input, uint16_t len, uint8_t output[32]);
|
||||||
extern void hash256(const uint8_t *input, size_t len, uint8_t output[32]);
|
extern void hash256(const uint8_t *input, size_t len, uint8_t output[32]);
|
||||||
extern void generic_hash(mbedtls_md_type_t md, const uint8_t *input, size_t len, uint8_t *output);
|
extern void generic_hash(mbedtls_md_type_t md, const uint8_t *input, size_t len, uint8_t *output);
|
||||||
extern int aes_encrypt(const uint8_t *key,
|
extern int aes_encrypt(const uint8_t *key, const uint8_t *iv, uint16_t key_size, int mode, uint8_t *data, uint16_t len);
|
||||||
const uint8_t *iv,
|
extern int aes_decrypt(const uint8_t *key, const uint8_t *iv, uint16_t key_size, int mode, uint8_t *data, uint16_t len);
|
||||||
int key_size,
|
extern int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, uint16_t len);
|
||||||
int mode,
|
extern int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, uint16_t len);
|
||||||
uint8_t *data,
|
|
||||||
int len);
|
|
||||||
extern int aes_decrypt(const uint8_t *key,
|
|
||||||
const uint8_t *iv,
|
|
||||||
int key_size,
|
|
||||||
int mode,
|
|
||||||
uint8_t *data,
|
|
||||||
int len);
|
|
||||||
extern int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len);
|
|
||||||
extern int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len);
|
|
||||||
extern mbedtls_ecp_group_id ec_get_curve_from_prime(const uint8_t *prime, size_t prime_len);
|
extern mbedtls_ecp_group_id ec_get_curve_from_prime(const uint8_t *prime, size_t prime_len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,11 +32,13 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#define O_RDWR _O_RDWR
|
#define O_RDWR _O_RDWR
|
||||||
|
#define O_CREAT _O_CREAT
|
||||||
#define open _open
|
#define open _open
|
||||||
#define write _write
|
#define write _write
|
||||||
#define mode_t unsigned short
|
#define mode_t unsigned short
|
||||||
#define lseek _lseek
|
#define lseek _lseek
|
||||||
#include "mman.h"
|
#include "mman.h"
|
||||||
|
#include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
#include "esp_compat.h"
|
#include "esp_compat.h"
|
||||||
@@ -50,14 +52,13 @@ const esp_partition_t *part0;
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#endif
|
||||||
#define FLASH_SECTOR_SIZE 4096
|
#define FLASH_SECTOR_SIZE 4096
|
||||||
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
|
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
|
||||||
#define XIP_BASE 0
|
#define XIP_BASE 0
|
||||||
int fd_map = 0;
|
int fd_map = 0;
|
||||||
uint8_t *map = NULL;
|
uint8_t *map = NULL;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#include "pico_keys.h"
|
#include "pico_keys.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -109,9 +110,7 @@ void do_flash() {
|
|||||||
//printf("WRITTING %X\n",flash_pages[r].address-XIP_BASE);
|
//printf("WRITTING %X\n",flash_pages[r].address-XIP_BASE);
|
||||||
uint32_t ints = save_and_disable_interrupts();
|
uint32_t ints = save_and_disable_interrupts();
|
||||||
flash_range_erase(flash_pages[r].address - XIP_BASE, FLASH_SECTOR_SIZE);
|
flash_range_erase(flash_pages[r].address - XIP_BASE, FLASH_SECTOR_SIZE);
|
||||||
flash_range_program(flash_pages[r].address - XIP_BASE,
|
flash_range_program(flash_pages[r].address - XIP_BASE, flash_pages[r].page, FLASH_SECTOR_SIZE);
|
||||||
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) {
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ void led_blinking_task() {
|
|||||||
}
|
}
|
||||||
#elif defined(CYW43_WL_GPIO_LED_PIN)
|
#elif defined(CYW43_WL_GPIO_LED_PIN)
|
||||||
cyw43_arch_gpio_put(led_color, led_state);
|
cyw43_arch_gpio_put(led_color, led_state);
|
||||||
#elif ESP_PLATFORM
|
#elif defined(ESP_PLATFORM)
|
||||||
neopixel_SetPixel(neopixel, &pixel[led_state], 1);
|
neopixel_SetPixel(neopixel, &pixel[led_state], 1);
|
||||||
#endif
|
#endif
|
||||||
led_state ^= 1; // toggle
|
led_state ^= 1; // toggle
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ static portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
|
|||||||
#define CCID_THREAD_TERMINATED 0xffff
|
#define CCID_THREAD_TERMINATED 0xffff
|
||||||
#define CCID_ACK_TIMEOUT 0x6600
|
#define CCID_ACK_TIMEOUT 0x6600
|
||||||
|
|
||||||
|
PACK(
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t bMessageType;
|
uint8_t bMessageType;
|
||||||
uint32_t dwLength;
|
uint32_t dwLength;
|
||||||
@@ -85,7 +86,7 @@ typedef struct {
|
|||||||
uint8_t abRFU0;
|
uint8_t abRFU0;
|
||||||
uint16_t abRFU1;
|
uint16_t abRFU1;
|
||||||
uint8_t apdu; //Actually it is an array
|
uint8_t apdu; //Actually it is an array
|
||||||
} __attribute__((__packed__)) ccid_header_t;
|
}) ccid_header_t;
|
||||||
|
|
||||||
uint8_t ccid_status = 1;
|
uint8_t ccid_status = 1;
|
||||||
static uint8_t itf_num;
|
static uint8_t itf_num;
|
||||||
|
|||||||
@@ -18,16 +18,9 @@
|
|||||||
#ifndef _CTAP_HID_H_
|
#ifndef _CTAP_HID_H_
|
||||||
#define _CTAP_HID_H_
|
#define _CTAP_HID_H_
|
||||||
|
|
||||||
#ifdef _MSC_VER // Windows
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef unsigned long int uint64_t;
|
|
||||||
#else
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -47,6 +40,7 @@ extern "C" {
|
|||||||
#define TYPE_INIT 0x80 // Initial frame identifier
|
#define TYPE_INIT 0x80 // Initial frame identifier
|
||||||
#define TYPE_CONT 0x00 // Continuation frame identifier
|
#define TYPE_CONT 0x00 // Continuation frame identifier
|
||||||
|
|
||||||
|
PACK(
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t cid; // Channel identifier
|
uint32_t cid; // Channel identifier
|
||||||
union {
|
union {
|
||||||
@@ -62,7 +56,7 @@ typedef struct {
|
|||||||
uint8_t data[HID_RPT_SIZE - 5]; // Data payload
|
uint8_t data[HID_RPT_SIZE - 5]; // Data payload
|
||||||
} cont;
|
} cont;
|
||||||
};
|
};
|
||||||
} __attribute__((__packed__)) CTAPHID_FRAME;
|
}) CTAPHID_FRAME;
|
||||||
|
|
||||||
extern CTAPHID_FRAME *ctap_req, *ctap_resp;
|
extern CTAPHID_FRAME *ctap_req, *ctap_resp;
|
||||||
|
|
||||||
@@ -120,10 +114,12 @@ extern CTAPHID_FRAME *ctap_req, *ctap_resp;
|
|||||||
#define CAPFLAG_WINK 0x01 // Device supports WINK command
|
#define CAPFLAG_WINK 0x01 // Device supports WINK command
|
||||||
#define CAPFLAG_CBOR 0x04 // Device supports CBOR command
|
#define CAPFLAG_CBOR 0x04 // Device supports CBOR command
|
||||||
|
|
||||||
|
PACK(
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t nonce[INIT_NONCE_SIZE]; // Client application nonce
|
uint8_t nonce[INIT_NONCE_SIZE]; // Client application nonce
|
||||||
} __attribute__((__packed__)) CTAPHID_INIT_REQ;
|
}) CTAPHID_INIT_REQ;
|
||||||
|
|
||||||
|
PACK(
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t nonce[INIT_NONCE_SIZE]; // Client application nonce
|
uint8_t nonce[INIT_NONCE_SIZE]; // Client application nonce
|
||||||
uint32_t cid; // Channel identifier
|
uint32_t cid; // Channel identifier
|
||||||
@@ -132,7 +128,7 @@ typedef struct {
|
|||||||
uint8_t versionMinor; // Minor version number
|
uint8_t versionMinor; // Minor version number
|
||||||
uint8_t versionBuild; // Build version number
|
uint8_t versionBuild; // Build version number
|
||||||
uint8_t capFlags; // Capabilities flags
|
uint8_t capFlags; // Capabilities flags
|
||||||
} __attribute__((__packed__)) CTAPHID_INIT_RESP;
|
}) CTAPHID_INIT_RESP;
|
||||||
|
|
||||||
// CTAPHID_SYNC command defines
|
// CTAPHID_SYNC command defines
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,12 @@ uint8_t (*get_version_minor)() = NULL;
|
|||||||
|
|
||||||
static usb_buffer_t hid_rx[ITF_HID_TOTAL] = {0}, hid_tx[ITF_HID_TOTAL] = {0};
|
static usb_buffer_t hid_rx[ITF_HID_TOTAL] = {0}, hid_tx[ITF_HID_TOTAL] = {0};
|
||||||
|
|
||||||
|
PACK(
|
||||||
typedef struct msg_packet {
|
typedef struct msg_packet {
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint16_t current_len;
|
uint16_t current_len;
|
||||||
uint8_t data[CTAP_MAX_PACKET_SIZE];
|
uint8_t data[CTAP_MAX_PACKET_SIZE];
|
||||||
} __attribute__((__packed__)) msg_packet_t;
|
}) msg_packet_t;
|
||||||
|
|
||||||
msg_packet_t msg_packet = { 0 };
|
msg_packet_t msg_packet = { 0 };
|
||||||
|
|
||||||
@@ -247,11 +248,11 @@ void tud_hid_report_complete_cb(uint8_t instance, uint8_t const *report, uint16_
|
|||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
taskENTER_CRITICAL(&mutex);
|
taskENTER_CRITICAL(&mutex);
|
||||||
#endif
|
#endif
|
||||||
CTAPHID_FRAME *ctap_req = (CTAPHID_FRAME *) report;
|
CTAPHID_FRAME *req = (CTAPHID_FRAME *) report;
|
||||||
if (last_write_result[instance] == WRITE_PENDING) {
|
if (last_write_result[instance] == WRITE_PENDING) {
|
||||||
last_write_result[instance] = WRITE_SUCCESS;
|
last_write_result[instance] = WRITE_SUCCESS;
|
||||||
if (FRAME_TYPE(ctap_req) == TYPE_INIT) {
|
if (FRAME_TYPE(req) == TYPE_INIT) {
|
||||||
if (ctap_req->init.cmd != CTAPHID_KEEPALIVE) {
|
if (req->init.cmd != CTAPHID_KEEPALIVE) {
|
||||||
send_buffer_size[instance] -= MIN(64 - 7, send_buffer_size[instance]);
|
send_buffer_size[instance] -= MIN(64 - 7, send_buffer_size[instance]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,11 +261,11 @@ void tud_hid_report_complete_cb(uint8_t instance, uint8_t const *report, uint16_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (last_write_result[instance] == WRITE_SUCCESS) {
|
if (last_write_result[instance] == WRITE_SUCCESS) {
|
||||||
if (FRAME_TYPE(ctap_req) != TYPE_INIT || ctap_req->init.cmd != CTAPHID_KEEPALIVE) {
|
if (FRAME_TYPE(req) != TYPE_INIT || req->init.cmd != CTAPHID_KEEPALIVE) {
|
||||||
if (send_buffer_size[instance] > 0) {
|
if (send_buffer_size[instance] > 0) {
|
||||||
ctap_resp = (CTAPHID_FRAME *) ((uint8_t *) ctap_resp + 64 - 5);
|
ctap_resp = (CTAPHID_FRAME *) ((uint8_t *) ctap_resp + 64 - 5);
|
||||||
uint8_t seq = FRAME_TYPE(ctap_req) == TYPE_INIT ? 0 : FRAME_SEQ(ctap_req) + 1;
|
uint8_t seq = FRAME_TYPE(req) == TYPE_INIT ? 0 : FRAME_SEQ(req) + 1;
|
||||||
ctap_resp->cid = ctap_req->cid;
|
ctap_resp->cid = req->cid;
|
||||||
ctap_resp->cont.seq = seq;
|
ctap_resp->cont.seq = seq;
|
||||||
|
|
||||||
hid_tx[ITF_HID_CTAP].r_ptr += 64 - 5;
|
hid_tx[ITF_HID_CTAP].r_ptr += 64 - 5;
|
||||||
@@ -352,7 +353,7 @@ int driver_process_usb_nopacket_hid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern const uint8_t fido_aid[], u2f_aid[];
|
extern const uint8_t fido_aid[], u2f_aid[];
|
||||||
extern void apdu_thread(), cbor_thread();
|
extern void apdu_thread(void), cbor_thread(void);
|
||||||
|
|
||||||
int driver_process_usb_packet_hid(uint16_t read) {
|
int driver_process_usb_packet_hid(uint16_t read) {
|
||||||
int apdu_sent = 0;
|
int apdu_sent = 0;
|
||||||
@@ -552,7 +553,7 @@ int driver_process_usb_packet_hid(uint16_t read) {
|
|||||||
msg_packet.len = msg_packet.current_len = 0;
|
msg_packet.len = msg_packet.current_len = 0;
|
||||||
last_packet_time = 0;
|
last_packet_time = 0;
|
||||||
if (apdu_sent < 0) {
|
if (apdu_sent < 0) {
|
||||||
return ctap_error(-apdu_sent);
|
return ctap_error((uint8_t)(-apdu_sent));
|
||||||
}
|
}
|
||||||
send_keepalive();
|
send_keepalive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ bool is_busy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void usb_send_event(uint32_t flag) {
|
void usb_send_event(uint32_t flag) {
|
||||||
|
#if !defined(ENABLE_EMULATION)
|
||||||
queue_add_blocking(&usb_to_card_q, &flag);
|
queue_add_blocking(&usb_to_card_q, &flag);
|
||||||
|
#endif
|
||||||
if (flag == EV_CMD_AVAILABLE) {
|
if (flag == EV_CMD_AVAILABLE) {
|
||||||
timeout_start();
|
timeout_start();
|
||||||
}
|
}
|
||||||
@@ -183,16 +185,8 @@ int card_status(uint8_t itf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void) itf;
|
||||||
#endif
|
#endif
|
||||||
return CCID_ERR_FILE_NOT_FOUND;
|
return CCID_ERR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *usb_prepare_response(uint8_t itf) {
|
|
||||||
#ifndef ENABLE_EMULATION
|
|
||||||
#ifdef USB_ITF_CCID
|
|
||||||
#endif
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
return driver_prepare_response_emul(itf);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
#include "pico/util/queue.h"
|
#include "pico/util/queue.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
#include "esp_compat.h"
|
|
||||||
|
|
||||||
/* USB thread */
|
/* USB thread */
|
||||||
#define EV_CARD_CHANGE 1
|
#define EV_CARD_CHANGE 1
|
||||||
@@ -108,12 +107,18 @@ extern void driver_exec_finished_ccid(uint8_t itf, uint16_t size_next);
|
|||||||
extern void driver_exec_finished_cont_ccid(uint8_t itf, uint16_t size_next, uint16_t offset);
|
extern void driver_exec_finished_cont_ccid(uint8_t itf, uint16_t size_next, uint16_t offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_BUFFER_SIZE 2048 // Size of USB buffer
|
#ifdef ENABLE_EMULATION
|
||||||
|
extern void driver_exec_finished_emul(uint8_t itf, uint16_t size_next);
|
||||||
|
extern void driver_exec_finished_cont_emul(uint8_t itf, uint16_t size_next, uint16_t offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define USB_BUFFER_SIZE 2048 // Size of USB buffer"
|
||||||
|
PACK(
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t buffer[USB_BUFFER_SIZE];
|
uint8_t buffer[USB_BUFFER_SIZE];
|
||||||
uint16_t r_ptr, w_ptr;
|
uint16_t r_ptr;
|
||||||
} __attribute__((__packed__)) usb_buffer_t;
|
uint16_t w_ptr;
|
||||||
|
}) usb_buffer_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WRITE_UNKNOWN = 0,
|
WRITE_UNKNOWN = 0,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#ifndef USB_DESCRIPTORS_H_
|
#ifndef USB_DESCRIPTORS_H_
|
||||||
#define USB_DESCRIPTORS_H_
|
#define USB_DESCRIPTORS_H_
|
||||||
|
|
||||||
|
PACK(
|
||||||
struct ccid_class_descriptor {
|
struct ccid_class_descriptor {
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
@@ -41,6 +42,6 @@ struct ccid_class_descriptor {
|
|||||||
uint16_t wLcdLayout;
|
uint16_t wLcdLayout;
|
||||||
uint8_t bPINSupport;
|
uint8_t bPINSupport;
|
||||||
uint8_t bMaxCCIDBusySlots;
|
uint8_t bMaxCCIDBusySlots;
|
||||||
} __attribute__((__packed__));
|
});
|
||||||
|
|
||||||
#endif /* USB_DESCRIPTORS_H_ */
|
#endif /* USB_DESCRIPTORS_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user