summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2024-02-19 21:53:41 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2024-02-19 23:38:40 +0100
commit3e5ab6fdad95666cd998c52be438f767ee8440c9 (patch)
tree9e7015fcaf2afff4ab32a31867b11779a646bff7
parent5462db9901b6540ff46cb9e3b14628cc57c764de (diff)
egismoc: Convert value check values to big endian only when needed
Since the driver seem to require a big-endian value it's just better to use architecture native endianness to compute the check value and eventually just convert to big endian as the chip wants.
-rw-r--r--libfprint/drivers/egismoc/egismoc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/libfprint/drivers/egismoc/egismoc.c b/libfprint/drivers/egismoc/egismoc.c
index 841e7e9..0b5e8d2 100644
--- a/libfprint/drivers/egismoc/egismoc.c
+++ b/libfprint/drivers/egismoc/egismoc.c
@@ -294,23 +294,21 @@ egismoc_get_check_bytes (const guchar *value,
fp_dbg ("Get check bytes");
EgisMocCheckBytes check_bytes;
const size_t steps = (value_length + 1) / 2;
- guint16 big_endian_values[steps];
+ guint16 values[steps];
size_t sum_values = 0;
for (int i = 0, j = 0; i < value_length; i += 2, j++)
{
- big_endian_values[j] = 0;
+ values[j] = (value[i] << 8 & 0xff00);
if (i < value_length - 1)
- big_endian_values[j] = value[i + 1] << 8;
-
- big_endian_values[j] |= (value[i] & 0x00ff);
+ values[j] |= value[i + 1] & 0x00ff;
}
for (int i = 0; i < steps; i++)
- sum_values += big_endian_values[i];
+ sum_values += values[i];
- check_bytes.check_value = GUINT16_TO_LE (0xffff - (sum_values % 0xffff));
+ check_bytes.check_value = GUINT16_TO_BE (0xffff - (sum_values % 0xffff));
return check_bytes;
}