source: trunk/third/gaim-encryption/keys.h @ 22512

Revision 22512, 3.6 KB checked in by ghudson, 18 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r22511, which included commits to RCS files with non-trunk default branches.
Line 
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
33struct 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};
44typedef struct crypt_key crypt_key;
45
46struct key_ring_data {
47   char name[64];
48   GaimAccount* account;
49   crypt_key* key;
50};
51typedef struct key_ring_data key_ring_data;
52typedef GSList key_ring;
53
54/* List of all the keys we know about */
55extern key_ring *GE_buddy_ring, *GE_saved_buddy_ring, *GE_my_priv_ring, *GE_my_pub_ring;
56static const char Private_key_file[] = "id.priv";
57static const char Public_key_file[] = "id";
58static const char Buddy_key_file[] = "known_keys";
59
60/*The key routines: */
61crypt_key * GE_find_key_by_name(key_ring *, const char *name, GaimAccount* acct);
62crypt_key * GE_find_own_key_by_name(key_ring **, char *name, GaimAccount *acct, GaimConversation *conv);
63void        GE_debug_dump_keyring(key_ring *);
64key_ring *  GE_find_key_node_by_name(key_ring *, const char *name, GaimAccount* acct);
65void        GE_received_key(char *keystr, char *name, GaimAccount* acct, GaimConversation *conv, char** orig_msg);
66key_ring *  GE_load_keys(const char *);
67void        GE_save_keys(key_ring *, char *, char *);
68void        GE_key_rings_init(void);
69key_ring*   GE_add_key_to_ring(key_ring*, key_ring_data*);
70void        GE_add_key_to_file(const char *filename, key_ring_data* key);
71key_ring*   GE_del_key_from_ring(key_ring* ring, const char* name, GaimAccount* acct);
72void        GE_del_key_from_file(const char *filename, const char *name, GaimAccount *acct);
73void        GE_del_one_key_from_file(const char *filename, int key_num, const char *name);
74key_ring*   GE_clear_ring(key_ring*);
75void        GE_make_private_pair(crypt_proto* proto, const char* name, GaimAccount* acct, int keylength);
76
77#endif
Note: See TracBrowser for help on using the repository browser.