mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-18 20:35:57 +02:00
No more discrimination related with core0/core1. using get_core_num() returns the core number.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -168,19 +168,11 @@ uint32_t neug_get() {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void neug_wait_full(void) { //should be called only on core1
|
void neug_wait_full() {
|
||||||
struct rng_rb *rb = &the_ring_buffer;
|
struct rng_rb *rb = &the_ring_buffer;
|
||||||
|
uint core = get_core_num();
|
||||||
while (!rb->full) {
|
while (!rb->full) {
|
||||||
sleep_ms(1);
|
if (core == 1)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void neug_wait_full_ext(bool blocking) {
|
|
||||||
struct rng_rb *rb = &the_ring_buffer;
|
|
||||||
|
|
||||||
while (!rb->full) {
|
|
||||||
if (blocking == true)
|
|
||||||
sleep_ms(1);
|
sleep_ms(1);
|
||||||
else
|
else
|
||||||
neug_task();
|
neug_task();
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
void neug_init(uint32_t *buf, uint8_t size);
|
void neug_init(uint32_t *buf, uint8_t size);
|
||||||
uint32_t neug_get();
|
uint32_t neug_get();
|
||||||
void neug_flush(void);
|
void neug_flush(void);
|
||||||
void neug_wait_full(void);
|
void neug_wait_full();
|
||||||
void neug_wait_full_ext(bool);
|
|
||||||
void neug_fini(void);
|
void neug_fini(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -79,13 +79,13 @@ void random_get_salt(uint8_t *p) {
|
|||||||
/*
|
/*
|
||||||
* Random byte iterator
|
* Random byte iterator
|
||||||
*/
|
*/
|
||||||
int random_gen_ext(void *arg, unsigned char *out, size_t out_len, bool blocking) {
|
int random_gen(void *arg, unsigned char *out, size_t out_len) {
|
||||||
uint8_t *index_p = (uint8_t *)arg;
|
uint8_t *index_p = (uint8_t *)arg;
|
||||||
uint8_t index = index_p ? *index_p : 0;
|
uint8_t index = index_p ? *index_p : 0;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
while (out_len) {
|
while (out_len) {
|
||||||
neug_wait_full_ext(blocking);
|
neug_wait_full();
|
||||||
|
|
||||||
n = RANDOM_BYTES_LENGTH - index;
|
n = RANDOM_BYTES_LENGTH - index;
|
||||||
if (n > out_len)
|
if (n > out_len)
|
||||||
@@ -107,11 +107,3 @@ int random_gen_ext(void *arg, unsigned char *out, size_t out_len, bool blocking)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int random_gen(void *arg, unsigned char *out, size_t out_len) {
|
|
||||||
return random_gen_ext(arg, out, out_len, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int random_gen_core0(void *arg, unsigned char *out, size_t out_len) {
|
|
||||||
return random_gen_ext(arg, out, out_len, false);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -34,6 +34,5 @@ void random_get_salt (uint8_t *p);
|
|||||||
|
|
||||||
/* iterator returning a byta at a time */
|
/* iterator returning a byta at a time */
|
||||||
extern int random_gen(void *arg, unsigned char *output, size_t output_len);
|
extern int random_gen(void *arg, unsigned char *output, size_t output_len);
|
||||||
extern int random_gen_core0(void *arg, unsigned char *out, size_t out_len);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
static bool mounted = false;
|
static bool mounted = false;
|
||||||
extern int cbor_process(uint8_t, const uint8_t *, size_t);
|
extern int cbor_process(uint8_t, const uint8_t *, size_t);
|
||||||
extern void init_fido(bool);
|
extern void init_fido();
|
||||||
|
|
||||||
typedef struct msg_packet {
|
typedef struct msg_packet {
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
@@ -216,7 +216,7 @@ int driver_process_usb_packet_hid(uint16_t read) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctap_req->init.cmd == CTAPHID_INIT) {
|
if (ctap_req->init.cmd == CTAPHID_INIT) {
|
||||||
init_fido(false);
|
init_fido();
|
||||||
ctap_resp = (CTAPHID_FRAME *)usb_get_tx(ITF_HID);
|
ctap_resp = (CTAPHID_FRAME *)usb_get_tx(ITF_HID);
|
||||||
memset(ctap_resp, 0, 64);
|
memset(ctap_resp, 0, 64);
|
||||||
CTAPHID_INIT_REQ *req = (CTAPHID_INIT_REQ *)ctap_req->init.data;
|
CTAPHID_INIT_REQ *req = (CTAPHID_INIT_REQ *)ctap_req->init.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user