aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/simpleserial
diff options
context:
space:
mode:
authorJ08nY2019-11-25 17:45:35 +0100
committerJ08nY2019-11-25 17:45:35 +0100
commit8a56c7a95e662862cfe78b834ccb091e95d5372f (patch)
tree1fd57480b7fc681f00c0bfb6c0e5cfea86762f87 /pyecsca/codegen/simpleserial
parentc8d0bff46001bd5636825c5b0bb4c896cb34a4e6 (diff)
downloadpyecsca-codegen-8a56c7a95e662862cfe78b834ccb091e95d5372f.tar.gz
pyecsca-codegen-8a56c7a95e662862cfe78b834ccb091e95d5372f.tar.zst
pyecsca-codegen-8a56c7a95e662862cfe78b834ccb091e95d5372f.zip
Add libtommath, HOST build, and a simple PRNG.
Diffstat (limited to 'pyecsca/codegen/simpleserial')
-rw-r--r--pyecsca/codegen/simpleserial/simpleserial.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/pyecsca/codegen/simpleserial/simpleserial.c b/pyecsca/codegen/simpleserial/simpleserial.c
index 8205ed4..ca7c54d 100644
--- a/pyecsca/codegen/simpleserial/simpleserial.c
+++ b/pyecsca/codegen/simpleserial/simpleserial.c
@@ -3,6 +3,7 @@
#include "simpleserial.h"
#include <stdint.h>
#include "hal.h"
+#include <stdio.h>
typedef struct ss_cmd
{
@@ -28,10 +29,13 @@ static char hex_lookup[16] =
int hex_decode(int len, char* ascii_buf, uint8_t* data_buf)
{
- for(int i = 0; i < len; i++)
+ if (len % 2 != 0)
+ return 1;
+
+ for(int i = 0; i < len; i+=2)
{
- char n_hi = ascii_buf[2*i];
- char n_lo = ascii_buf[2*i+1];
+ char n_hi = ascii_buf[i];
+ char n_lo = ascii_buf[i+1];
if(n_lo >= '0' && n_lo <= '9')
data_buf[i] = n_lo - '0';
@@ -125,7 +129,7 @@ void simpleserial_get(void)
// Callback
uint8_t ret[1];
- ret[0] = commands[cmd].fp(data_buf, i);
+ ret[0] = commands[cmd].fp(data_buf, i/2);
// Acknowledge (if version is 1.1)
#if SS_VER == SS_VER_1_1