kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit b03e334f06f39ccc6c25ca001dee72747e6b4c7d
parent 555d4a7cc6a4dd16d342186077a2e6d8dc1130a4
Author: lash <dev@holbrook.no>
Date:   Wed, 17 Apr 2024 09:56:05 +0100

Ensure big-endian timestamp in key from testdata generator

Diffstat:
MMakefile | 2++
Msrc/asn1/schema_entry.txt | 5+++--
Msrc/gtk/kee-entry.c | 19++++++++++++-------
3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile @@ -13,6 +13,8 @@ glade: clean: make -C src clean + rm -vf testdata_asn1schema.py + run: gtk all G_DEBUG=3 G_MESSAGES_DEBUG=all ./src/gtk/a.out diff --git a/src/asn1/schema_entry.txt b/src/asn1/schema_entry.txt @@ -8,16 +8,17 @@ Kee DEFINITIONS EXPLICIT TAGS ::= BEGIN } KeeEntryFlags ::= BIT STRING { - bob-is-signer(0) + byteorder(0), + bob-is-signer(1) } KeeEntry ::= SEQUENCE { + flags KeeEntryFlags, parent OCTET STRING, --- timestamp GeneralizedTime, timestamp INTEGER, creditDelta INTEGER, collateralDelta INTEGER, - flags KeeEntryFlags, body OCTET STRING } END diff --git a/src/gtk/kee-entry.c b/src/gtk/kee-entry.c @@ -115,6 +115,7 @@ static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data int credit; int collateral; int c; + char flags; int v; char *p; @@ -138,7 +139,16 @@ static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data fprintf(stderr, "%s\n", err); return r; } + + c = 1; + flags = 0; + r = asn1_read_value(item, "flags", &flags, &c); + if (r != ASN1_SUCCESS) { + fprintf(stderr, "%s\n", err); + return r; + } + credit = 0; p = (char*)&v; c = sizeof(v); v = 0; @@ -153,6 +163,7 @@ static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data flip_endian(sizeof(credit), (void*)&credit); } + collateral = 0; c = sizeof(v); v = 0; r = asn1_read_value(item, "collateralDelta", p, &c); @@ -166,16 +177,10 @@ static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data flip_endian(sizeof(collateral), (void*)&collateral); } - c = 1; - r = asn1_read_value(item, "flags", &c, err); - if (r != ASN1_SUCCESS) { - fprintf(stderr, "%s\n", err); - return r; - } alice = 0; bob = 0; - if (c & 0x01) { + if (flags & 0x40) { // bit string is left to right bob = credit; } else { alice = credit;