48 |
#include "wptImport.h" |
#include "wptImport.h" |
49 |
#include "wptCrypto.h" |
#include "wptCrypto.h" |
50 |
#include "wptKeyManager.h" |
#include "wptKeyManager.h" |
51 |
|
#include "wptKeyserver.h" |
52 |
#include "openpgp.h" |
#include "openpgp.h" |
53 |
|
|
54 |
|
|
999 |
if (!listview_get_item_state (lv, i)) |
if (!listview_get_item_state (lv, i)) |
1000 |
continue; |
continue; |
1001 |
listview_get_item_text (lv, i, FM_COL_STAT, status, DIM (status) -1); |
listview_get_item_text (lv, i, FM_COL_STAT, status, DIM (status) -1); |
1002 |
if (!strcmp( status, "ENCRYPTED") && fm_cmd == FM_DECRYPT) |
if (!strcmp (status, "ENCRYPTED") && fm_cmd == FM_DECRYPT) |
1003 |
n++; |
n++; |
1004 |
if (!strcmp( status, "UNKNOWN") && fm_cmd == FM_SIGN) |
if (!strcmp (status, "UNKNOWN") && fm_cmd == FM_SIGN) |
1005 |
n++; |
n++; |
1006 |
if (fm_cmd == FM_WIPE) |
if (fm_cmd == FM_WIPE) |
1007 |
ndel++; |
ndel++; |
1026 |
if (!listview_get_item_state (lv, i)) |
if (!listview_get_item_state (lv, i)) |
1027 |
continue; |
continue; |
1028 |
listview_get_item_text (lv, i, FM_COL_NAME, fname, DIM (fname) - 1); |
listview_get_item_text (lv, i, FM_COL_NAME, fname, DIM (fname) - 1); |
1029 |
if( file_exist_check (fname) && !is_directory (fname)) { |
if (file_exist_check (fname) && !is_directory (fname)) { |
1030 |
log_box (_("File Manager"), MB_ERR, |
log_box (_("File Manager"), MB_ERR, |
1031 |
_("\"%s\" does not exist"), fname); |
_("\"%s\" does not exist"), fname); |
1032 |
continue; |
continue; |
1683 |
} |
} |
1684 |
|
|
1685 |
|
|
1686 |
|
/* Handy function to kick of the gpg verify process. */ |
1687 |
|
static gpgme_error_t |
1688 |
|
fm_gpg_verify (gpgme_sig_mode_t sigmode, gpgme_ctx_t ctx, |
1689 |
|
file_data_t in, file_data_t out) |
1690 |
|
{ |
1691 |
|
gpgme_error_t err; |
1692 |
|
|
1693 |
|
op_begin (); |
1694 |
|
if (sigmode == GPGME_SIG_MODE_DETACH) |
1695 |
|
err = gpgme_op_verify (ctx, in->dat, out->dat, NULL); |
1696 |
|
else |
1697 |
|
err = gpgme_op_verify (ctx, in->dat, in->dat, out->dat); |
1698 |
|
op_end (); |
1699 |
|
return err; |
1700 |
|
} |
1701 |
|
|
1702 |
|
|
1703 |
/* Verify the signature from the file @name. If @detached 1, |
/* Verify the signature from the file @name. If @detached 1, |
1704 |
it is assumed that a detached signature should be checked. */ |
it is assumed that a detached signature should be checked. */ |
1705 |
int |
int |
1706 |
fm_verify (fm_state_t c, int detached, const char *name) |
fm_verify (fm_state_t c, int detached, const char *name) |
1707 |
{ |
{ |
|
gpgme_ctx_t ctx = c->ctx; |
|
1708 |
gpgme_error_t err; |
gpgme_error_t err; |
1709 |
gpgme_signature_t s; |
gpgme_signature_t s; |
1710 |
gpgme_verify_result_t res; |
gpgme_verify_result_t res; |
1718 |
if (get_output_file (c, name, detached)) |
if (get_output_file (c, name, detached)) |
1719 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
1720 |
|
|
|
memset (&log, 0, sizeof (log)); |
|
|
log.file = m_strdup (name); |
|
1721 |
file_verify_create_dlg (); |
file_verify_create_dlg (); |
1722 |
|
|
1723 |
|
memset (&log, 0, sizeof (log)); |
1724 |
|
log.file = m_strdup (name); |
1725 |
|
|
1726 |
err = gpg_file_data_new (name, F_DATA_READ, &in); |
err = gpg_file_data_new (name, F_DATA_READ, &in); |
1727 |
if (err) |
if (err) |
1728 |
goto leave; |
goto leave; |
1731 |
if (err) |
if (err) |
1732 |
goto leave; |
goto leave; |
1733 |
|
|
1734 |
op_begin (); |
err = fm_gpg_verify (c->sigmode, c->ctx, in, out); |
|
if (c->sigmode == GPGME_SIG_MODE_DETACH) |
|
|
err = gpgme_op_verify (ctx, in->dat, out->dat, NULL); |
|
|
else |
|
|
err = gpgme_op_verify (ctx, in->dat, in->dat, out->dat); |
|
|
op_end (); |
|
1735 |
if (err) { |
if (err) { |
1736 |
msg_box (c->dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
msg_box (c->dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
1737 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
1738 |
goto leave; |
goto leave; |
1739 |
} |
} |
1740 |
|
|
1741 |
res = gpgme_op_verify_result (ctx); |
res = gpgme_op_verify_result (c->ctx); |
1742 |
if (!res) |
if (!res) |
1743 |
goto leave; |
goto leave; |
1744 |
|
if (res->signatures != NULL && |
1745 |
|
gpgme_err_code (res->signatures->status) == GPG_ERR_NO_PUBKEY) { |
1746 |
|
/* We need to call gpg again to get the actual sig state |
1747 |
|
and the data files must be rewinded also. */ |
1748 |
|
if (fetch_key_from_keyserver (c->dlg, res->signatures)) { |
1749 |
|
rc = WPTERR_GENERAL; |
1750 |
|
goto leave; |
1751 |
|
} |
1752 |
|
gpg_file_data_rewind (in); |
1753 |
|
gpg_file_data_rewind (out); |
1754 |
|
err = fm_gpg_verify (c->sigmode, c->ctx, in, out); |
1755 |
|
if (err) { |
1756 |
|
msg_box (c->dlg, gpgme_strerror (err), _("Verify"), MB_ERR); |
1757 |
|
rc = WPTERR_GENERAL; |
1758 |
|
goto leave; |
1759 |
|
} |
1760 |
|
/* Refresh the pointer because a new GPG instance has been |
1761 |
|
created for the new verify operation. */ |
1762 |
|
res = gpgme_op_verify_result (c->ctx); |
1763 |
|
} |
1764 |
|
|
1765 |
for (s=res->signatures; s; s=s->next) { |
for (s=res->signatures; s; s=s->next) { |
1766 |
log.sig = s; |
log.sig = s; |
1767 |
fm_add_sig_stat (&log); |
fm_add_sig_stat (&log); |