kee

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

commit c784578db051c051abc0c8f1330c3d048f257dc7
parent 3dd7f20a73f39046f2129eddff4cbb91a6635450
Author: lash <dev@holbrook.no>
Date:   Fri, 19 Apr 2024 17:52:03 +0100

Complete signature veirfy function from deserialized ledger

Diffstat:
Msrc/ledger.c | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/ledger.c b/src/ledger.c @@ -107,7 +107,7 @@ static char *get_message(asn1_node item, char *out_digest, char *out_data, size_ } buf[0] = 0; - c = 1; + c = 0; r = asn1_write_value(root, "Kee.KeeEntry.signatureResponse", buf, c); if (r != ASN1_SUCCESS) { return NULL; @@ -204,6 +204,12 @@ static int verify_item(asn1_node item, const char *pubkey_first_data, const char return 1; } + err = gcry_pk_verify(sig, msg, pubkey); + if (err != GPG_ERR_NO_ERROR) { + fprintf(stderr, "verify fail: %s\n", gcry_strerror(err)); + return 1; + } + return 0; } @@ -246,13 +252,13 @@ struct kee_ledger_item_t *kee_ledger_parse_item(struct kee_ledger_t *ledger, con cur->initiator = BOB; credit_delta = &cur->bob_credit_delta; collateral_delta = &cur->bob_collateral_delta; - pubkey_first = (const char*)ledger->pubkey_alice; // alice countersigns bobs - pubkey_last = (const char*)ledger->pubkey_bob; // alice countersigns bobs + pubkey_first = (const char*)ledger->pubkey_bob; // alice countersigns bobs + pubkey_last = (const char*)ledger->pubkey_alice; // alice countersigns bobs } else { credit_delta = &cur->alice_credit_delta; collateral_delta = &cur->alice_collateral_delta; - pubkey_first = (const char*)ledger->pubkey_bob; - pubkey_last = (const char*)ledger->pubkey_alice; + pubkey_first = (const char*)ledger->pubkey_alice; + pubkey_last = (const char*)ledger->pubkey_bob; } r = asn1_der_decoding(&item, data, c, err);