*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <plugins/pgpcore/sgpgme.h>
#include <plugins/pgpcore/prefs_gpg.h>
#include <plugins/pgpcore/passphrase.h>
#include <plugins/pgpcore/sgpgme.h>
#include <plugins/pgpcore/prefs_gpg.h>
#include <plugins/pgpcore/passphrase.h>
return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
}
static gchar *pgpmime_get_sig_info_full(MimeInfo *mimeinfo)
{
PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
}
static gchar *pgpmime_get_sig_info_full(MimeInfo *mimeinfo)
{
PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
if (mimeinfo->type != MIMETYPE_MULTIPART)
return FALSE;
if (g_ascii_strcasecmp(mimeinfo->subtype, "encrypted"))
if (mimeinfo->type != MIMETYPE_MULTIPART)
return FALSE;
if (g_ascii_strcasecmp(mimeinfo->subtype, "encrypted"))
if (len > 0) {
if (fwrite(chars, 1, len, dstfp) < len) {
FILE_OP_ERROR(fname, "fwrite");
if (len > 0) {
if (fwrite(chars, 1, len, dstfp) < len) {
FILE_OP_ERROR(fname, "fwrite");
if (fclose(dstfp) == EOF) {
FILE_OP_ERROR(fname, "fclose");
privacy_set_error(_("Couldn't close decrypted file %s"), fname);
if (fclose(dstfp) == EOF) {
FILE_OP_ERROR(fname, "fclose");
privacy_set_error(_("Couldn't close decrypted file %s"), fname);
- data->done_sigtest = TRUE;
- data->is_signed = TRUE;
- data->sigstatus = sigstat;
- if (data->ctx)
- gpgme_release(data->ctx);
- data->ctx = ctx;
+ if (data != NULL) {
+ data->done_sigtest = TRUE;
+ data->is_signed = TRUE;
+ data->sigstatus = sigstat;
+ if (data->ctx)
+ gpgme_release(data->ctx);
+ data->ctx = ctx;
+ }
gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
{
MimeInfo *msgcontent, *sigmultipart, *newinfo;
gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
{
MimeInfo *msgcontent, *sigmultipart, *newinfo;
if (result && result->signatures) {
gpgme_new_signature_t sig = result->signatures;
if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP) {
if (result && result->signatures) {
gpgme_new_signature_t sig = result->signatures;
if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP) {
- micalg = g_strdup_printf("PGP-%s", gpgme_hash_algo_name(
- result->signatures->hash_algo));
+ micalg = g_strdup_printf("pgp-%s", g_ascii_strdown(gpgme_hash_algo_name(
+ result->signatures->hash_algo),-1));
if (sigcontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
privacy_set_error(_("Data signing failed, no contents."));
if (sigcontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
privacy_set_error(_("Data signing failed, no contents."));
newinfo = procmime_mimeinfo_new();
newinfo->type = MIMETYPE_APPLICATION;
newinfo->subtype = g_strdup("pgp-signature");
newinfo = procmime_mimeinfo_new();
newinfo->type = MIMETYPE_APPLICATION;
newinfo->subtype = g_strdup("pgp-signature");
newinfo->data.mem = g_malloc(len + 1);
g_memmove(newinfo->data.mem, sigcontent, len);
newinfo->data.mem[len] = '\0';
newinfo->data.mem = g_malloc(len + 1);
g_memmove(newinfo->data.mem, sigcontent, len);
newinfo->data.mem[len] = '\0';
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
if (err) {
debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
privacy_set_error(_("Couldn't add GPG key %s, %s"), fprs[i], gpgme_strerror(err));
if (err) {
debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
privacy_set_error(_("Couldn't add GPG key %s, %s"), fprs[i], gpgme_strerror(err));
enccontent = sgpgme_data_release_and_get_mem(gpgenc, &len);
gpgme_data_release(gpgtext);
g_free(textstr);
enccontent = sgpgme_data_release_and_get_mem(gpgenc, &len);
gpgme_data_release(gpgtext);
g_free(textstr);
if (enccontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
privacy_set_error(_("Encryption failed, %s"), gpgme_strerror(err));
gpgme_release(ctx);
if (enccontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
privacy_set_error(_("Encryption failed, %s"), gpgme_strerror(err));
gpgme_release(ctx);
pgpmime_encrypt,
pgpmime_get_encrypt_warning,
pgpmime_inhibit_encrypt_warning,
pgpmime_encrypt,
pgpmime_get_encrypt_warning,
pgpmime_inhibit_encrypt_warning,