From 9ea16b6d8568cb383eb1f469d1dc54bfcad4f188 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 16 Oct 2017 00:23:51 +0200 Subject: PGP encrypted file transfers --- plugins/openpgp/src/stream_module.vala | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'plugins/openpgp/src/stream_module.vala') diff --git a/plugins/openpgp/src/stream_module.vala b/plugins/openpgp/src/stream_module.vala index 6c55cdc5..068370fd 100644 --- a/plugins/openpgp/src/stream_module.vala +++ b/plugins/openpgp/src/stream_module.vala @@ -33,11 +33,8 @@ namespace Dino.Plugins.OpenPgp { } } - public bool encrypt(Message.Stanza message, Gee.List fprs) { - string[] encrypt_to = new string[fprs.size + 1]; - for (int i = 0; i < fprs.size; i++) encrypt_to[i] = fprs[i]; - encrypt_to[encrypt_to.length - 1] = own_key.fpr; - string? enc_body = gpg_encrypt(message.body, encrypt_to); + public bool encrypt(Message.Stanza message, GPG.Key[] keys) { + string? enc_body = gpg_encrypt(message.body, keys); if (enc_body != null) { message.stanza.put_node(new StanzaNode.build("x", NS_URI_ENCRYPTED).add_self_xmlns().put_node(new StanzaNode.text(enc_body))); message.body = "[This message is OpenPGP encrypted (see XEP-0027)]"; @@ -105,13 +102,9 @@ namespace Dino.Plugins.OpenPgp { } } - private static string? gpg_encrypt(string plain, string[] key_ids) { - GPG.Key[] keys = new GPG.Key[key_ids.length]; + private static string? gpg_encrypt(string plain, GPG.Key[] keys) { string encr; try { - for (int i = 0; i < key_ids.length; i++) { - keys[i] = GPGHelper.get_public_key(key_ids[i]); - } encr = GPGHelper.encrypt_armor(plain, keys, GPG.EncryptFlags.ALWAYS_TRUST); } catch (Error e) { return null; -- cgit v1.2.3-54-g00ecf