From: Laurent Mazet Date: Thu, 10 Apr 2025 20:28:30 +0000 (+0200) Subject: fix all tests X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=6cae43c3836b82e400b0d49c23647c7bfea7ac69;p=morep.git fix all tests --- diff --git a/morep_simulator.c b/morep_simulator.c index 1a76d84..11cc979 100644 --- a/morep_simulator.c +++ b/morep_simulator.c @@ -79,7 +79,7 @@ message_t message_list[] = { /* PRNG service */ {"RANDOM_REQ", prng_e, 0x00, prng_param_e}, - {"RANDOM_RESP", prng_e, 0x01, status_e}, + {"RANDOM_RESP", prng_e, 0x01, raw_data_e}, /* Control service */ {"STATUS_REQ", control_e, 0x00, nopdu_e}, @@ -90,8 +90,8 @@ message_t message_list[] = { {"REBOOT_RESP", control_e, 0x05, status_e}, {"ZEROIZE_REQ", control_e, 0x04, nopdu_e}, {"ZEROIZE_RESP", control_e, 0x05, status_e}, - {"LOCK_REQ", control_e, 0xFE, nopdu_e}, - {"LOCK_RESP", control_e, 0xFF, status_e}, + {"LOCK_CRYPTO_REQ", control_e, 0xFE, nopdu_e}, + {"LOCK_CRYPTO_RESP", control_e, 0xFF, status_e}, /* End of list */ {"", noserv_e, 0x00, undef_pdu_e} @@ -245,7 +245,7 @@ int main (int argc, char **argv) (comm_list + nbcomms)->etype = strrchr (url, '/') + 1; for (int i = 0; (service_list + i)->service_id != noserv_e; i++) { service_t *s = service_list + i; - if (strcmp (s->name, servname) == 0) { + if (s && servname && (strcmp (s->name, servname) == 0)) { memcpy (mode ? &(s->rx) : &(s->tx), comm_list + nbcomms, sizeof (comm_t)); break; } @@ -438,6 +438,8 @@ int main (int argc, char **argv) /* parse message */ pdu = msg->pdu; switch (pdu) { + case nopdu_e: + break; case channel_e: parse_channel (line + offset, &msg_channel); break; @@ -497,7 +499,7 @@ int main (int argc, char **argv) uint8_t msgtype = 0; uint8_t payload[1496] = {0}; - int seqnum = MOREP_Receive (comm->morep, &msgtype, payload, &len); + seqnum = MOREP_Receive (comm->morep, &msgtype, payload, &len); /* check pdu type */ pdu = undef_pdu_e; @@ -517,6 +519,8 @@ int main (int argc, char **argv) /* deserialize message */ switch (pdu) { + case nopdu_e: + break; case channel_e: deserial_channel (payload, len, &msg_channel); break; @@ -551,6 +555,8 @@ int main (int argc, char **argv) serv->name, comm->etype, seqnum, msg->msgtype, len, pdu, msg->name); char buffer[1496 * 3 + 256] = {0}; switch (pdu) { + case nopdu_e: + break; case channel_e: format_channel (&msg_channel, buffer, sizeof (buffer)); break; @@ -596,12 +602,18 @@ int main (int argc, char **argv) /* test: morep_simulator.exe -r 2>&1 | grep 'url not specified' */ /* test: morep_simulator.exe -s 2>&1 | grep 'service not specified' */ /* test: morep_simulator.exe -t 2>&1 | grep 'url not specified' */ -/* test: morep_simulator.exe -l - -t lo://00:00:00:00:00:00/0809 -v 4 script-l0.eth */ +/* test: morep_simulator.exe -l - -t lo://00:00:00:00:00:00/0809 -v 4 script-lo.eth */ /* test: morep_simulator.exe -l script-cross_crypto.log -s CROSS_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-cross_crypto.eth */ +/* test: morep_simulator.exe -l script-cross_crypto.log -s CROSS_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-cross_crypto.eth | grep -v WARNING */ /* test: morep_simulator.exe -l script-local_crypto.log -s LOCAL_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-local_crypto.eth */ +/* test: morep_simulator.exe -l script-local_crypto.log -s LOCAL_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-local_crypto.eth | grep -v WARNING */ /* test: morep_simulator.exe -l script-provisioning.log -s PROVISIONING -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-provisioning.eth */ +/* test: morep_simulator.exe -l script-provisioning.log -s PROVISIONING -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-provisioning.eth | grep -v WARNING */ /* test: morep_simulator.exe -l script-prng.log -s PRNG -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-prng.eth */ +/* test: morep_simulator.exe -l script-prng.log -s PRNG -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-prng.eth | grep -v WARNING */ /* test: morep_simulator.exe -l script-bypass.log -s BYPASS -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-bypass.eth */ -/* test: morep_simulator.exe -l script-control.log -s CONTROL -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-control.eth -v 4 */ +/* test: morep_simulator.exe -l script-bypass.log -s BYPASS -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-bypass.eth | grep -v WARNING */ +/* test: morep_simulator.exe -l script-control.log -s CONTROL -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-control.eth -v 3 */ +/* test: morep_simulator.exe -l script-control.log -s CONTROL -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-control.eth -v 3 | grep -v WARNING */ /* vim: set ts=4 sw=4 si et: */ diff --git a/parse.h b/parse.h index fd94ad4..f141972 100644 --- a/parse.h +++ b/parse.h @@ -320,7 +320,7 @@ __BEGIN_DECLS */ #define SERIAL_ARRAY(name, field) \ if (field##_len < _maxlen - len) { \ - memcpy (_buffer + len, field, field##_len); \ + memcpy (_buffer + len, field, (uint16_t)field##_len); \ len += field##_len; \ } else { \ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \ @@ -337,7 +337,7 @@ __BEGIN_DECLS */ #define SERIAL_TAB(name, field) \ if ((int)sizeof (field) < _maxlen - len) { \ - memcpy (_buffer + len, field, sizeof (field)); \ + memcpy (_buffer + len, field, (uint16_t)sizeof (field)); \ len += sizeof (field); \ } else { \ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \ @@ -444,8 +444,8 @@ __BEGIN_DECLS */ #define DESERIAL_TAB(name, field) \ if ((int)sizeof (field) < end - ptr) { \ - memcpy (field, ptr, sizeof (field)); \ - ptr += sizeof (field); \ + memcpy (field, ptr, (uint16_t)sizeof (field)); \ + ptr += sizeof (field); \ } else { \ VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \ ptr = end + 1; \ @@ -462,13 +462,13 @@ __BEGIN_DECLS */ #define DESERIAL_ARRAY(name, field, ...) \ if ((0 == __VA_ARGS__ + 0) && (ptr < end)) { \ - memcpy (field, ptr, end - ptr); \ + memcpy (field, ptr, (uint16_t)(end - ptr)); \ field##_len = end - ptr; \ ptr = end; \ } else if (field##_len < end - ptr) { \ - memcpy (field, ptr, field##_len); \ + memcpy (field, ptr, (uint16_t)field##_len); \ ptr += field##_len; \ - } else { \ + } else if (field##_len > 0) { \ VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \ ptr = end + 1; \ } diff --git a/script-bypass.eth b/script-bypass.eth index 83eed3b..8fed117 100644 --- a/script-bypass.eth +++ b/script-bypass.eth @@ -1,7 +1,7 @@ # Bypass test script -T:BYPASS BYPASS_CROSS_ASYNC DATA=@makefile +T:BYPASS BYPASS_CROSS_ASYNC DATA=@script-bypass.eth R:BYPASS BYPASS_CROSS_ASYNC -T:BYPASS BYPASSED_CROSS_ASYNC DATA=@makefile +T:BYPASS BYPASSED_CROSS_ASYNC DATA=@script-bypass.eth R:BYPASS BYPASSED_CROSS_ASYNC diff --git a/script-control.eth b/script-control.eth index 6dd8096..d5cce3d 100644 --- a/script-control.eth +++ b/script-control.eth @@ -6,10 +6,10 @@ R:CONTROL STATUS_REQ T:CONTROL STATUS_RESP STATUS=4 R:CONTROL STATUS_RESP -T:CONTROL AUTHENTIFICATION_REQ DATA="This is an authentification phrase" +T:CONTROL AUTHENTIFICATION_REQ DATA="This_is_an_authentification_phrase" R:CONTROL AUTHENTIFICATION_REQ -T:CONTROL AUTHENTIFICATION_RESP DATA="Authentification completed" +T:CONTROL AUTHENTIFICATION_RESP DATA="Authentification_completed" R:CONTROL AUTHENTIFICATION_RESP T:CONTROL REBOOT_REQ @@ -18,11 +18,11 @@ R:CONTROL REBOOT_REQ T:CONTROL REBOOT_RESP STATUS=0 R:CONTROL REBOOT_RESP -T:CONTROL ZEROISE_REQ -R:CONTROL ZEROISE_REQ +T:CONTROL ZEROIZE_REQ +R:CONTROL ZEROIZE_REQ -T:CONTROL ZEROISE_RESP STATUS=0xFF -R:CONTROL ZEROISE_RESP +T:CONTROL ZEROIZE_RESP STATUS=0xFF +R:CONTROL ZEROIZE_RESP T:CONTROL LOCK_CRYPTO_REQ R:CONTROL LOCK_CRYPTO_REQ diff --git a/script-lo.eth b/script-lo.eth index 515b729..4b57454 100644 --- a/script-lo.eth +++ b/script-lo.eth @@ -8,5 +8,5 @@ SLEEP 1000 T0808 MSG=24 DATA=42796520776f726c64 R0808 MSG=24 DATA=42796520776f726c64 -T0808 MSG=10 DATA=@makefile -R0808 MSG=10 DATA=@makefile +T0808 MSG=10 DATA=@script-lo.eth +R0808 MSG=10 DATA=@script-lo.eth diff --git a/script-local_crypto.eth b/script-local_crypto.eth index 875757a..cfca6d5 100644 --- a/script-local_crypto.eth +++ b/script-local_crypto.eth @@ -1,6 +1,6 @@ # Local crypto test script -T:LOCAL_CRYPTO ENCRYPT_LOCAL_ASYNC CHANNELID=2 BYPASSLEN=4 BYPASS=11:22:33:44 DATA=@script-cross_crypto.eth +T:LOCAL_CRYPTO ENCRYPT_LOCAL_ASYNC CHANNELID=2 BYPASSLEN=4 BYPASS=11223344 DATA=@script-cross_crypto.eth R:LOCAL_CRYPTO ENCRYPT_LOCAL_ASYNC T:LOCAL_CRYPTO ENCRYPTED_LOCAL_ASYNC CHANNELID=9 BYPASSLEN=0 DATA=@script-local_crypto.eth @@ -9,5 +9,5 @@ R:LOCAL_CRYPTO ENCRYPTED_LOCAL_ASYNC T:LOCAL_CRYPTO DECRYPT_LOCAL_ASYNC CHANNELID=5 BYPASSLEN=0 DATA=@script-local_crypto.eth R:LOCAL_CRYPTO DECRYPT_LOCAL_ASYNC -T:LOCAL_CRYPTO DECRYPTED_LOCAL_ASYNC CHANNELID=0 BYPASSLEN=4 BYPASS=11:22:33:44 DATA=@script-cross_crypto.eth +T:LOCAL_CRYPTO DECRYPTED_LOCAL_ASYNC CHANNELID=0 BYPASSLEN=4 BYPASS=11223344 DATA=@script-cross_crypto.eth R:LOCAL_CRYPTO DECRYPTED_LOCAL_ASYNC diff --git a/script-prng.eth b/script-prng.eth index 2145b51..517cce3 100644 --- a/script-prng.eth +++ b/script-prng.eth @@ -3,5 +3,5 @@ T:PRNG RANDOM_REQ PRNGID=0 SEQLEN=64 SEED=0102030405060708090A0B0C0D0E0F10 R:PRNG RANDOM_REQ -T:PRNG RANDOM_RESP DATA=@makefile +T:PRNG RANDOM_RESP DATA=@script-prng.eth R:PRNG RANDOM_RESP