void OtrInternal::deleteFingerprint(const psiotr::Fingerprint& fingerprint)
{
    ConnContext* context = otrl_context_find(m_userstate,
                                             fingerprint.username.toUtf8().constData(),
                                             fingerprint.account.toUtf8().constData(),
                                             OTR_PROTOCOL_STRING,
#if (OTRL_VERSION_MAJOR >= 4)
                                             OTRL_INSTAG_BEST,
#endif
                                             false, NULL, NULL, NULL);
    if (context)
    {
        ::Fingerprint* fp = otrl_context_find_fingerprint(context,
                                                          fingerprint.fingerprint,
                                                          0, NULL);
        if (fp)
        {
            if (context->active_fingerprint == fp)
            {
                otrl_context_force_finished(context);
            }
            otrl_context_forget_fingerprint(fp, true);
            write_fingerprints();
        }
    }
}
void OtrInternal::verifyFingerprint(const psiotr::Fingerprint& fingerprint,
                                    bool verified)
{
    ConnContext* context = otrl_context_find(m_userstate,
                                             fingerprint.username.toUtf8().constData(),
                                             fingerprint.account.toUtf8().constData(),
                                             OTR_PROTOCOL_STRING,
#if (OTRL_VERSION_MAJOR >= 4)
                                             OTRL_INSTAG_BEST,
#endif
                                             false, NULL, NULL, NULL);
    if (context)
    {
        ::Fingerprint* fp = otrl_context_find_fingerprint(context,
                                                          fingerprint.fingerprint,
                                                          0, NULL);
        if (fp)
        {
            otrl_context_set_trust(fp, verified? "verified" : "");
            write_fingerprints();

            if (context->active_fingerprint == fp)
            {
                m_callback->stateChange(QString::fromUtf8(context->accountname),
                                        QString::fromUtf8(context->username),
                                        psiotr::OTR_STATECHANGE_TRUST);
            }
        }
    }
}
Esempio n. 3
0
/*
 * Search for a OTR Fingerprint object from the given human readable string and
 * return a pointer to the object if found else NULL.
 */
Fingerprint *otr_find_hash_fingerprint_from_human(const char *human_fp,
		struct otr_user_state *ustate)
{
	char str_fp[OTRL_PRIVKEY_FPRINT_HUMAN_LEN];
	Fingerprint *fp = NULL, *fp_iter = NULL;
	ConnContext *context;

	/* Loop on all context of the user state */
	for (context = ustate->otr_state->context_root; context != NULL;
			context = context->next) {
		/* Loop on all fingerprint of the context */
		for (fp_iter = context->fingerprint_root.next; fp_iter;
				fp_iter = fp_iter->next) {
			otrl_privkey_hash_to_human(str_fp, fp_iter->fingerprint);
			/* Compare human fingerprint given in argument to the current. */
			if (strncmp(str_fp, human_fp, sizeof(str_fp)) == 0) {
				fp = otrl_context_find_fingerprint(context,
						fp_iter->fingerprint, 0, NULL);
				goto end;
			}
		}
	}

end:
	return fp;
}
Esempio n. 4
0
Fingerprint *
otrg_fingerprint_get_origin(OtrgFingerprintClone *clone)
{
	ConnContext *context;

	g_return_val_if_fail(clone != NULL, NULL);

	context = otrg_context_get_origin(clone->cclone);

	if (context == NULL)
		return NULL;

	return otrl_context_find_fingerprint(context, clone->fingerprint,
		0, NULL);
}
/**
 * set fingerprint verified/not verified
 */
void OtrConnection::verifyFingerprint(unsigned char* fp, bool verified) {
	ConnContext* context;
	Fingerprint* fingerprint;
	for (context = userstate->context_root; context != NULL; context = context->next) {
		fingerprint = otrl_context_find_fingerprint(context, 
						            fp, 
						            0, NULL);
		if (verified) {
			otrl_context_set_trust(fingerprint, "verified");
		}
		else {
			otrl_context_set_trust(fingerprint, "");
		}
	}
	write_fingerprints();
}
/**
 * Delete a known fingerprint.
 */
