summaryrefslogtreecommitdiff
path: root/fw/src
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-03-23 20:19:24 +0100
committerjaseg <git@jaseg.de>2021-03-23 20:19:24 +0100
commit4fcc3337e21089b50a1034fa05c69d4bd7b84640 (patch)
tree0debac66581849b96dbb4d614cd34c6427353d91 /fw/src
parent32da9c4e8cb2b5252c13b363db7c28675cf60bb5 (diff)
downloadsecure-hid-4fcc3337e21089b50a1034fa05c69d4bd7b84640.tar.gz
secure-hid-4fcc3337e21089b50a1034fa05c69d4bd7b84640.tar.bz2
secure-hid-4fcc3337e21089b50a1034fa05c69d4bd7b84640.zip
Make mouse demo work
Diffstat (limited to 'fw/src')
-rw-r--r--fw/src/demo.c3
-rw-r--r--fw/src/noise.c18
2 files changed, 20 insertions, 1 deletions
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; i<BLAKE2S_HASH_SIZE; i++)
+ LOG_PRINTF("%02x ", remote_fp[i]);
+ LOG_PRINTF("\n");
+ LOG_PRINTF("Key in storage: ");
+ for (int i=0; i<BLAKE2S_HASH_SIZE; i++)
+ LOG_PRINTF("%02x ", st->remote_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; i<BLAKE2S_HASH_SIZE; i++)
+ LOG_PRINTF("%02x ", st->remote_key_reference[i]);
+ LOG_PRINTF("\n");
}
/*@