kee

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

commit 3d27fe8d3e88fc52bda6da98609ca16419753cf3
parent 3b310df2078f8d6c5a1297908a1f24853fa70c12
Author: lash <dev@holbrook.no>
Date:   Sun, 21 Apr 2024 11:05:16 +0100

Allow case insensitive dn, use pubkey for missing uid

Diffstat:
Msrc/dn.c | 21++++++++++++++++-----
Msrc/gtk/kee-entry.c | 32++++++++++++++------------------
Msrc/ledger.c | 2--
3 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/src/dn.c b/src/dn.c @@ -13,12 +13,17 @@ struct kee_dn_t* kee_dn_init(struct kee_dn_t *dn, size_t cap) { dn->mem = malloc(cap); dn->p = (char*)dn->mem; dn->cn = NULL; + dn->c = NULL; + dn->uid = NULL; + dn->o = NULL; + dn->dc = NULL; return dn; } int kee_dn_from_str(struct kee_dn_t *dn, const char *s, size_t l) { int r; int i; + int j; LDAPDN ldn; LDAPRDN lrdn; LDAPAVA *ldnav; @@ -39,15 +44,21 @@ int kee_dn_from_str(struct kee_dn_t *dn, const char *s, size_t l) { break; } ldnav = *lrdn; - - memcpy(tmp, ldnav->la_attr.bv_val, ldnav->la_attr.bv_len); - tmp[ldnav->la_attr.bv_len] = 0; - if (!strcmp(tmp, "CN")) { + + for (j = 0; j < ldnav->la_attr.bv_len; j++) { + tmp[j] = ldnav->la_attr.bv_val[j] | 0x60; + } + tmp[j] = 0; + + if (!strcmp(tmp, "cn")) { dn->cn = dn->p; dst = dn->cn; - } else if (!strcmp(tmp, "O")) { + } else if (!strcmp(tmp, "o")) { dn->o = dn->p; dst = dn->o; + } else if (!strcmp(tmp, "uid")) { + dn->uid = dn->p; + dst = dn->uid; } else { return 1; } diff --git a/src/gtk/kee-entry.c b/src/gtk/kee-entry.c @@ -131,6 +131,19 @@ int kee_entry_deserialize(KeeEntry *o, const char *data, size_t data_len) { if (r) { return ERR_FAIL; } + + last_value_length = 129; + strcpy(last_value, "uid="); + if (o->bob_dn.uid == NULL) { + r = bin_to_hex((unsigned char*)o->ledger.pubkey_bob, 32, (unsigned char*)last_value+4, &last_value_length); + if (r) { + return ERR_FAIL; + } + r = kee_dn_from_str(&o->bob_dn, last_value, last_value_length); + if (r) { + return ERR_FAIL; + } + } r = calculate_digest_algo(data, data_len, o->current_id, GCRY_MD_SHA512); if (r) { @@ -161,33 +174,16 @@ static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data } void kee_entry_apply_list_item_widget(KeeEntry *o) { - int r; GtkWidget *widget; - size_t l; - unsigned char alice_hex[129]; - unsigned char bob_hex[129]; - char *bob; if (o->state) { g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "entry must be loaded first"); return; } -// bob = NULL; -// r = ldap_rdn2str(*o->bob_dn, &bob, LDAP_DN_FORMAT_LDAPV3); -// if (r) { -// return; -// } - - l = 129; - bin_to_hex((unsigned char*)o->ledger.pubkey_alice, 64, alice_hex, &l); - l = 129; - bin_to_hex((unsigned char*)o->ledger.pubkey_bob, 64, bob_hex, &l); - sprintf(o->header, "[%s] %s -> %s", o->ledger.uoa, alice_hex, bob_hex); + sprintf(o->header, "%s [%s]\n%s (%s)", o->ledger.content.subject, o->ledger.uoa, o->bob_dn.cn, o->bob_dn.uid); widget = gtk_label_new(o->header); gtk_box_append(GTK_BOX(o), widget); - widget = gtk_label_new(o->bob_dn.cn); - gtk_box_append(GTK_BOX(o), widget); return; } diff --git a/src/ledger.c b/src/ledger.c @@ -2,8 +2,6 @@ #include <libtasn1.h> #include <gcrypt.h> -//#include "cmime.h" - #include "ledger.h" #include "cadiz.h" #include "err.h"