aboutsummaryrefslogtreecommitdiff
path: root/plugins/openpgp/src/stream_module.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-16 00:23:51 +0200
committerfiaxh <git@mx.ax.lt>2017-10-22 18:26:31 +0200
commit9ea16b6d8568cb383eb1f469d1dc54bfcad4f188 (patch)
tree27da8705fc99f2407af5e60083e34ddeeff39630 /plugins/openpgp/src/stream_module.vala
parent8b43df8ec3f92477f857280668a9f29f0b9d6229 (diff)
downloaddino-9ea16b6d8568cb383eb1f469d1dc54bfcad4f188.tar.gz
dino-9ea16b6d8568cb383eb1f469d1dc54bfcad4f188.zip
PGP encrypted file transfers
Diffstat (limited to 'plugins/openpgp/src/stream_module.vala')
-rw-r--r--plugins/openpgp/src/stream_module.vala13
1 files changed, 3 insertions, 10 deletions
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<string> 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;