summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demo.c21
-rw-r--r--src/rand_stm32.c2
-rw-r--r--src/rand_stm32.h2
3 files changed, 16 insertions, 9 deletions
diff --git a/src/demo.c b/src/demo.c
index a4debe5..d39d145 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -175,7 +175,7 @@ volatile struct {
struct dma_usart_file usart2_out_s = {
.usart = USART2,
- .baudrate = 1000000,
+ .baudrate = 115200,
.dma = DMA1,
.stream = 6,
.channel = 4,
@@ -298,6 +298,8 @@ int main(void)
cobs_decode_incremental_initialize(&host_cobs_state);
usart_enable_rx_interrupt(USART2);
nvic_enable_irq(NVIC_USART2_IRQ);
+ nvic_set_priority(NVIC_USART2_IRQ, 3<<4);
+ nvic_set_priority(debug_out_s.irqn, 1<<4);
LOG_PRINTF("\n==================================\n");
LOG_PRINTF("SecureHID device side initializing\n");
@@ -329,14 +331,9 @@ int main(void)
if (!handshake)
LOG_PRINTF("Error starting protocol handshake.\n");
- int i = 0, j = 0;
while (23) {
usbh_poll(tim6_get_time_us());
delay_ms_busy_loop(1); /* approx 1ms interval between usbh_poll() */
- if (i++ == 1000) {
- i = 0;
- LOG_PRINTF("Loop iteration %d\n", 1000*(j++));
- }
if (handshake) {
#define MAX_MESSAGE_LEN 256
@@ -364,6 +361,7 @@ int main(void)
noise_handshakestate_free(handshake);
handshake = NULL;
}
+ host_packet_length = 0; /* Acknowledge to USART ISR the buffer has been handled */
}
break;
@@ -371,7 +369,16 @@ int main(void)
if (noise_handshakestate_split(handshake, &tx_cipher, &rx_cipher) != NOISE_ERROR_NONE) {
LOG_PRINTF("Error splitting handshake state\n");
} else {
- LOG_PRINTF("Noise protocol handshake completed successfully\n");
+ LOG_PRINTF("Noise protocol handshake completed successfully, handshake hash:\n");
+ uint8_t buf[BLAKE2S_HASH_SIZE];
+ if (noise_handshakestate_get_handshake_hash(handshake, buf, sizeof(buf)) != NOISE_ERROR_NONE) {
+ LOG_PRINTF("Error fetching noise handshake state\n");
+ } else {
+ LOG_PRINTF(" ");
+ for (int i=0; i<sizeof(buf); i++)
+ LOG_PRINTF("%02x ", buf[i]);
+ LOG_PRINTF("\n");
+ }
}
noise_handshakestate_free(handshake);
diff --git a/src/rand_stm32.c b/src/rand_stm32.c
index 862587c..03aa98f 100644
--- a/src/rand_stm32.c
+++ b/src/rand_stm32.c
@@ -46,8 +46,6 @@
#include "crypto/noise-c/src/protocol/internal.h"
#include "crypto/noise-c/src/crypto/blake2/blake2s.h"
-#define BLAKE2S_HASH_SIZE 32
-
/* FIXME persist state in backup sram */
extern unsigned _ram_start, _ram_end, _rom_start, _rom_end;
static uint8_t global_stm_rand_state[BLAKE2S_HASH_SIZE];
diff --git a/src/rand_stm32.h b/src/rand_stm32.h
index 6f9ba3d..3e89ec3 100644
--- a/src/rand_stm32.h
+++ b/src/rand_stm32.h
@@ -4,6 +4,8 @@
#include <stdint.h>
#include <unistd.h>
+#define BLAKE2S_HASH_SIZE 32
+
void rand_init(void);
#endif