Fri, 20 May 2022 02:55:51 -0500
Update purple_core_init to take a PurpleUiInfo instance
Added an `id` property to `PurpleUiInfo`
Testing Done:
Ran the unit tests and verified I could run Pidgin and connect an account.
Reviewed at https://reviews.imfreedom.org/r/1456/
| 8849 | 1 | /* |
| 2 | ||
| 15884 | 3 | silcpurple_pk.c |
| 8849 | 4 | |
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
7 | Copyright (C) 2004 - 2007 Pekka Riikonen |
| 8849 | 8 | |
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
|
40769
2214cc7b95ca
Fix SILC compilation
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40195
diff
changeset
|
20 | #include <glib/gi18n-lib.h> |
|
2214cc7b95ca
Fix SILC compilation
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40195
diff
changeset
|
21 | #include <glib/gstdio.h> |
|
2214cc7b95ca
Fix SILC compilation
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40195
diff
changeset
|
22 | |
|
40195
fb4b0ae193c0
Remove glibcompat.h from all the files that don't actually need it.
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
23 | #include "glibcompat.h" /* for purple_g_stat on win32 */ |
| 15884 | 24 | #include "silcpurple.h" |
| 8849 | 25 | |
| 26 | /************************* Public Key Verification ***************************/ | |
| 27 | ||
| 28 | typedef struct { | |
| 29 | SilcClient client; | |
| 30 | SilcClientConnection conn; | |
| 31 | char *filename; | |
| 32 | char *entity; | |
| 33 | char *entity_name; | |
| 34 | char *fingerprint; | |
| 35 | char *babbleprint; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
36 | SilcPublicKey public_key; |
| 8849 | 37 | SilcVerifyPublicKey completion; |
| 38 | void *context; | |
| 39 | gboolean changed; | |
| 40 | } *PublicKeyVerify; | |
| 41 | ||
| 15884 | 42 | static void silcpurple_verify_ask(const char *entity, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
43 | const char *fingerprint, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
44 | const char *babbleprint, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
45 | PublicKeyVerify verify); |
| 8849 | 46 | |
| 15884 | 47 | static void silcpurple_verify_cb(PublicKeyVerify verify, gint id) |
| 8849 | 48 | { |
| 49 | if (id != 2) { | |
| 50 | if (verify->completion) | |
| 51 | verify->completion(FALSE, verify->context); | |
| 52 | } else { | |
| 53 | if (verify->completion) | |
| 54 | verify->completion(TRUE, verify->context); | |
| 55 | ||
| 56 | /* Save the key for future checking */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
57 | silc_pkcs_save_public_key(verify->filename, verify->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
58 | SILC_PKCS_FILE_BASE64); |
| 8849 | 59 | } |
| 60 | ||
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
61 | g_free(verify->filename); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
62 | g_free(verify->entity); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
63 | g_free(verify->entity_name); |
| 8849 | 64 | silc_free(verify->fingerprint); |
| 65 | silc_free(verify->babbleprint); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
66 | silc_pkcs_public_key_free(verify->public_key); |
| 8849 | 67 | silc_free(verify); |
| 68 | } | |
| 69 | ||
| 15884 | 70 | static void silcpurple_verify_details_cb(PublicKeyVerify verify) |
| 8849 | 71 | { |
| 72 | /* What a hack. We have to display the accept dialog _again_ | |
| 15884 | 73 | because Purple closes the dialog after you press the button. Purple |
| 8849 | 74 | should have option for the dialogs whether the buttons close them |
| 75 | or not. */ | |
| 15884 | 76 | silcpurple_verify_ask(verify->entity, verify->fingerprint, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
77 | verify->babbleprint, verify); |
| 8849 | 78 | } |
| 79 | ||
| 15884 | 80 | static void silcpurple_verify_details(PublicKeyVerify verify, gint id) |
| 8849 | 81 | { |
| 15884 | 82 | PurpleConnection *gc = verify->client->application; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
28981
diff
changeset
|
83 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 84 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
85 | silcpurple_show_public_key(sg, verify->entity_name, verify->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
86 | G_CALLBACK(silcpurple_verify_details_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
87 | verify); |
| 8849 | 88 | } |
| 89 | ||
| 15884 | 90 | static void silcpurple_verify_ask(const char *entity, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
91 | const char *fingerprint, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
92 | const char *babbleprint, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
93 | PublicKeyVerify verify) |
| 8849 | 94 | { |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
95 | PurpleConnection *gc = verify->client->application; |
| 8849 | 96 | char tmp[256], tmp2[256]; |
| 97 | ||
| 98 | if (verify->changed) { | |
| 99 | g_snprintf(tmp, sizeof(tmp), | |
| 100 | _("Received %s's public key. Your local copy does not match this " | |
| 101 | "key. Would you still like to accept this public key?"), | |
| 102 | entity); | |
| 103 | } else { | |
| 104 | g_snprintf(tmp, sizeof(tmp), | |
| 105 | _("Received %s's public key. Would you like to accept this " | |
| 106 | "public key?"), entity); | |
| 107 | } | |
| 108 | g_snprintf(tmp2, sizeof(tmp2), | |
| 109 | _("Fingerprint and babbleprint for the %s key are:\n\n" | |
| 110 | "%s\n%s\n"), entity, fingerprint, babbleprint); | |
| 111 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
112 | purple_request_action(gc, _("Verify Public Key"), tmp, tmp2, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
113 | PURPLE_DEFAULT_ACTION_NONE, |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
114 | purple_request_cpar_from_connection(gc), verify, 3, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
115 | _("Yes"), G_CALLBACK(silcpurple_verify_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
116 | _("No"), G_CALLBACK(silcpurple_verify_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
117 | _("_View..."), G_CALLBACK(silcpurple_verify_details)); |
| 8849 | 118 | } |
| 119 | ||
| 15884 | 120 | void silcpurple_verify_public_key(SilcClient client, SilcClientConnection conn, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
121 | const char *name, SilcConnectionType conn_type, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
122 | SilcPublicKey public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
123 | SilcVerifyPublicKey completion, void *context) |
| 8849 | 124 | { |
| 15884 | 125 | PurpleConnection *gc = client->application; |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28981
diff
changeset
|
126 | gsize i; |
| 8849 | 127 | char file[256], filename[256], filename2[256], *ipf, *hostf = NULL; |
| 128 | char *fingerprint, *babbleprint; | |
| 129 | struct passwd *pw; | |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32281
diff
changeset
|
130 | GStatBuf st; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
131 | char *entity = ((conn_type == SILC_CONN_SERVER || |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
132 | conn_type == SILC_CONN_ROUTER) ? |
| 8849 | 133 | "server" : "client"); |
| 134 | PublicKeyVerify verify; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
135 | const char *ip, *hostname; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
136 | SilcUInt16 port; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
137 | unsigned char *pk; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
138 | SilcUInt32 pk_len; |
| 8849 | 139 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
140 | if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) { |
| 15884 | 141 | purple_notify_error(gc, _("Verify Public Key"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
142 | _("Unsupported public key type"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
143 | purple_request_cpar_from_connection(gc)); |
| 8849 | 144 | if (completion) |
| 145 | completion(FALSE, context); | |
| 146 | return; | |
| 147 | } | |
| 148 | ||
| 149 | pw = getpwuid(getuid()); | |
| 150 | if (!pw) { | |
| 151 | if (completion) | |
| 152 | completion(FALSE, context); | |
| 153 | return; | |
| 154 | } | |
| 155 | ||
| 156 | memset(filename, 0, sizeof(filename)); | |
| 157 | memset(filename2, 0, sizeof(filename2)); | |
| 158 | memset(file, 0, sizeof(file)); | |
| 159 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
160 | silc_socket_stream_get_info(silc_packet_stream_get_stream(conn->stream), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
161 | NULL, &hostname, &ip, &port); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
162 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
163 | pk = silc_pkcs_public_key_encode(public_key, &pk_len); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
164 | if (!pk) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
165 | if (completion) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
166 | completion(FALSE, context); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
167 | return; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
168 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
169 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
170 | if (conn_type == SILC_CONN_SERVER || |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
171 | conn_type == SILC_CONN_ROUTER) { |
| 8849 | 172 | if (!name) { |
| 173 | g_snprintf(file, sizeof(file) - 1, "%skey_%s_%d.pub", entity, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
174 | ip, port); |
| 8849 | 175 | g_snprintf(filename, sizeof(filename) - 1, |
| 176 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 177 | silcpurple_silcdir(), entity, file); |
| 8849 | 178 | |
| 179 | g_snprintf(file, sizeof(file) - 1, "%skey_%s_%d.pub", entity, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
180 | hostname, port); |
| 8849 | 181 | g_snprintf(filename2, sizeof(filename2) - 1, |
| 182 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 183 | silcpurple_silcdir(), entity, file); |
| 8849 | 184 | |
| 185 | ipf = filename; | |
| 186 | hostf = filename2; | |
| 187 | } else { | |
| 188 | g_snprintf(file, sizeof(file) - 1, "%skey_%s_%d.pub", entity, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
189 | name, port); |
| 8849 | 190 | g_snprintf(filename, sizeof(filename) - 1, |
| 191 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 192 | silcpurple_silcdir(), entity, file); |
| 8849 | 193 | |
| 194 | ipf = filename; | |
| 195 | } | |
| 196 | } else { | |
| 197 | /* Replace all whitespaces with `_'. */ | |
| 198 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); | |
| 199 | for (i = 0; i < strlen(fingerprint); i++) | |
| 200 | if (fingerprint[i] == ' ') | |
| 201 | fingerprint[i] = '_'; | |
| 202 | ||
| 203 | g_snprintf(file, sizeof(file) - 1, "%skey_%s.pub", entity, fingerprint); | |
| 204 | g_snprintf(filename, sizeof(filename) - 1, | |
| 205 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 206 | silcpurple_silcdir(), entity, file); |
| 8849 | 207 | silc_free(fingerprint); |
| 208 | ||
| 209 | ipf = filename; | |
| 210 | } | |
| 211 | ||
| 212 | verify = silc_calloc(1, sizeof(*verify)); | |
| 213 | if (!verify) | |
| 214 | return; | |
| 215 | verify->client = client; | |
| 216 | verify->conn = conn; | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
217 | verify->filename = g_strdup(ipf); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
218 | verify->entity = g_strdup(entity); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
219 | verify->entity_name = (conn_type != SILC_CONN_CLIENT ? |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
220 | (name ? g_strdup(name) : g_strdup(hostname)) |
| 8849 | 221 | : NULL); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
222 | verify->public_key = silc_pkcs_public_key_copy(public_key); |
| 8849 | 223 | verify->completion = completion; |
| 224 | verify->context = context; | |
| 225 | fingerprint = verify->fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); | |
| 226 | babbleprint = verify->babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); | |
| 227 | ||
| 228 | /* Check whether this key already exists */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10116
diff
changeset
|
229 | if (g_stat(ipf, &st) < 0 && (!hostf || g_stat(hostf, &st) < 0)) { |
| 8849 | 230 | /* Key does not exist, ask user to verify the key and save it */ |
| 15884 | 231 | silcpurple_verify_ask(name ? name : entity, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
232 | fingerprint, babbleprint, verify); |
| 8849 | 233 | return; |
| 234 | } else { | |
| 235 | /* The key already exists, verify it. */ | |
| 236 | SilcPublicKey public_key; | |
| 237 | unsigned char *encpk; | |
| 238 | SilcUInt32 encpk_len; | |
| 239 | ||
| 240 | /* Load the key file, try for both IP filename and hostname filename */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
241 | if (!silc_pkcs_load_public_key(ipf, &public_key) && |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
242 | (!hostf || (!silc_pkcs_load_public_key(hostf, &public_key)))) { |
| 15884 | 243 | silcpurple_verify_ask(name ? name : entity, |
| 8849 | 244 | fingerprint, babbleprint, verify); |
| 245 | return; | |
| 246 | } | |
| 247 | ||
| 248 | /* Encode the key data */ | |
| 249 | encpk = silc_pkcs_public_key_encode(public_key, &encpk_len); | |
| 250 | if (!encpk) { | |
| 15884 | 251 | silcpurple_verify_ask(name ? name : entity, |
| 8849 | 252 | fingerprint, babbleprint, verify); |
| 253 | return; | |
| 254 | } | |
| 255 | ||
| 256 | /* Compare the keys */ | |
| 257 | if (memcmp(encpk, pk, encpk_len)) { | |
| 258 | /* Ask user to verify the key and save it */ | |
| 259 | verify->changed = TRUE; | |
| 15884 | 260 | silcpurple_verify_ask(name ? name : entity, |
| 8849 | 261 | fingerprint, babbleprint, verify); |
| 262 | return; | |
| 263 | } | |
| 264 | ||
| 265 | /* Local copy matched */ | |
| 266 | if (completion) | |
| 267 | completion(TRUE, context); | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
268 | g_free(verify->filename); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
269 | g_free(verify->entity); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
270 | g_free(verify->entity_name); |
| 8849 | 271 | silc_free(verify->fingerprint); |
| 272 | silc_free(verify->babbleprint); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
273 | silc_pkcs_public_key_free(verify->public_key); |
| 8849 | 274 | silc_free(verify); |
| 275 | } | |
| 276 | } |