mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-11 21:08:16 +02:00
Add PHY option to enable specific curves. It's in the app side the management.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -54,6 +54,10 @@ int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len) {
|
|||||||
p += strlen(phy->usb_product);
|
p += strlen(phy->usb_product);
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
}
|
}
|
||||||
|
if (phy->enabled_curves_present) {
|
||||||
|
*p++ = PHY_ENABLED_CURVES;
|
||||||
|
p += put_uint32_t_be(phy->enabled_curves, p);
|
||||||
|
}
|
||||||
|
|
||||||
*len = p - data;
|
*len = p - data;
|
||||||
return PICOKEY_OK;
|
return PICOKEY_OK;
|
||||||
@@ -96,6 +100,11 @@ int phy_unserialize_data(const uint8_t *data, uint16_t len, phy_data_t *phy) {
|
|||||||
phy->usb_product_present = true;
|
phy->usb_product_present = true;
|
||||||
p += strlen(phy->usb_product) + 1;
|
p += strlen(phy->usb_product) + 1;
|
||||||
break;
|
break;
|
||||||
|
case PHY_ENABLED_CURVES:
|
||||||
|
phy->enabled_curves = get_uint32_t_be(p);
|
||||||
|
p += sizeof(uint32_t);
|
||||||
|
phy->enabled_curves_present = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PICOKEY_OK;
|
return PICOKEY_OK;
|
||||||
|
|||||||
28
src/fs/phy.h
28
src/fs/phy.h
@@ -26,13 +26,25 @@
|
|||||||
#define PHY_OPTS 0x6
|
#define PHY_OPTS 0x6
|
||||||
#define PHY_UP_BTN 0x8
|
#define PHY_UP_BTN 0x8
|
||||||
#define PHY_USB_PRODUCT 0x9
|
#define PHY_USB_PRODUCT 0x9
|
||||||
|
#define PHY_ENABLED_CURVES 0xA
|
||||||
|
|
||||||
#define PHY_OPT_WCID 0x1
|
#define PHY_OPT_WCID 0x1
|
||||||
#define PHY_OPT_DIMM 0x2
|
#define PHY_OPT_DIMM 0x2
|
||||||
#define PHY_OPT_DISABLE_POWER_RESET 0x4
|
#define PHY_OPT_DISABLE_POWER_RESET 0x4
|
||||||
#define PHY_OPT_LED_STEADY 0x8
|
#define PHY_OPT_LED_STEADY 0x8
|
||||||
|
|
||||||
|
#define PHY_CURVE_SECP256R1 0x1
|
||||||
|
#define PHY_CURVE_SECP384R1 0x2
|
||||||
|
#define PHY_CURVE_SECP521R1 0x4
|
||||||
|
#define PHY_CURVE_SECP256K1 0x8
|
||||||
|
#define PHY_CURVE_BP256R1 0x10
|
||||||
|
#define PHY_CURVE_BP384R1 0x20
|
||||||
|
#define PHY_CURVE_BP512R1 0x40
|
||||||
|
#define PHY_CURVE_ED25519 0x80
|
||||||
|
#define PHY_CURVE_ED448 0x100
|
||||||
|
#define PHY_CURVE_CURVE25519 0x200
|
||||||
|
#define PHY_CURVE_CURVE448 0x400
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -44,19 +56,27 @@ typedef struct phy_data {
|
|||||||
};
|
};
|
||||||
uint8_t vidpid[4];
|
uint8_t vidpid[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint32_t enabled_curves;
|
||||||
|
|
||||||
|
char usb_product[32];
|
||||||
|
|
||||||
|
uint16_t opts;
|
||||||
|
|
||||||
uint8_t led_gpio;
|
uint8_t led_gpio;
|
||||||
uint8_t led_brightness;
|
uint8_t led_brightness;
|
||||||
uint16_t opts;
|
|
||||||
uint8_t up_btn;
|
uint8_t up_btn;
|
||||||
char usb_product[32];
|
|
||||||
bool vidpid_present;
|
bool vidpid_present;
|
||||||
bool led_gpio_present;
|
bool led_gpio_present;
|
||||||
bool led_brightness_present;
|
bool led_brightness_present;
|
||||||
bool up_btn_present;
|
bool up_btn_present;
|
||||||
bool usb_product_present;
|
bool usb_product_present;
|
||||||
|
bool enabled_curves_present;
|
||||||
|
|
||||||
} phy_data_t;
|
} phy_data_t;
|
||||||
|
|
||||||
#define PHY_MAX_SIZE 47
|
#define PHY_MAX_SIZE sizeof(phy_data_t)
|
||||||
|
|
||||||
#ifndef ENABLE_EMULATION
|
#ifndef ENABLE_EMULATION
|
||||||
extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len);
|
extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len);
|
||||||
|
|||||||
Reference in New Issue
Block a user