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