/[winpt]/trunk/Include/wptKeyserver.h
ViewVC logotype

Diff of /trunk/Include/wptKeyserver.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.25  
changed lines
  Added in v.214

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26