mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-26 05:26:22 +00:00
Bugfixes for OX implementation
* autocomplete for /ox discover * fixed help description * Implemented /ox char command * Validated KeyID length
This commit is contained in:
@@ -45,6 +45,9 @@
|
||||
#include "pgp/gpg.h"
|
||||
|
||||
#ifdef HAVE_LIBGPGME
|
||||
|
||||
#define KEYID_LENGTH 40
|
||||
|
||||
static void _ox_metadata_node__public_key(const char* const fingerprint);
|
||||
static int _ox_metadata_result(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata);
|
||||
|
||||
@@ -165,8 +168,8 @@ ox_announce_public_key(const char* const filename)
|
||||
void
|
||||
ox_discover_public_key(const char* const jid)
|
||||
{
|
||||
assert(jid);
|
||||
log_info("Discovering Public Key for %s", jid);
|
||||
assert(jid && strlen(jid) > 0);
|
||||
log_info("[OX] Discovering Public Key for %s", jid);
|
||||
cons_show("Discovering Public Key for %s", jid);
|
||||
// iq
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
@@ -188,6 +191,7 @@ ox_discover_public_key(const char* const jid)
|
||||
|
||||
xmpp_id_handler_add(connection_get_conn(), _ox_metadata_result, id, strdup(jid));
|
||||
xmpp_send(connection_get_conn(), iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -228,7 +232,7 @@ _ox_metadata_node__public_key(const char* const fingerprint)
|
||||
{
|
||||
log_info("Annonuce OpenPGP metadata: %s", fingerprint);
|
||||
assert(fingerprint);
|
||||
assert(strlen(fingerprint) == 40);
|
||||
assert(strlen(fingerprint) == KEYID_LENGTH);
|
||||
// iq
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
char* id = xmpp_uuid_gen(ctx);
|
||||
@@ -269,7 +273,7 @@ _ox_metadata_result(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void*
|
||||
log_debug("[OX] Processing result %s's metadata.", (char*)userdata);
|
||||
|
||||
if (g_strcmp0(xmpp_stanza_get_type(stanza), "result") != 0) {
|
||||
log_debug("[OX] Error: No result");
|
||||
log_debug("[OX] Error: Unable to load metadata of user %s - Not a stanza result type", (char*)userdata);
|
||||
return FALSE;
|
||||
}
|
||||
// pubsub
|
||||
@@ -301,8 +305,11 @@ _ox_metadata_result(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void*
|
||||
|
||||
while (pubkeymetadata) {
|
||||
const char* fingerprint = xmpp_stanza_get_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT);
|
||||
if (fingerprint) {
|
||||
if ( strlen( fingerprint ) == KEYID_LENGTH ) {
|
||||
cons_show(fingerprint);
|
||||
} else {
|
||||
cons_show("OX: Wrong char size of public key");
|
||||
log_error("[OX] Wrong chat size of public key %s", fingerprint);
|
||||
}
|
||||
pubkeymetadata = xmpp_stanza_get_next(pubkeymetadata);
|
||||
}
|
||||
@@ -332,7 +339,7 @@ _ox_request_public_key(const char* const jid, const char* const fingerprint)
|
||||
{
|
||||
assert(jid);
|
||||
assert(fingerprint);
|
||||
assert(strlen(fingerprint) == 40);
|
||||
assert(strlen(fingerprint) == KEYID_LENGTH);
|
||||
cons_show("Requesting Public Key %s for %s", fingerprint, jid);
|
||||
log_info("[OX] Request %s's public key %s.", jid, fingerprint);
|
||||
// iq
|
||||
|
||||
Reference in New Issue
Block a user