From 4fcc3337e21089b50a1034fa05c69d4bd7b84640 Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 23 Mar 2021 20:19:24 +0100 Subject: Make mouse demo work --- fw/src/demo.c | 3 +++ fw/src/noise.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'fw/src') diff --git a/fw/src/demo.c b/fw/src/demo.c index f20e35c..69f8e8e 100644 --- a/fw/src/demo.c +++ b/fw/src/demo.c @@ -296,6 +296,7 @@ void pairing_input(uint8_t modbyte, uint8_t keycode) { case KEY_ENTER: pairing_buf[pairing_buf_pos++] = '\0'; if (!pairing_check(&noise_state, pairing_buf)) { + LOG_PRINTF("Pairing success, persisting remote key.\n"); persist_remote_key(&noise_state); /* FIXME write key to backup memory */ @@ -303,6 +304,8 @@ void pairing_input(uint8_t modbyte, uint8_t keycode) { if (send_encrypted_message(&noise_state, &response, sizeof(response))) LOG_PRINTF("Error sending pairing response packet\n"); + noise_state.failed_handshakes = 0; + } else { /* FIXME sound alarm */ diff --git a/fw/src/noise.c b/fw/src/noise.c index 90aaf36..6405d49 100644 --- a/fw/src/noise.c +++ b/fw/src/noise.c @@ -188,7 +188,7 @@ void uninit_handshake(struct NoiseState *st, enum handshake_state new_state) { noise_handshakestate_free(st->handshake); st->handshake_state = new_state; st->handshake = NULL; - arm_key_scrubber(); + //arm_key_scrubber(); FIXME DEBUG } /*@ @@ -291,9 +291,19 @@ int handshake_phase2(struct NoiseState * const st, uint8_t *buf, size_t len) { BLAKE2s_update(&bc, st->remote_key, sizeof(st->remote_key)); BLAKE2s_finish(&bc, remote_fp); + LOG_PRINTF("Key in memory: "); + for (int i=0; iremote_key_reference[i]); + LOG_PRINTF("\n"); + //@ ghost key_checked_trace = 1; if (!fc_memcmp_uint8(remote_fp, st->remote_key_reference, sizeof(remote_fp))) { /* keys match */ //@ ghost key_match_trace = 1; + LOG_PRINTF("Keys match, accepting peer.\n"); uint8_t response = REPORT_PAIRING_SUCCESS; if (send_encrypted_message(st, &response, sizeof(response))) LOG_PRINTF("Error sending pairing response packet\n"); @@ -303,6 +313,7 @@ int handshake_phase2(struct NoiseState * const st, uint8_t *buf, size_t len) { return 1; } else { /* keys don't match */ + LOG_PRINTF("Keys don't match, requiring pairing.\n"); uint8_t response = REPORT_PAIRING_START; if (send_encrypted_message(st, &response, sizeof(response))) LOG_PRINTF("Error sending pairing response packet\n"); @@ -403,6 +414,11 @@ void persist_remote_key(struct NoiseState *st) { BLAKE2s_update(&bc, st->remote_key, sizeof(st->remote_key)); BLAKE2s_finish(&bc, st->remote_key_reference); st->handshake_state = HANDSHAKE_DONE_KNOWN_HOST; + + LOG_PRINTF("Key in memory: "); + for (int i=0; iremote_key_reference[i]); + LOG_PRINTF("\n"); } /*@ -- cgit