void OtrConnection::deleteFingerprint(unsigned char* fpHash) {
	qWarning() << "löschen";
	ConnContext* context;
	Fingerprint* fp;
//	char fpHuman[45];
//	otrl_privkey_hash_to_human(fpHuman, fpHash);
	for (context = userstate->context_root; context != NULL; context = context->next) {
		fp = otrl_context_find_fingerprint(context, 
						   fpHash, 
						   0, NULL);
		if (fp != NULL) {
			otrl_context_forget_fingerprint(fp, 1);
			break;
		}
	}
	write_fingerprints();
}
Esempio n. 7
0
void OtrInternal::deleteFingerprint(const qutimotr::Fingerprint& fingerprint)
{
    ConnContext* context;
    ::Fingerprint* fp;

    for (context = m_userstate->context_root; context != NULL;
         context = context->next)
    {
        fp = otrl_context_find_fingerprint(context, fingerprint.fingerprint, 0,
                                           NULL);
        if (fp != NULL)
        {
            otrl_context_forget_fingerprint(fp, true);
            break;
        }
    }
    write_fingerprints();
}
Esempio n. 8
0
void OtrInternal::verifyFingerprint(const qutimotr::Fingerprint& fingerprint,
                                    bool verified)
{
    ConnContext* context;
    ::Fingerprint* fp;

    for (context = m_userstate->context_root; context != NULL;
         context = context->next)
    {
        fp = otrl_context_find_fingerprint(context, fingerprint.fingerprint,
                                           0, NULL);
        if (verified)
        {
            otrl_context_set_trust(fp, "verified");
        }
        else
        {
            otrl_context_set_trust(fp, "");
        }
    }

    write_fingerprints();
}
Esempio n. 9
0
/* Read the fingerprint store from a FILE* into the given
 * OtrlUserState.  Use add_app_data to add application data to each
 * ConnContext so created.  The FILE* must be open for reading. */
gcry_error_t otrl_privkey_read_fingerprints_FILEp(OtrlUserState us,
	FILE *storef,
	void (*add_app_data)(void *data, ConnContext *context),
	void  *data)
{
    ConnContext *context;
    char storeline[1000];
    unsigned char fingerprint[20];
    size_t maxsize = sizeof(storeline);

    if (!storef) return gcry_error(GPG_ERR_NO_ERROR);

    while(fgets(storeline, maxsize, storef)) {
	char *username;
	char *accountname;
	char *protocol;
	char *hex;
	char *trust;
	char *tab;
	char *eol;
	Fingerprint *fng;
	int i, j;
	/* Parse the line, which should be of the form:
	 *    username\taccountname\tprotocol\t40_hex_nybbles\n          */
	username = storeline;
	tab = strchr(username, '\t');
	if (!tab) continue;
	*tab = '\0';

	accountname = tab + 1;
	tab = strchr(accountname, '\t');
	if (!tab) continue;
	*tab = '\0';

	protocol = tab + 1;
	tab = strchr(protocol, '\t');
	if (!tab) continue;
	*tab = '\0';

	hex = tab + 1;
	tab = strchr(hex, '\t');
	if (!tab) {
	    eol = strchr(hex, '\r');
	    if (!eol) eol = strchr(hex, '\n');
	    if (!eol) continue;
	    *eol = '\0';
	    trust = NULL;
	} else {
	    *tab = '\0';
	    trust = tab + 1;
	    eol = strchr(trust, '\r');
	    if (!eol) eol = strchr(trust, '\n');
	    if (!eol) continue;
	    *eol = '\0';
	}

	if (strlen(hex) != 40) continue;
	for(j=0, i=0; i<40; i+=2) {
	    fingerprint[j++] = (ctoh(hex[i]) << 4) + (ctoh(hex[i+1]));
	}
	/* Get the context for this user, adding if not yet present */
	context = otrl_context_find(us, username, accountname, protocol,
		1, NULL, add_app_data, data);
	/* Add the fingerprint if not already there */
	fng = otrl_context_find_fingerprint(context, fingerprint, 1, NULL);
	otrl_context_set_trust(fng, trust);
    }

    return gcry_error(GPG_ERR_NO_ERROR);
}