kee

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

commit 1448fc7d98d3e88fc6e20c4086b7ecf3020d140b
parent 5a4db9725c4d5dd098083c90db453aa0b55f490a
Author: lash <dev@holbrook.no>
Date:   Sat, 27 Apr 2024 05:25:51 +0100

Remove commented and unused code

Diffstat:
Msrc/gpg.c | 28+++-------------------------
Msrc/gpg.h | 2+-
Msrc/ledger.c | 10----------
Msrc/tests/ledger.c | 15++++-----------
4 files changed, 8 insertions(+), 47 deletions(-)

diff --git a/src/gpg.c b/src/gpg.c @@ -400,7 +400,7 @@ int gpg_key_create(struct gpg_store *gpg, const char *passphrase) { return ERR_OK; } -int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mode_e mode, void *criteria) { +int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mode_e mode, const void *criteria) { int r; size_t c; char *p; @@ -446,28 +446,6 @@ int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mo return ERR_OK; } -static int gpg_sign_sexp(gcry_sexp_t *out, gcry_sexp_t *key, const char *v) { - gcry_error_t e; - gcry_sexp_t data; - size_t err_offset; - char in[BUFLEN]; - - e = gcry_sexp_build(&data, &err_offset, "(data(flags eddsa)(hash-algo sha512)(value %b))", 64, v); - if (e) { - sprintf(in, "error sign sexp data build: %s\n", gcry_strerror(e)); - debug_log(DEBUG_ERROR, in); - return ERR_KEYFAIL; - } - e = gcry_pk_sign(out, data, *key); - if (e) { - sprintf(in, "error sign: %s\n", gcry_strerror(e)); - debug_log(DEBUG_ERROR, in); - return ERR_KEYFAIL; - } - - return 0; -} - int gpg_verify(gcry_sexp_t *sig, gcry_sexp_t *key, const char *v) { gcry_error_t e; @@ -633,7 +611,7 @@ int gpg_store_sign_with(struct gpg_store *gpg, char *data, size_t data_len, cons return 1; } c = POINT_LENGTH; - p = gcry_sexp_nth_data(pnt, 1, &c); + p = (char*)gcry_sexp_nth_data(pnt, 1, &c); if (p == NULL) { return 1; } @@ -646,7 +624,7 @@ int gpg_store_sign_with(struct gpg_store *gpg, char *data, size_t data_len, cons return 1; } c = POINT_LENGTH; - p = gcry_sexp_nth_data(pnt, 1, &c); + p = (char*)gcry_sexp_nth_data(pnt, 1, &c); if (p == NULL) { return 1; } diff --git a/src/gpg.h b/src/gpg.h @@ -104,7 +104,7 @@ char *gpg_store_get_fingerprint(struct gpg_store *gpg); //int gpg_key_create(gcry_sexp_t *key); int gpg_key_create(struct gpg_store *gpg, const char *passphrase); //int gpg_sign(gcry_sexp_t *out, gcry_sexp_t *key, const char *v); -int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mode_e mode, void *criteria); +int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mode_e mode, const void *criteria); int gpg_store_sign(struct gpg_store *gpg, char *data, size_t data_len, const char *passphrase); int gpg_store_sign_with(struct gpg_store *gpg, char *data, size_t data_len, const char *passphrase, const char *fingerprint); int gpg_store_verify(const char *sig_bytes, const char *digest, const char *pubkey_bytes); diff --git a/src/ledger.c b/src/ledger.c @@ -115,18 +115,10 @@ static char *get_message(struct kee_ledger_t *ledger, asn1_node item, char *out_ static int verify_item(struct kee_ledger_t *ledger, asn1_node item, const char *pubkey_first_data, const char *pubkey_last_data) { int r; - gcry_sexp_t sig; - gcry_sexp_t msg; - gcry_sexp_t pubkey; - gcry_error_t err; size_t c; - gcry_mpi_t sr; - gcry_mpi_t ss; char sig_data[64]; char msg_data[1024 + 64]; char *p = (char*)msg_data; - char pubkey_sexp_data[1024]; - size_t pubkey_sexp_len; c = 1024; p = get_message(ledger, item, p, p+64, &c); @@ -643,8 +635,6 @@ static int kee_ledger_digest(struct kee_ledger_t *ledger, char *out) { int kee_ledger_sign(struct kee_ledger_t *ledger, struct kee_ledger_item_t *item, struct gpg_store *gpg, char *out, size_t *out_len, const char *passphrase) { int r; char *p; - char *signature_check; - char *signature_target; size_t c; size_t l; enum kee_item_serialize_mode_e mode; diff --git a/src/tests/ledger.c b/src/tests/ledger.c @@ -2,6 +2,7 @@ #include "ledger.h" #include "hex.h" +#include "digest.h" const char *test_ledger_data = "30818e0c035553440201020420c67ee54f93d63d00f4b8c9a7e1c11b39657b55c525704bb32e15ec85bc140d140420adcaf6474132ac36e97d3dbee693d3b186cd8399d402dc505073069c46b5bd780440878102c19c032fd0d06f6b054a01e969b823ccfe7d5ba37a37beef3e64feb5f9b38e1a0f7413b781a4626b884f89bb3052f662692c53578453dc7c7d911d8609"; @@ -183,8 +184,7 @@ int test_sign() { int test_alice() { char *p; int r; - size_t c; - unsigned char *version; + const char *version; struct kee_ledger_t ledger; struct kee_ledger_item_t item; struct gpg_store gpg; @@ -302,10 +302,11 @@ int test_alice() { kee_content_free(&content_item); kee_content_free(&content); kee_ledger_free(&ledger); + + return 0; } int test_parse() { - char *p; int r; size_t c; struct kee_ledger_t ledger; @@ -313,14 +314,6 @@ int test_parse() { struct kee_ledger_item_t *ledger_item_b; Cadiz cadiz; char data[1024]; - char path[1024]; - char out[1024]; - const char *version; - gcry_sexp_t alice; - gcry_sexp_t bob; - char fingerprint_bob[FINGERPRINT_LENGTH]; - size_t out_len; - struct kee_ledger_item_t *item_parsed; cadiz.locator = "./testdata_resource";