kee

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

commit 7da90d48834bdd732838edfa6eed0c3ef929e9bf
parent 6db4d1cecaadc5336d78381b528d6d40147667ae
Author: lash <dev@holbrook.no>
Date:   Fri,  3 May 2024 18:20:28 +0100

Add pubkey when signing request through gtk ui

Diffstat:
Msrc/gpg.c | 8+++-----
Msrc/gtk/kee-entry.c | 6+++++-
Msrc/ledger.h | 11++++++-----
3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/gpg.c b/src/gpg.c @@ -200,12 +200,9 @@ static char *key_filename(struct gpg_store *gpg, char *path) { static int key_from_data(gcry_sexp_t *key, const char *indata, size_t indata_len) { gcry_error_t e; - size_t c; - c = 0; - e = gcry_sexp_sscan(key, &c, indata, indata_len); + e = gcry_sexp_new(key, indata, indata_len, 0); if (e != GPG_ERR_NO_ERROR) { - //debug_log(DEBUG_DEBUG, indata); return ERR_KEYFAIL; } return ERR_OK; @@ -502,6 +499,7 @@ void gpg_store_init(struct gpg_store *gpg, const char *path) { } } +/// \todo conceal passphrase hashing int gpg_store_check(struct gpg_store *gpg, const char *passphrase) { int r; const char *v; @@ -562,7 +560,7 @@ int gpg_store_check(struct gpg_store *gpg, const char *passphrase) { char pp[4096]; //sprintf(pp, "found key %s in %s", (unsigned char*)m_fingerprint, p.c_str()); sprintf(pp, "found key %s in path: %s", fingerprint, p); - //debug_log(DEBUG_INFO, pp); + debug_log(DEBUG_INFO, pp); } //r = gpg_sign(&o, &k, sign_test); //return r; diff --git a/src/gtk/kee-entry.c b/src/gtk/kee-entry.c @@ -86,6 +86,7 @@ static void kee_entry_handle_add(GtkButton *butt, KeeEntry *o) { char *out; size_t out_len; size_t c; + char passphrase_hash[32]; GVariant *transport_data; buf = gtk_entry_get_buffer(o->form->uoa); @@ -130,7 +131,10 @@ static void kee_entry_handle_add(GtkButton *butt, KeeEntry *o) { buf = gtk_entry_get_buffer(o->form->passphrase); b = (char*)gtk_entry_buffer_get_text(buf); - r = kee_ledger_sign(&o->ledger, o->ledger.last_item, o->gpg, b); + gpg_store_digest(o->gpg, passphrase_hash, b); + + memcpy(o->ledger.pubkey_alice, o->gpg->public_key, PUBKEY_LENGTH); + r = kee_ledger_sign(&o->ledger, o->ledger.last_item, o->gpg, passphrase_hash); if (r) { g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "fail entry sign"); return; diff --git a/src/ledger.h b/src/ledger.h @@ -7,6 +7,7 @@ #include "cadiz.h" #include "gpg.h" #include "db.h" +#include "digest.h" enum kee_initiator_e { ALICE, @@ -28,8 +29,8 @@ struct kee_ledger_item_t { struct timespec time; enum kee_initiator_e initiator; char response; - char alice_signature[64]; - char bob_signature[64]; + char alice_signature[SIGNATURE_LENGTH]; + char bob_signature[SIGNATURE_LENGTH]; struct kee_content_t content; }; @@ -42,10 +43,10 @@ struct kee_ledger_cache_t { }; struct kee_ledger_t { - char digest[64]; + char digest[DIGEST_LENGTH]; struct kee_ledger_item_t *last_item; - char pubkey_alice[32]; - char pubkey_bob[32]; + char pubkey_alice[PUBKEY_LENGTH]; + char pubkey_bob[PUBKEY_LENGTH]; char uoa_decimals; char uoa[64]; struct kee_content_t content;