updates.
[silc.git] / apps / silcd / protocol.h
1 /*
2
3   protocol.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2001 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef PROTOCOL_H
22 #define PROTOCOL_H
23
24 /* SILC client protocol types */
25 #define SILC_PROTOCOL_SERVER_NONE               0
26 #define SILC_PROTOCOL_SERVER_CONNECTION_AUTH    1
27 #define SILC_PROTOCOL_SERVER_KEY_EXCHANGE       2
28 #define SILC_PROTOCOL_SERVER_REKEY              3
29 #define SILC_PROTOCOL_SERVER_BACKUP             4
30 /* #define SILC_PROTOCOL_SERVER_MAX             255 */
31
32 /* Internal context for Key Exchange protocol. */
33 typedef struct {
34   void *server;
35   void *context;
36   SilcSocketConnection sock;
37   SilcRng rng;
38
39   /* TRUE if we are receiveing part of the protocol */
40   bool responder;
41
42   /* Destinations ID taken from authenticataed packet so that we can
43      get the destinations ID. */
44   void *dest_id;
45   SilcIdType dest_id_type;
46
47   /* Pointer to the configurations. */
48   void *cconfig;
49   void *sconfig;
50   void *rconfig;
51
52   SilcTask timeout_task;
53   SilcPacketContext *packet;
54   SilcSKE ske;
55   SilcSKEKeyMaterial *keymat;
56 } SilcServerKEInternalContext;
57
58 /* Internal context for connection authentication protocol */
59 typedef struct {
60   void *server;
61   void *context;
62   SilcSocketConnection sock;
63
64   /* TRUE if we are receiving part of the protocol */
65   bool responder;
66
67   /* SKE object from Key Exchange protocol. */
68   SilcSKE ske;
69
70   /* Auth method that must be used. This is resolved before this
71      connection authentication protocol is started. Used when we are
72      initiating. */
73   uint32 auth_meth;
74
75   /* Authentication data if we alreay know it. This is filled before
76      starting the protocol if we know the authentication data. Otherwise
77      these are and remain NULL. Used when we are initiating. */
78   void *auth_data;
79   uint32 auth_data_len;
80
81   /* Destinations ID from KE protocol context */
82   void *dest_id;
83   SilcIdType dest_id_type;
84
85   /* Pointer to the configurations. */
86   void *cconfig;
87   void *sconfig;
88   void *rconfig;
89
90   SilcTask timeout_task;
91   SilcPacketContext *packet;
92   uint16 conn_type;
93 } SilcServerConnAuthInternalContext;
94
95 /* Internal context for the rekey protocol */
96 typedef struct {
97   void *server;
98   void *context;
99   SilcSocketConnection sock;
100   bool responder;                   /* TRUE if we are receiving party */
101   bool pfs;                         /* TRUE if PFS is to be used */
102   SilcSKE ske;                      /* Defined if PFS is used */
103   SilcPacketContext *packet;
104 } SilcServerRekeyInternalContext;
105
106 /* Prototypes */
107 void silc_server_protocols_register(void);
108 void silc_server_protocols_unregister(void);
109 int silc_server_protocol_ke_set_keys(SilcSKE ske,
110                                      SilcSocketConnection sock,
111                                      SilcSKEKeyMaterial *keymat,
112                                      SilcCipher cipher,
113                                      SilcPKCS pkcs,
114                                      SilcHash hash,
115                                      SilcHmac hmac,
116                                      SilcSKEDiffieHellmanGroup group,
117                                      bool is_responder);
118
119 #endif