aboutsummaryrefslogtreecommitdiff
path: root/src/libnpass/gpg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnpass/gpg.c')
-rw-r--r--src/libnpass/gpg.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libnpass/gpg.c b/src/libnpass/gpg.c
index a729028..dedc149 100644
--- a/src/libnpass/gpg.c
+++ b/src/libnpass/gpg.c
@@ -18,7 +18,7 @@
} while (0)
static gpgme_ctx_t ctx = NULL;
-static gpgme_key_t key = NULL;
+static gpgme_key_t key[2] = {0};
static int gpg_init(void);
static void gpg_cleanup(void);
@@ -45,9 +45,9 @@ static int gpg_init(void)
static void gpg_cleanup(void)
{
if (ctx)
- gpgme_key_release(key);
- if (key)
gpgme_release(ctx);
+ if (*key)
+ gpgme_key_release(*key);
}
int gpg_key_validate(const char *fpr)
@@ -59,7 +59,7 @@ int gpg_key_validate(const char *fpr)
if (r)
return r;
- err = gpgme_get_key(ctx, fpr, &key, 1);
+ err = gpgme_get_key(ctx, fpr, key, 1);
gpg_err_ret(err);
gpg_cleanup();
@@ -108,14 +108,14 @@ int gpg_encrypt(FILE *stream, const char *fpr, const char *pass, size_t n)
if (r)
return r;
- err = gpgme_get_key(ctx, fpr, &key, 1);
+ err = gpgme_get_key(ctx, fpr, key, 1);
gpg_err_ret(err);
err = gpgme_data_new_from_mem(&in, pass, n, 0);
gpg_err_ret(err);
err = gpgme_data_new(&out);
gpg_err_ret(err);
- err = gpgme_op_encrypt(ctx, &key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
+ err = gpgme_op_encrypt(ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
gpg_err_ret(err);
r = gpgme_data_seek(out, 0, SEEK_SET);