1 |
/* wptKeyserver.h - Keyserver headerfile |
2 |
* Copyright (C) 2000-2006, 2008 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 |
|
17 |
#ifndef WPT_KEYSERVER_H |
18 |
#define WPT_KEYSERVER_H |
19 |
|
20 |
|
21 |
/* Default keyserver URL. */ |
22 |
#define DEF_HKP_KEYSERVER "hkp://subkeys.pgp.net" |
23 |
|
24 |
/* Horowitz Keyserver Protocol */ |
25 |
#define HKP_PORT 11371 |
26 |
|
27 |
/* Valid proxy protocols. */ |
28 |
enum proxy_proto_t { |
29 |
PROXY_PROTO_NONE = 0, |
30 |
PROXY_PROTO_HTTP |
31 |
}; |
32 |
|
33 |
/* Valid proxy authentications. */ |
34 |
enum proxy_auth_t { |
35 |
PROXY_AUTH_NONE = 0, |
36 |
PROXY_AUTH_PLAIN = 2 |
37 |
}; |
38 |
|
39 |
/* Valid key server protocols. */ |
40 |
enum ksproto_t { |
41 |
KSPROTO_HTTP = 0, |
42 |
}; |
43 |
#define KSPROTO_HKP 0 /* alias for http */ |
44 |
|
45 |
struct keyserver_ctx { |
46 |
const char *name; |
47 |
unsigned short port; |
48 |
const char *pattern; |
49 |
}; |
50 |
|
51 |
struct keyserver { |
52 |
char *name; /* name of the keyserver. */ |
53 |
int port; /* used tcp port. */ |
54 |
int used; /* 1=entry will be used. */ |
55 |
int is_default; |
56 |
}; |
57 |
|
58 |
/* Proxy configuration context. */ |
59 |
struct keyserver_proxy_s { |
60 |
int proto; /* protocol. */ |
61 |
int port; /* server port. */ |
62 |
char *host; /* server host. */ |
63 |
int auth_mode; /* authentication mode. */ |
64 |
char *user; /* user. */ |
65 |
char *base64_user; /* base64 encoded user. */ |
66 |
char *pass; /* password. */ |
67 |
}; |
68 |
typedef struct keyserver_proxy_s *keyserver_proxy_t; |
69 |
|
70 |
#define MAX_KEYSERVERS 8 |
71 |
extern keyserver server[MAX_KEYSERVERS]; /* runtime initialized */ |
72 |
extern char *default_keyserver; |
73 |
extern WORD default_keyserver_port; |
74 |
extern keyserver_proxy_s proxy; |
75 |
|
76 |
|
77 |
struct keyserver_uid_s { |
78 |
struct keyserver_uid_s *next; |
79 |
long creation; |
80 |
long expires; |
81 |
char *uid; |
82 |
}; |
83 |
|
84 |
struct keyserver_key_s { |
85 |
int algo; /* pubkey algorithm. */ |
86 |
int bits; /* length of the key. */ |
87 |
char *keyid; /* keyid of the key. */ |
88 |
long creation; /* creation date. */ |
89 |
long expires; |
90 |
struct keyserver_uid_s *uids; /* list ofuser-ids. */ |
91 |
const struct keyserver_uid_s *main_uid; |
92 |
}; |
93 |
|
94 |
/*-- Winsock2 support --*/ |
95 |
int wsock_init (void); |
96 |
void wsock_end (void); |
97 |
const char* wsock_strerror (void); |
98 |
|
99 |
/*-- Keyserver config --*/ |
100 |
int kserver_load_conf (void); |
101 |
const char* kserver_check_keyid (const char *keyid); |
102 |
void kserver_proxy_release (keyserver_proxy_t ctx); |
103 |
const char* kserver_get_hostname (int idx, int type, unsigned short *port); |
104 |
void keyserver_set_default (const char *hostname, unsigned short port); |
105 |
void kserver_set_socket_timeout (size_t nsec); |
106 |
|
107 |
/*-- General --*/ |
108 |
int check_inet_address (const char *addr); |
109 |
const char* kserver_strerror (void); |
110 |
int kserver_check_inet_connection (void); |
111 |
int kserver_connect (const char *hostname, WORD port, int *conn_fd); |
112 |
int kserver_sendkey (const char *hostname, WORD port, |
113 |
const char *pubkey, size_t len); |
114 |
int kserver_recvkey (const char *hostname, WORD port, |
115 |
const char *keyid, char **r_key, size_t *r_keylen); |
116 |
int kserver_search_begin (const char *hostname, WORD port, |
117 |
const char *pattern, int *conn_fd, size_t *nkeys); |
118 |
int kserver_search_next (int conn_fd, keyserver_key_s **r_key); |
119 |
void kserver_search_end (int conn_fd); |
120 |
void kserver_release_key (keyserver_key_s *key); |
121 |
|
122 |
/*-- Dialog support --*/ |
123 |
int hkp_send_key (HWND dlg, const char *kserver, unsigned short port, |
124 |
const char *pattern); |
125 |
int hkp_recv_key (HWND dlg, const char *kserver, unsigned short port, |
126 |
const char *pattern, int proto, int flags); |
127 |
int fetch_key_from_keyserver (HWND dlg, gpgme_signature_t sig); |
128 |
|
129 |
#endif /* WPT_KEYSERVER_H */ |