1 |
werner |
37 |
/* wptKeyserver.h - Keyserver headerfile |
2 |
|
|
* Copyright (C) 2000-2005 Timo Schulz |
3 |
|
|
* |
4 |
|
|
* This file is part of WinPT. |
5 |
|
|
* |
6 |
|
|
* WinPT is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* WinPT is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
|
* General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef WPT_KEYSERVER_H |
22 |
|
|
#define WPT_KEYSERVER_H |
23 |
|
|
|
24 |
|
|
#define HKP_PORT 11371 /* Horowitz Keyserver Protocol */ |
25 |
|
|
#define FINGER_PORT 79 /* Finger Protocol */ |
26 |
|
|
|
27 |
|
|
/* Default keyserver URL. */ |
28 |
|
|
#define DEF_HKP_KEYSERVER "http://subkeys.pgp.net" |
29 |
|
|
|
30 |
|
|
enum proxy_t { |
31 |
twoaday |
115 |
PROXY_USER = 0, /* proxy username */ |
32 |
|
|
PROXY_PASS = 1, /* proxy password */ |
33 |
werner |
37 |
}; |
34 |
|
|
|
35 |
|
|
/* Valid key server protocols. */ |
36 |
|
|
enum ksproto_t { |
37 |
|
|
KSPROTO_HTTP = 0, |
38 |
|
|
KSPROTO_LDAP = 1, |
39 |
|
|
KSPROTO_FINGER = 2 |
40 |
|
|
}; |
41 |
|
|
#define KSPROTO_HKP 0 /* alias for http */ |
42 |
|
|
|
43 |
|
|
struct keyserver_ctx { |
44 |
|
|
const char *name; |
45 |
|
|
unsigned short port; |
46 |
|
|
const char *pattern; |
47 |
|
|
}; |
48 |
|
|
|
49 |
|
|
struct keyserver { |
50 |
|
|
char *name; /* name of the keyserver. */ |
51 |
|
|
int port; /* used tcp port. */ |
52 |
|
|
int used; /* 1=entry will be used. */ |
53 |
|
|
int proto; /* protocol (0..2). */ |
54 |
|
|
}; |
55 |
|
|
|
56 |
|
|
struct keyserver_proxy_ctx { |
57 |
|
|
int port; /* proxy server port. */ |
58 |
|
|
char *host; /* proxy server host. */ |
59 |
|
|
char *user; /* proxy user. */ |
60 |
|
|
char *base64_user; /* base64 encoded proxy user. */ |
61 |
|
|
char *pass; /* proxy password. */ |
62 |
|
|
}; |
63 |
|
|
|
64 |
|
|
struct keyserver_node { |
65 |
|
|
keyserver_node * next; |
66 |
|
|
keyserver host; |
67 |
|
|
int used; |
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
struct keyserver_cfgfile { |
71 |
|
|
keyserver_node * list; |
72 |
|
|
keyserver_proxy_ctx proxy; |
73 |
|
|
int nlist; |
74 |
|
|
}; |
75 |
|
|
|
76 |
|
|
#define MAX_KEYSERVERS 32 |
77 |
|
|
extern keyserver server[MAX_KEYSERVERS]; /* runtime initialized */ |
78 |
twoaday |
115 |
extern char *default_keyserver; |
79 |
werner |
37 |
extern unsigned short default_keyserver_port; |
80 |
|
|
|
81 |
|
|
struct keyserver_key { |
82 |
|
|
int bits; /* length of the key. */ |
83 |
|
|
char keyid[8+1]; /* keyid of the key. */ |
84 |
|
|
char date[10+1]; /* date of creation. */ |
85 |
|
|
char uid[384]; /* primary user-id. */ |
86 |
|
|
}; |
87 |
|
|
|
88 |
|
|
const char* kserver_strerror (void); |
89 |
|
|
|
90 |
|
|
/*-- Winsock2 support --*/ |
91 |
|
|
int wsock_init (void); |
92 |
|
|
void wsock_end (void); |
93 |
|
|
const char* wsock_strerror (void); |
94 |
|
|
|
95 |
|
|
/*-- Keyserver config --*/ |
96 |
|
|
int kserver_load_conf (const char *conf); |
97 |
|
|
const char* kserver_check_keyid (const char *keyid); |
98 |
|
|
const char* kserver_get_proxy (int *r_port); |
99 |
|
|
const char* kserver_get_proxy_info (int id); |
100 |
|
|
|
101 |
|
|
int kserver_read_config( const char *fname, keyserver_cfgfile **ret_cfg ); |
102 |
|
|
int kserver_write_config( const char *fname, keyserver_cfgfile *cfg ); |
103 |
|
|
void kserver_cfgfile_release( keyserver_cfgfile *cfg ); |
104 |
|
|
void kserver_change_proxy( keyserver_proxy_ctx *ctx ); |
105 |
|
|
void proxy_release( keyserver_proxy_ctx *ctx ); |
106 |
|
|
const char * kserver_get_hostname (int idx, int type, unsigned short *port); |
107 |
|
|
void keyserver_set_default (const char *hostname, unsigned short port); |
108 |
|
|
void set_default_kserver (void); |
109 |
|
|
|
110 |
|
|
/*-- General --*/ |
111 |
|
|
int check_IP_or_hostname (const char *name); |
112 |
|
|
int kserver_check_inet_connection (void); |
113 |
|
|
int kserver_connect (const char *hostname, unsigned short port, int *conn_fd); |
114 |
twoaday |
115 |
int kserver_sendkey (const char *hostname, unsigned short port, |
115 |
|
|
const char *pubkey, int len); |
116 |
werner |
37 |
int kserver_recvkey (const char *hostname, unsigned short port, |
117 |
|
|
const char *keyid, char *key, int maxkeylen); |
118 |
|
|
|
119 |
twoaday |
115 |
int kserver_search_init(const char *hostname, unsigned short port, |
120 |
|
|
const char *keyid, int *conn_fd); |
121 |
werner |
37 |
int kserver_search_chkresp (int conn_fd); |
122 |
|
|
int kserver_search (int conn_fd, keyserver_key *key); |
123 |
|
|
|
124 |
|
|
/*-- Finger/LDAP Protocol --*/ |
125 |
|
|
int ldap_recvkey (const char *hostname, const char *keyid, char *key, |
126 |
|
|
int maxkeylen); |
127 |
|
|
int finger_recvkey (const char * host, const char * user, char * key, |
128 |
|
|
int maxkeylen); |
129 |
|
|
|
130 |
|
|
/*-- Dialog support --*/ |
131 |
twoaday |
115 |
int hkp_send_key (HWND dlg, const char *kserver, unsigned short port, |
132 |
|
|
const char *pattern); |
133 |
|
|
int hkp_recv_key (HWND dlg, const char *kserver, unsigned short port, |
134 |
|
|
const char *pattern, int proto, int flags); |
135 |
|
|
int hkp_recv_key2 (HWND dlg, const char *kserver, WORD port, |
136 |
|
|
const char *pattern, int proto, int flags, |
137 |
|
|
char **r_fpr); |
138 |
werner |
37 |
|
139 |
twoaday |
115 |
#endif /* WPT_KEYSERVER_H */ |