1 | /* Protocol-independent Key structures */ |
---|
2 | /* Copyright (C) 2001-2003 William Tompkins */ |
---|
3 | |
---|
4 | /* This plugin is free software, distributed under the GNU General Public */ |
---|
5 | /* License. */ |
---|
6 | /* Please see the file "COPYING" distributed with the Gaim source code */ |
---|
7 | /* for more details */ |
---|
8 | /* */ |
---|
9 | /* */ |
---|
10 | /* This software is distributed in the hope that it will be useful, */ |
---|
11 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
---|
12 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ |
---|
13 | /* General Public License for more details. */ |
---|
14 | |
---|
15 | /* To compile and use: */ |
---|
16 | /* See INSTALL file. */ |
---|
17 | |
---|
18 | #ifndef KEYS_H |
---|
19 | #define KEYS_H |
---|
20 | |
---|
21 | #include "cryptproto.h" |
---|
22 | |
---|
23 | #include "debug.h" |
---|
24 | #include "gaim.h" |
---|
25 | #include "conversation.h" |
---|
26 | |
---|
27 | |
---|
28 | #define KEY_DIGEST_LENGTH 10 |
---|
29 | #define KEY_FINGERPRINT_LENGTH 59 |
---|
30 | |
---|
31 | #define MAX_KEY_STORLEN 8000 /* The maximum length of a key stored in a file (in chars) */ |
---|
32 | |
---|
33 | struct crypt_key { |
---|
34 | crypt_proto* proto; |
---|
35 | proto_union store; /* Protocol dependent key data */ |
---|
36 | /* enum {Public, Private} type; */ |
---|
37 | char length[6]; /* string: Size of key (for ui display) */ |
---|
38 | char digest[KEY_DIGEST_LENGTH]; /* Top 10 hex digits of modulus */ |
---|
39 | char fingerprint[KEY_FINGERPRINT_LENGTH]; /* SHA-1 hash of modulus, as 12:34:56...*/ |
---|
40 | /* Why have both digest and fingerprint? Well a) historical b) practicality */ |
---|
41 | /* digest is insecure as a means of verifying that keys are actually the same */ |
---|
42 | /* fingerprint is too long to include with every message */ |
---|
43 | }; |
---|
44 | typedef struct crypt_key crypt_key; |
---|
45 | |
---|
46 | struct key_ring_data { |
---|
47 | char name[64]; |
---|
48 | GaimAccount* account; |
---|
49 | crypt_key* key; |
---|
50 | }; |
---|
51 | typedef struct key_ring_data key_ring_data; |
---|
52 | typedef GSList key_ring; |
---|
53 | |
---|
54 | /* List of all the keys we know about */ |
---|
55 | extern key_ring *GE_buddy_ring, *GE_saved_buddy_ring, *GE_my_priv_ring, *GE_my_pub_ring; |
---|
56 | static const char Private_key_file[] = "id.priv"; |
---|
57 | static const char Public_key_file[] = "id"; |
---|
58 | static const char Buddy_key_file[] = "known_keys"; |
---|
59 | |
---|
60 | /*The key routines: */ |
---|
61 | crypt_key * GE_find_key_by_name(key_ring *, const char *name, GaimAccount* acct); |
---|
62 | crypt_key * GE_find_own_key_by_name(key_ring **, char *name, GaimAccount *acct, GaimConversation *conv); |
---|
63 | void GE_debug_dump_keyring(key_ring *); |
---|
64 | key_ring * GE_find_key_node_by_name(key_ring *, const char *name, GaimAccount* acct); |
---|
65 | void GE_received_key(char *keystr, char *name, GaimAccount* acct, GaimConversation *conv, char** orig_msg); |
---|
66 | key_ring * GE_load_keys(const char *); |
---|
67 | void GE_save_keys(key_ring *, char *, char *); |
---|
68 | void GE_key_rings_init(void); |
---|
69 | key_ring* GE_add_key_to_ring(key_ring*, key_ring_data*); |
---|
70 | void GE_add_key_to_file(const char *filename, key_ring_data* key); |
---|
71 | key_ring* GE_del_key_from_ring(key_ring* ring, const char* name, GaimAccount* acct); |
---|
72 | void GE_del_key_from_file(const char *filename, const char *name, GaimAccount *acct); |
---|
73 | void GE_del_one_key_from_file(const char *filename, int key_num, const char *name); |
---|
74 | key_ring* GE_clear_ring(key_ring*); |
---|
75 | void GE_make_private_pair(crypt_proto* proto, const char* name, GaimAccount* acct, int keylength); |
---|
76 | |
---|
77 | #endif |
---|