diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-12 14:44:09 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-12 14:44:09 +0100 |
commit | f24b47c44db03a8d9ba611f827e71aeb1f63d0bd (patch) | |
tree | 85a2622877dab97b15ff4862505f3770adaf4bd0 /plugins/gpgme-vala/src/gpgme_helper.vala | |
parent | dbbe5e39d069196aa17951b12575492cfa8c7976 (diff) | |
download | dino-f24b47c44db03a8d9ba611f827e71aeb1f63d0bd.tar.gz dino-f24b47c44db03a8d9ba611f827e71aeb1f63d0bd.zip |
PGP module: store data in own db, use pgp key as specified in account settings
Diffstat (limited to 'plugins/gpgme-vala/src/gpgme_helper.vala')
-rw-r--r-- | plugins/gpgme-vala/src/gpgme_helper.vala | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/gpgme-vala/src/gpgme_helper.vala index 9efa2b4c..429c96f0 100644 --- a/plugins/gpgme-vala/src/gpgme_helper.vala +++ b/plugins/gpgme-vala/src/gpgme_helper.vala @@ -28,12 +28,13 @@ public static string decrypt(string encr) throws GLib.Error { return get_string_from_data(dec_data); } -public static string sign(string plain, SigMode mode) throws GLib.Error { +public static string sign(string plain, SigMode mode, Key? key = null) throws GLib.Error { initialize(); global_mutex.lock(); Data plain_data = Data.create_from_memory(plain.data, false); Context context = Context.create(); + if (key != null) context.signers_add(key); Data signed_data = context.op_sign(plain_data, mode); global_mutex.unlock(); return get_string_from_data(signed_data); @@ -76,11 +77,19 @@ public static Gee.List<Key> get_keylist(string? pattern = null, bool secret_only } public static Key? get_public_key(string sig) throws GLib.Error { + return get_key(sig, false); +} + +public static Key? get_private_key(string sig) throws GLib.Error { + return get_key(sig, true); +} + +private static Key? get_key(string sig, bool priv) throws GLib.Error { initialize(); global_mutex.lock(); Context context = Context.create(); - Key key = context.get_key(sig, false); + Key key = context.get_key(sig, priv); global_mutex.unlock(); return key; } |