Wed, 21 Aug 2013 14:59:29 +0200
Fix most of libpurple warnings about -Wsign-compare
| 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 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
22972
diff
changeset
|
20 | #include "internal.h" |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
21 | #include "silc.h" |
| 8849 | 22 | #include "silcclient.h" |
| 15884 | 23 | #include "silcpurple.h" |
| 8849 | 24 | |
| 25 | /************************* Public Key Verification ***************************/ | |
| 26 | ||
| 27 | typedef struct { | |
| 28 | SilcClient client; | |
| 29 | SilcClientConnection conn; | |
| 30 | char *filename; | |
| 31 | char *entity; | |
| 32 | char *entity_name; | |
| 33 | char *fingerprint; | |
| 34 | 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
|
35 | SilcPublicKey public_key; |
| 8849 | 36 | SilcVerifyPublicKey completion; |
| 37 | void *context; | |
| 38 | gboolean changed; | |
| 39 | } *PublicKeyVerify; | |
| 40 | ||
| 15884 | 41 | 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
|
42 | 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
|
43 | 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
|
44 | PublicKeyVerify verify); |
| 8849 | 45 | |
| 15884 | 46 | static void silcpurple_verify_cb(PublicKeyVerify verify, gint id) |
| 8849 | 47 | { |
| 48 | if (id != 2) { | |
| 49 | if (verify->completion) | |
| 50 | verify->completion(FALSE, verify->context); | |
| 51 | } else { | |
| 52 | if (verify->completion) | |
| 53 | verify->completion(TRUE, verify->context); | |
| 54 | ||
| 55 | /* 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
|
56 | 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
|
57 | SILC_PKCS_FILE_BASE64); |
| 8849 | 58 | } |
| 59 | ||
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
60 | g_free(verify->filename); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
61 | g_free(verify->entity); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
62 | g_free(verify->entity_name); |
| 8849 | 63 | silc_free(verify->fingerprint); |
| 64 | 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
|
65 | silc_pkcs_public_key_free(verify->public_key); |
| 8849 | 66 | silc_free(verify); |
| 67 | } | |
| 68 | ||
| 15884 | 69 | static void silcpurple_verify_details_cb(PublicKeyVerify verify) |
| 8849 | 70 | { |
| 71 | /* What a hack. We have to display the accept dialog _again_ | |
| 15884 | 72 | because Purple closes the dialog after you press the button. Purple |
| 8849 | 73 | should have option for the dialogs whether the buttons close them |
| 74 | or not. */ | |
| 15884 | 75 | 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
|
76 | verify->babbleprint, verify); |
| 8849 | 77 | } |
| 78 | ||
| 15884 | 79 | static void silcpurple_verify_details(PublicKeyVerify verify, gint id) |
| 8849 | 80 | { |
| 15884 | 81 | 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
|
82 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 83 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
84 | 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
|
85 | 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
|
86 | verify); |
| 8849 | 87 | } |
| 88 | ||
| 15884 | 89 | 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
|
90 | 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
|
91 | 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
|
92 | PublicKeyVerify verify) |
| 8849 | 93 | { |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
94 | PurpleConnection *gc = verify->client->application; |
| 8849 | 95 | char tmp[256], tmp2[256]; |
| 96 | ||
| 97 | if (verify->changed) { | |
| 98 | g_snprintf(tmp, sizeof(tmp), | |
| 99 | _("Received %s's public key. Your local copy does not match this " | |
| 100 | "key. Would you still like to accept this public key?"), | |
| 101 | entity); | |
| 102 | } else { | |
| 103 | g_snprintf(tmp, sizeof(tmp), | |
| 104 | _("Received %s's public key. Would you like to accept this " | |
| 105 | "public key?"), entity); | |
| 106 | } | |
| 107 | g_snprintf(tmp2, sizeof(tmp2), | |
| 108 | _("Fingerprint and babbleprint for the %s key are:\n\n" | |
| 109 | "%s\n%s\n"), entity, fingerprint, babbleprint); | |
| 110 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
111 | 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
|
112 | PURPLE_DEFAULT_ACTION_NONE, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
113 | purple_connection_get_account(gc), entity, NULL, 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
|
114 | _("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
|
115 | _("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
|
116 | _("_View..."), G_CALLBACK(silcpurple_verify_details)); |
| 8849 | 117 | } |
| 118 | ||
| 15884 | 119 | 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
|
120 | 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
|
121 | 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
|
122 | SilcVerifyPublicKey completion, void *context) |
| 8849 | 123 | { |
| 15884 | 124 | PurpleConnection *gc = client->application; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
125 | gsize i; |
| 8849 | 126 | char file[256], filename[256], filename2[256], *ipf, *hostf = NULL; |
| 127 | char *fingerprint, *babbleprint; | |
| 128 | struct passwd *pw; | |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32281
diff
changeset
|
129 | 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
|
130 | 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
|
131 | conn_type == SILC_CONN_ROUTER) ? |
| 8849 | 132 | "server" : "client"); |
| 133 | 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
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | SilcUInt32 pk_len; |
| 8849 | 138 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
139 | if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) { |
| 15884 | 140 | purple_notify_error(gc, _("Verify Public Key"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
141 | _("Unsupported public key type"), NULL); |
| 8849 | 142 | if (completion) |
| 143 | completion(FALSE, context); | |
| 144 | return; | |
| 145 | } | |
| 146 | ||
| 147 | pw = getpwuid(getuid()); | |
| 148 | if (!pw) { | |
| 149 | if (completion) | |
| 150 | completion(FALSE, context); | |
| 151 | return; | |
| 152 | } | |
| 153 | ||
| 154 | memset(filename, 0, sizeof(filename)); | |
| 155 | memset(filename2, 0, sizeof(filename2)); | |
| 156 | memset(file, 0, sizeof(file)); | |
| 157 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
158 | 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
|
159 | 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
|
160 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
161 | 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
|
162 | if (!pk) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
163 | if (completion) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
164 | completion(FALSE, context); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
165 | return; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17675
diff
changeset
|
166 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
167 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
168 | 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
|
169 | conn_type == SILC_CONN_ROUTER) { |
| 8849 | 170 | if (!name) { |
| 171 | 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
|
172 | ip, port); |
| 8849 | 173 | g_snprintf(filename, sizeof(filename) - 1, |
| 174 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 175 | silcpurple_silcdir(), entity, file); |
| 8849 | 176 | |
| 177 | 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
|
178 | hostname, port); |
| 8849 | 179 | g_snprintf(filename2, sizeof(filename2) - 1, |
| 180 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 181 | silcpurple_silcdir(), entity, file); |
| 8849 | 182 | |
| 183 | ipf = filename; | |
| 184 | hostf = filename2; | |
| 185 | } else { | |
| 186 | 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
|
187 | name, port); |
| 8849 | 188 | g_snprintf(filename, sizeof(filename) - 1, |
| 189 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 190 | silcpurple_silcdir(), entity, file); |
| 8849 | 191 | |
| 192 | ipf = filename; | |
| 193 | } | |
| 194 | } else { | |
| 195 | /* Replace all whitespaces with `_'. */ | |
| 196 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); | |
| 197 | for (i = 0; i < strlen(fingerprint); i++) | |
| 198 | if (fingerprint[i] == ' ') | |
| 199 | fingerprint[i] = '_'; | |
| 200 | ||
| 201 | g_snprintf(file, sizeof(file) - 1, "%skey_%s.pub", entity, fingerprint); | |
| 202 | g_snprintf(filename, sizeof(filename) - 1, | |
| 203 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 204 | silcpurple_silcdir(), entity, file); |
| 8849 | 205 | silc_free(fingerprint); |
| 206 | ||
| 207 | ipf = filename; | |
| 208 | } | |
| 209 | ||
| 210 | verify = silc_calloc(1, sizeof(*verify)); | |
| 211 | if (!verify) | |
| 212 | return; | |
| 213 | verify->client = client; | |
| 214 | verify->conn = conn; | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
215 | verify->filename = g_strdup(ipf); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
216 | 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
|
217 | 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
|
218 | (name ? g_strdup(name) : g_strdup(hostname)) |
| 8849 | 219 | : 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
|
220 | verify->public_key = silc_pkcs_public_key_copy(public_key); |
| 8849 | 221 | verify->completion = completion; |
| 222 | verify->context = context; | |
| 223 | fingerprint = verify->fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); | |
| 224 | babbleprint = verify->babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); | |
| 225 | ||
| 226 | /* Check whether this key already exists */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10116
diff
changeset
|
227 | if (g_stat(ipf, &st) < 0 && (!hostf || g_stat(hostf, &st) < 0)) { |
| 8849 | 228 | /* Key does not exist, ask user to verify the key and save it */ |
| 15884 | 229 | 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
|
230 | fingerprint, babbleprint, verify); |
| 8849 | 231 | return; |
| 232 | } else { | |
| 233 | /* The key already exists, verify it. */ | |
| 234 | SilcPublicKey public_key; | |
| 235 | unsigned char *encpk; | |
| 236 | SilcUInt32 encpk_len; | |
| 237 | ||
| 238 | /* 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
|
239 | 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
|
240 | (!hostf || (!silc_pkcs_load_public_key(hostf, &public_key)))) { |
| 15884 | 241 | silcpurple_verify_ask(name ? name : entity, |
| 8849 | 242 | fingerprint, babbleprint, verify); |
| 243 | return; | |
| 244 | } | |
| 245 | ||
| 246 | /* Encode the key data */ | |
| 247 | encpk = silc_pkcs_public_key_encode(public_key, &encpk_len); | |
| 248 | if (!encpk) { | |
| 15884 | 249 | silcpurple_verify_ask(name ? name : entity, |
| 8849 | 250 | fingerprint, babbleprint, verify); |
| 251 | return; | |
| 252 | } | |
| 253 | ||
| 254 | /* Compare the keys */ | |
| 255 | if (memcmp(encpk, pk, encpk_len)) { | |
| 256 | /* Ask user to verify the key and save it */ | |
| 257 | verify->changed = TRUE; | |
| 15884 | 258 | silcpurple_verify_ask(name ? name : entity, |
| 8849 | 259 | fingerprint, babbleprint, verify); |
| 260 | return; | |
| 261 | } | |
| 262 | ||
| 263 | /* Local copy matched */ | |
| 264 | if (completion) | |
| 265 | completion(TRUE, context); | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
266 | g_free(verify->filename); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
267 | g_free(verify->entity); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
268 | g_free(verify->entity_name); |
| 8849 | 269 | silc_free(verify->fingerprint); |
| 270 | 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
|
271 | silc_pkcs_public_key_free(verify->public_key); |
| 8849 | 272 | silc_free(verify); |
| 273 | } | |
| 274 | } |