Exemple #1
0
MuError
mu_cmd_verify (MuConfig *opts, GError **err)
{
	MuMsg *msg;
	MuMsgOptions msgopts;
	VData vdata;

	g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
	g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_VERIFY,
			      MU_ERROR_INTERNAL);

	msg = mu_msg_new_from_file (opts->params[1], NULL, err);
	if (!msg)
		return MU_ERROR;

	msgopts = mu_config_get_msg_options (opts);

	vdata.status = MU_MSG_PART_SIG_STATUS_UNKNOWN;
	vdata.opts   = opts;
	vdata.msg    = NULL;

	/* TODO: update for decryption */
	mu_msg_part_foreach (msg, msgopts, (MuMsgPartForeachFunc)each_sig, &vdata);

	/* if there's anything bad, all goodness goes away */
	if (vdata.status & MU_MSG_PART_SIG_STATUS_BAD ||
	    vdata.status & MU_MSG_PART_SIG_STATUS_ERROR)
		vdata.status &= ~MU_MSG_PART_SIG_STATUS_GOOD;

	if (!opts->quiet) {
		gchar *str;
		str = mu_msg_part_sig_statuses_to_string (vdata.status);
		g_print ("verdict: %s\n", str);
		g_free (str);
	}

	mu_msg_unref (msg);

	return vdata.status == MU_MSG_PART_SIG_STATUS_GOOD ? MU_OK : MU_ERROR;
}
Exemple #2
0
char*
mu_msg_part_sig_info_to_string (MuMsgPartSigInfo *info)
{
	GString *gstr;
	gchar *statuses;

	g_return_val_if_fail (info, NULL);

	gstr = g_string_sized_new (128);

	statuses = mu_msg_part_sig_statuses_to_string (info->status);
	g_string_append_printf (gstr, "status: %s", statuses);
	g_free (statuses);

	if (info->status & MU_MSG_PART_SIG_STATUS_ERROR ||
	    info->status & MU_MSG_PART_SIG_STATUS_FAIL)
		return g_string_free (gstr, FALSE);

	g_string_append_printf (gstr, "; algorithms (P/D) (%s, %s)",
				info->pubkey_algo, info->digest_algo);

	g_string_append_printf (gstr, "; created: %s, expires: %s",
				mu_date_str_s ("%c", info->created),
				mu_date_str_s ("%c", info->expires));

	if (info->name || info->email)
		g_string_append_printf (gstr, "; who:%s %s",
					info->name ? info-> name : "",
					info->email ? info->email : "");

	if (info->issuer_name && info->issuer_serial)
		g_string_append_printf (gstr, "; issuer: %s (%s)",
					info->issuer_name,
					info->issuer_serial);
	if (info->fingerprint)
		g_string_append_printf (gstr, "; fingerprint: %s",
					info->fingerprint);

	return g_string_free (gstr, FALSE);
}