aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-pgp-context.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-09-26 08:08:17 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-09-26 08:08:17 +0800
commit99949cdd3907da9d310fe4a8f8bf927fd4069e58 (patch)
tree79c296f1224c1a4a7491ba76e25b687f49c91f01 /camel/camel-pgp-context.c
parentefdd8e72f9bae4ece3e94225f226efca4013863f (diff)
downloadgsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.tar
gsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.tar.gz
gsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.tar.bz2
gsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.tar.lz
gsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.tar.xz
gsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.tar.zst
gsoc2013-evolution-99949cdd3907da9d310fe4a8f8bf927fd4069e58.zip
No longer takes a remember argument. (pgp_sign): Only uncache the
2001-09-25 Jeffrey Stedfast <fejj@ximian.com> * camel-pgp-context.c (camel_pgp_context_new): No longer takes a remember argument. (pgp_sign): Only uncache the passphrase on failure. (pgp_clearsign): Same. (pgp_encrypt): Here too. (pgp_decrypt): And here. (pass_free): New function to zero the passphrase before freeing it. svn path=/trunk/; revision=13138
Diffstat (limited to 'camel/camel-pgp-context.c')
-rw-r--r--camel/camel-pgp-context.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c
index db87a0dd6c..5983dd71bb 100644
--- a/camel/camel-pgp-context.c
+++ b/camel/camel-pgp-context.c
@@ -58,7 +58,6 @@
struct _CamelPgpContextPrivate {
CamelPgpType type;
char *path;
- gboolean remember;
};
static int pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash,
@@ -141,7 +140,7 @@ camel_pgp_context_get_type (void)
* Return value: the new CamelPgpContext
**/
CamelPgpContext *
-camel_pgp_context_new (CamelSession *session, CamelPgpType type, const char *path, gboolean remember)
+camel_pgp_context_new (CamelSession *session, CamelPgpType type, const char *path)
{
CamelPgpContext *context;
@@ -156,7 +155,6 @@ camel_pgp_context_new (CamelSession *session, CamelPgpType type, const char *pat
context->priv->type = type;
context->priv->path = g_strdup (path);
- context->priv->remember = remember;
return context;
}
@@ -216,6 +214,15 @@ pgp_forget_passphrase (CamelSession *session, CamelPgpType pgp_type, char *useri
camel_session_forget_password (session, NULL, userid ? userid : type, NULL);
}
+static void
+pass_free (char *passphrase)
+{
+ if (passphrase) {
+ memset (passphrase, 0, strlen (passphrase));
+ g_free (passphrase);
+ }
+}
+
static int
cleanup_child (pid_t child)
{
@@ -630,7 +637,7 @@ pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash,
&diagnostics);
g_byte_array_free (plaintext, TRUE);
- g_free (passphrase);
+ pass_free (passphrase);
if (retval != 0 || !*ciphertext) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -642,9 +649,6 @@ pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash,
return -1;
}
- if (!context->priv->remember)
- pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
-
g_free (diagnostics);
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
@@ -658,7 +662,7 @@ pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash,
if (passphrase) {
pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
- g_free (passphrase);
+ pass_free (passphrase);
}
return -1;
@@ -804,7 +808,7 @@ pgp_clearsign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash
&diagnostics);
g_byte_array_free (plaintext, TRUE);
- g_free (passphrase);
+ pass_free (passphrase);
if (retval != 0 || !*ciphertext) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -814,9 +818,6 @@ pgp_clearsign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash
pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
}
- if (!context->priv->remember)
- pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
-
g_free (diagnostics);
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
@@ -830,7 +831,7 @@ pgp_clearsign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash
if (passphrase) {
pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
- g_free (passphrase);
+ pass_free (passphrase);
}
return -1;
@@ -1192,7 +1193,7 @@ pgp_encrypt (CamelCipherContext *ctx, gboolean sign, const char *userid, GPtrArr
g_byte_array_free (plaintext, TRUE);
- g_free (passphrase);
+ pass_free (passphrase);
g_ptr_array_free (argv, TRUE);
if (retval != 0 || !*ciphertext) {
@@ -1207,9 +1208,6 @@ pgp_encrypt (CamelCipherContext *ctx, gboolean sign, const char *userid, GPtrArr
return -1;
}
- if (!context->priv->remember)
- pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
-
g_free (diagnostics);
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
@@ -1222,7 +1220,7 @@ pgp_encrypt (CamelCipherContext *ctx, gboolean sign, const char *userid, GPtrArr
g_byte_array_free (plaintext, TRUE);
if (sign) {
- g_free (passphrase);
+ pass_free (passphrase);
pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
}
@@ -1326,7 +1324,7 @@ pgp_decrypt (CamelCipherContext *ctx, CamelStream *istream,
&diagnostics);
g_byte_array_free (ciphertext, TRUE);
- g_free (passphrase);
+ pass_free (passphrase);
/* gpg returns '1' if it succeedes in decrypting but can't verify the signature */
if (retval != 0 || (context->priv->type == CAMEL_PGP_TYPE_GPG && retval == 1) || !*plaintext) {
@@ -1340,9 +1338,6 @@ pgp_decrypt (CamelCipherContext *ctx, CamelStream *istream,
return -1;
}
- if (!context->priv->remember)
- pgp_forget_passphrase (ctx->session, context->priv->type, NULL);
-
g_free (diagnostics);
camel_stream_write (ostream, plaintext, plainlen);
@@ -1356,7 +1351,7 @@ pgp_decrypt (CamelCipherContext *ctx, CamelStream *istream,
if (passphrase) {
pgp_forget_passphrase (ctx->session, context->priv->type, NULL);
- g_free (passphrase);
+ pass_free (passphrase);
}
return -1;