Sat, 09 Jun 2007 16:39:00 +0000
Duplicate the current SILC prpl as silc10 for backwards compatibility with
SILC Toolkit 1.0
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
2 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
3 | silcpurple_pk.c |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
4 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
5 | Author: Pekka Riikonen <priikone@silcnet.org> |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
6 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
7 | Copyright (C) 2004 Pekka Riikonen |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
8 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
9 | This program is free software; you can redistribute it and/or modify |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
10 | it under the terms of the GNU General Public License as published by |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
11 | the Free Software Foundation; version 2 of the License. |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
12 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
13 | This program is distributed in the hope that it will be useful, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
16 | GNU General Public License for more details. |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
17 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
18 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
19 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
20 | #include "silcincludes.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
21 | #include "silcclient.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
22 | #include "silcpurple.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
23 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
24 | /************************* Public Key Verification ***************************/ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
25 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
26 | typedef struct { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
27 | SilcClient client; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
28 | SilcClientConnection conn; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
29 | char *filename; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
30 | char *entity; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
31 | char *entity_name; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
32 | char *fingerprint; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
33 | char *babbleprint; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
34 | unsigned char *pk; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
35 | SilcUInt32 pk_len; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
36 | SilcSKEPKType pk_type; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
37 | SilcVerifyPublicKey completion; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
38 | void *context; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
39 | gboolean changed; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
40 | } *PublicKeyVerify; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
41 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
42 | static void silcpurple_verify_ask(const char *entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
43 | const char *fingerprint, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
44 | const char *babbleprint, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
45 | PublicKeyVerify verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
46 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
47 | static void silcpurple_verify_cb(PublicKeyVerify verify, gint id) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
48 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
49 | if (id != 2) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
50 | if (verify->completion) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
51 | verify->completion(FALSE, verify->context); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
52 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
53 | if (verify->completion) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
54 | verify->completion(TRUE, verify->context); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
55 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
56 | /* Save the key for future checking */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
57 | silc_pkcs_save_public_key_data(verify->filename, verify->pk, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
58 | verify->pk_len, SILC_PKCS_FILE_PEM); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
59 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
60 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
61 | silc_free(verify->filename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
62 | silc_free(verify->entity); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
63 | silc_free(verify->entity_name); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
64 | silc_free(verify->fingerprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
65 | silc_free(verify->babbleprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
66 | silc_free(verify->pk); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
67 | silc_free(verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
68 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
69 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
70 | static void silcpurple_verify_details_cb(PublicKeyVerify verify) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
71 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
72 | /* What a hack. We have to display the accept dialog _again_ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
73 | because Purple closes the dialog after you press the button. Purple |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
74 | should have option for the dialogs whether the buttons close them |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
75 | or not. */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
76 | silcpurple_verify_ask(verify->entity, verify->fingerprint, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
77 | verify->babbleprint, verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
78 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
79 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
80 | static void silcpurple_verify_details(PublicKeyVerify verify, gint id) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
81 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
82 | SilcPublicKey public_key; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
83 | PurpleConnection *gc = verify->client->application; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
84 | SilcPurple sg = gc->proto_data; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
85 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
86 | silc_pkcs_public_key_decode(verify->pk, verify->pk_len, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
87 | &public_key); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
88 | silcpurple_show_public_key(sg, verify->entity_name, public_key, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
89 | G_CALLBACK(silcpurple_verify_details_cb), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
90 | verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
91 | silc_pkcs_public_key_free(public_key); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
92 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
93 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
94 | static void silcpurple_verify_ask(const char *entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
95 | const char *fingerprint, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
96 | const char *babbleprint, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
97 | PublicKeyVerify verify) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
98 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
99 | PurpleConnection *gc = verify->client->application; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
100 | char tmp[256], tmp2[256]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
101 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
102 | if (verify->changed) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
103 | g_snprintf(tmp, sizeof(tmp), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
104 | _("Received %s's public key. Your local copy does not match this " |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
105 | "key. Would you still like to accept this public key?"), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
106 | entity); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
107 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
108 | g_snprintf(tmp, sizeof(tmp), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
109 | _("Received %s's public key. Would you like to accept this " |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
110 | "public key?"), entity); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
111 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
112 | g_snprintf(tmp2, sizeof(tmp2), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
113 | _("Fingerprint and babbleprint for the %s key are:\n\n" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
114 | "%s\n%s\n"), entity, fingerprint, babbleprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
115 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
116 | purple_request_action(gc, _("Verify Public Key"), tmp, tmp2, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
117 | PURPLE_DEFAULT_ACTION_NONE, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
118 | purple_connection_get_account(gc), entity, NULL, verify, 3, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
119 | _("Yes"), G_CALLBACK(silcpurple_verify_cb), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
120 | _("No"), G_CALLBACK(silcpurple_verify_cb), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
121 | _("_View..."), G_CALLBACK(silcpurple_verify_details)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
122 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
123 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
124 | void silcpurple_verify_public_key(SilcClient client, SilcClientConnection conn, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
125 | const char *name, SilcSocketType conn_type, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
126 | unsigned char *pk, SilcUInt32 pk_len, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
127 | SilcSKEPKType pk_type, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
128 | SilcVerifyPublicKey completion, void *context) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
129 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
130 | PurpleConnection *gc = client->application; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
131 | int i; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
132 | char file[256], filename[256], filename2[256], *ipf, *hostf = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
133 | char *fingerprint, *babbleprint; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
134 | struct passwd *pw; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
135 | struct stat st; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
136 | char *entity = ((conn_type == SILC_SOCKET_TYPE_SERVER || |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
137 | conn_type == SILC_SOCKET_TYPE_ROUTER) ? |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
138 | "server" : "client"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
139 | PublicKeyVerify verify; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
140 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
141 | if (pk_type != SILC_SKE_PK_TYPE_SILC) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
142 | purple_notify_error(gc, _("Verify Public Key"), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
143 | _("Unsupported public key type"), NULL); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
144 | if (completion) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
145 | completion(FALSE, context); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
146 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
147 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
148 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
149 | pw = getpwuid(getuid()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
150 | if (!pw) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
151 | if (completion) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
152 | completion(FALSE, context); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
153 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
154 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
155 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
156 | memset(filename, 0, sizeof(filename)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
157 | memset(filename2, 0, sizeof(filename2)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
158 | memset(file, 0, sizeof(file)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
159 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
160 | if (conn_type == SILC_SOCKET_TYPE_SERVER || |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
161 | conn_type == SILC_SOCKET_TYPE_ROUTER) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
162 | if (!name) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
163 | g_snprintf(file, sizeof(file) - 1, "%skey_%s_%d.pub", entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
164 | conn->sock->ip, conn->sock->port); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
165 | g_snprintf(filename, sizeof(filename) - 1, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
166 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
167 | silcpurple_silcdir(), entity, file); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
168 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
169 | g_snprintf(file, sizeof(file) - 1, "%skey_%s_%d.pub", entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
170 | conn->sock->hostname, conn->sock->port); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
171 | g_snprintf(filename2, sizeof(filename2) - 1, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
172 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
173 | silcpurple_silcdir(), entity, file); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
174 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
175 | ipf = filename; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
176 | hostf = filename2; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
177 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
178 | g_snprintf(file, sizeof(file) - 1, "%skey_%s_%d.pub", entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
179 | name, conn->sock->port); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
180 | g_snprintf(filename, sizeof(filename) - 1, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
181 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
182 | silcpurple_silcdir(), entity, file); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
183 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
184 | ipf = filename; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
185 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
186 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
187 | /* Replace all whitespaces with `_'. */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
188 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
189 | for (i = 0; i < strlen(fingerprint); i++) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
190 | if (fingerprint[i] == ' ') |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
191 | fingerprint[i] = '_'; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
192 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
193 | g_snprintf(file, sizeof(file) - 1, "%skey_%s.pub", entity, fingerprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
194 | g_snprintf(filename, sizeof(filename) - 1, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
195 | "%s" G_DIR_SEPARATOR_S "%skeys" G_DIR_SEPARATOR_S "%s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
196 | silcpurple_silcdir(), entity, file); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
197 | silc_free(fingerprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
198 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
199 | ipf = filename; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
200 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
201 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
202 | verify = silc_calloc(1, sizeof(*verify)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
203 | if (!verify) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
204 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
205 | verify->client = client; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
206 | verify->conn = conn; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
207 | verify->filename = strdup(ipf); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
208 | verify->entity = strdup(entity); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
209 | verify->entity_name = (conn_type != SILC_SOCKET_TYPE_CLIENT ? |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
210 | (name ? strdup(name) : strdup(conn->sock->hostname)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
211 | : NULL); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
212 | verify->pk = silc_memdup(pk, pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
213 | verify->pk_len = pk_len; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
214 | verify->pk_type = pk_type; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
215 | verify->completion = completion; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
216 | verify->context = context; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
217 | fingerprint = verify->fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
218 | babbleprint = verify->babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
219 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
220 | /* Check whether this key already exists */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
221 | if (g_stat(ipf, &st) < 0 && (!hostf || g_stat(hostf, &st) < 0)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
222 | /* Key does not exist, ask user to verify the key and save it */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
223 | silcpurple_verify_ask(name ? name : entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
224 | fingerprint, babbleprint, verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
225 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
226 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
227 | /* The key already exists, verify it. */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
228 | SilcPublicKey public_key; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
229 | unsigned char *encpk; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
230 | SilcUInt32 encpk_len; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
231 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
232 | /* Load the key file, try for both IP filename and hostname filename */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
233 | if (!silc_pkcs_load_public_key(ipf, &public_key, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
234 | SILC_PKCS_FILE_PEM) && |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
235 | !silc_pkcs_load_public_key(ipf, &public_key, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
236 | SILC_PKCS_FILE_BIN) && |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
237 | (!hostf || (!silc_pkcs_load_public_key(hostf, &public_key, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
238 | SILC_PKCS_FILE_PEM) && |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
239 | !silc_pkcs_load_public_key(hostf, &public_key, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
240 | SILC_PKCS_FILE_BIN)))) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
241 | silcpurple_verify_ask(name ? name : entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
242 | fingerprint, babbleprint, verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
243 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
244 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
245 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
246 | /* Encode the key data */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
247 | encpk = silc_pkcs_public_key_encode(public_key, &encpk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
248 | if (!encpk) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
249 | silcpurple_verify_ask(name ? name : entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
250 | fingerprint, babbleprint, verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
251 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
252 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
253 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
254 | /* Compare the keys */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
255 | if (memcmp(encpk, pk, encpk_len)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
256 | /* Ask user to verify the key and save it */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
257 | verify->changed = TRUE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
258 | silcpurple_verify_ask(name ? name : entity, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
259 | fingerprint, babbleprint, verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
260 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
261 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
262 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
263 | /* Local copy matched */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
264 | if (completion) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
265 | completion(TRUE, context); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
266 | silc_free(verify->filename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
267 | silc_free(verify->entity); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
268 | silc_free(verify->entity_name); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
269 | silc_free(verify->pk); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
270 | silc_free(verify->fingerprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
271 | silc_free(verify->babbleprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
272 | silc_free(verify); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
273 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
274 | } |