Adding version header to show in lsusb command (bcdDevice) and major version in pkcs15-tool -D.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2022-03-08 18:43:30 +01:00
parent 9be78aade6
commit 4a0144ed2a
5 changed files with 44 additions and 24 deletions

View File

@@ -361,10 +361,6 @@ enum {
BLINK_SUSPENDED = (500 << 16) | 1000,
BLINK_PROCESSING = (50 << 16) | 50,
BLINK_RED = 18,
BLINK_GREEN = 19,
BLINK_BLUE = 20,
BLINK_ALWAYS_ON = UINT32_MAX,
BLINK_ALWAYS_OFF = 0
};
@@ -1558,8 +1554,12 @@ void led_blinking_task()
{
static uint32_t start_ms = 0;
static uint8_t led_state = false;
static uint8_t led_color = BLINK_RED;
static uint8_t led_color = PICO_DEFAULT_LED_PIN;
#ifdef PICO_DEFAULT_LED_PIN_INVERTED
uint32_t interval = !led_state ? blink_interval_ms & 0xffff : blink_interval_ms >> 16;
#else
uint32_t interval = led_state ? blink_interval_ms & 0xffff : blink_interval_ms >> 16;
#endif
// Blink every interval ms
@@ -1573,9 +1573,13 @@ void led_blinking_task()
void led_off_all()
{
gpio_put(18, 1);
gpio_put(19, 1);
gpio_put(20, 1);
#ifdef PIMORONI_TINY2040
gpio_put(TINY2040_LED_R_PIN, 1);
gpio_put(TINY2040_LED_G_PIN, 1);
gpio_put(TINY2040_LED_B_PIN, 1);
#else
gpio_put(PICO_DEFAULT_LED_PIN, 0);
#endif
}
extern void neug_task();
@@ -1587,15 +1591,19 @@ int main(void)
struct apdu *a = &apdu;
struct ccid *c = &ccid;
printf("BOARD INIT\r\n");
board_init();
gpio_init(18);
gpio_set_dir(18, GPIO_OUT);
gpio_init(19);
gpio_set_dir(19, GPIO_OUT);
gpio_init(20);
gpio_set_dir(20, GPIO_OUT);
#ifdef PIMORONI_TINY2040
gpio_init(TINY2040_LED_R_PIN);
gpio_set_dir(TINY2040_LED_R_PIN, GPIO_OUT);
gpio_init(TINY2040_LED_G_PIN);
gpio_set_dir(TINY2040_LED_G_PIN, GPIO_OUT);
gpio_init(TINY2040_LED_B_PIN);
gpio_set_dir(TINY2040_LED_B_PIN, GPIO_OUT);
#else
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
#endif
led_off_all();

View File

@@ -8,6 +8,7 @@
#include "mbedtls/rsa.h"
#include "mbedtls/ecp.h"
#include "mbedtls/ecdsa.h"
#include "version.h"
const uint8_t sc_hsm_aid[] = {
11,
@@ -195,7 +196,7 @@ int parse_token_info(const file_t *f, int mode) {
char *label = "PicoHSM";
char *manu = "Pol Henarejos";
sc_pkcs15_tokeninfo_t *ti = (sc_pkcs15_tokeninfo_t *)calloc(1, sizeof(sc_pkcs15_tokeninfo_t));
ti->version = 3;
ti->version = HSM_VERSION_MAJOR;
ti->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
ti->label = (char *)calloc(strlen(label)+1, sizeof(char));
strlcpy(ti->label, label, strlen(label)+1);

10
src/hsm/version.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef __VERSION_H_
#define __VERSION_H_
#define HSM_VERSION 0x0101
#define HSM_VERSION_MAJOR ((HSM_VERSION >> 8) & 0xff)
#define HSM_VERSION_MINOR (HSM_VERSION & 0xff)
#endif

View File

@@ -27,6 +27,7 @@
#include "usb_descriptors.h"
#include "ccid.h"
#include "pico/unique_id.h"
#include "version.h"
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
@@ -67,7 +68,7 @@ tusb_desc_device_t const desc_device =
.idVendor = (USB_VID),
.idProduct = (USB_PID),
.bcdDevice = (0x0301),
.bcdDevice = HSM_VERSION,
.iManufacturer = 1,
.iProduct = 2,