09e2aac3a4e4af5abde6279e68852eaac41355df
[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_MAX             255 */
30
31 /* Internal context for Key Exchange protocol. */
32 typedef struct {
33   void *server;
34   void *context;
35   SilcSocketConnection sock;
36   SilcRng rng;
37
38   /* TRUE if we are receiveing part of the protocol */
39   bool responder;
40
41   /* Destinations ID taken from authenticataed packet so that we can
42      get the destinations ID. */
43   void *dest_id;
44   SilcIdType dest_id_type;
45
46   /* Pointer to the configurations. */
47   void *cconfig;
48   void *sconfig;
49   void *rconfig;
50
51   SilcTask timeout_task;
52   SilcPacketContext *packet;
53   SilcSKE ske;
54   SilcSKEKeyMaterial *keymat;
55 } SilcServerKEInternalContext;
56
57 /* Internal context for connection authentication protocol */
58 typedef struct {
59   void *server;
60   void *context;
61   SilcSocketConnection sock;
62
63   /* TRUE if we are receiving part of the protocol */
64   bool responder;
65
66   /* SKE object from Key Exchange protocol. */
67   SilcSKE ske;
68
69   /* Auth method that must be used. This is resolved before this
70      connection authentication protocol is started. Used when we are
71      initiating. */
72   uint32 auth_meth;
73
74   /* Authentication data if we alreay know it. This is filled before
75      starting the protocol if we know the authentication data. Otherwise
76      these are and remain NULL. Used when we are initiating. */
77   void *auth_data;
78   uint32 auth_data_len;
79
80   /* Destinations ID from KE protocol context */
81   void *dest_id;
82   SilcIdType dest_id_type;
83
84   /* Pointer to the configurations. */
85   void *cconfig;
86   void *sconfig;
87   void *rconfig;
88
89   SilcTask timeout_task;
90   SilcPacketContext *packet;
91   uint16 conn_type;
92 } SilcServerConnAuthInternalContext;
93
94 /* Internal context for the rekey protocol */
95 typedef struct {
96   void *server;
97   void *context;
98   SilcSocketConnection sock;
99   bool responder;                   /* TRUE if we are receiving party */
100   bool pfs;                         /* TRUE if PFS is to be used */
101   SilcSKE ske;                      /* Defined if PFS is used */
102   SilcPacketContext *packet;
103 } SilcServerRekeyInternalContext;
104
105 /* Prototypes */
106 void silc_server_protocols_register(void);
107 void silc_server_protocols_unregister(void);
108 int silc_server_protocol_ke_set_keys(SilcSKE ske,
109                                      SilcSocketConnection sock,
110                                      SilcSKEKeyMaterial *keymat,
111                                      SilcCipher cipher,
112                                      SilcPKCS pkcs,
113                                      SilcHash hash,
114                                      SilcHmac hmac,
115                                      SilcSKEDiffieHellmanGroup group,
116                                      bool is_responder);
117
118 #endif