updates.
[silc.git] / lib / silcclient / protocol.h
1 /*
2
3   protocol.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 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_CLIENT_NONE               0
26 #define SILC_PROTOCOL_CLIENT_CONNECTION_AUTH    1
27 #define SILC_PROTOCOL_CLIENT_KEY_EXCHANGE       2
28 /* #define SILC_PROTOCOL_CLIENT_MAX             255 */
29
30 /* Internal context for key exchange protocol */
31 typedef struct {
32   void *client;
33   SilcSocketConnection sock;
34   SilcRng rng;
35   int responder;
36
37   void *dest_id;                    /* Destination ID from packet */
38   SilcIdType dest_id_type;          /* Destination ID type */
39
40   SilcTask timeout_task;
41   SilcPacketContext *packet;
42
43   SilcSKESendPacketCb send_packet;  /* SKE's packet sending callback */
44   SilcSKEVerifyCb verify;           /* SKE's key verify callback */
45   SilcSKE ske;                      /* The SKE object */
46   SilcSKEKeyMaterial *keymat;       /* The negotiated key material */
47   void *context;                    /* Internal context */
48 } SilcClientKEInternalContext;
49
50 /* Internal context for connection authentication protocol */
51 typedef struct {
52   void *client;
53   SilcSocketConnection sock;
54
55   /* SKE object from Key Exchange protocol. */
56   SilcSKE ske;
57
58   /* Auth method that must be used. This is resolved before this
59      connection authentication protocol is started. */
60   SilcProtocolAuthMeth auth_meth;
61
62   /* Destinations ID from KE protocol context */
63   void *dest_id;
64   SilcIdType dest_id_type;
65
66   /* Authentication data if we alreay know it. This is filled before
67      starting the protocol if we know the authentication data. Otherwise
68      these are and remain NULL. */
69   unsigned char *auth_data;
70   unsigned int auth_data_len;
71
72   SilcTask timeout_task;
73 } SilcClientConnAuthInternalContext;
74
75 /* Prototypes */
76 void silc_client_protocols_register(void);
77 void silc_client_protocols_unregister(void);
78 void silc_client_protocol_ke_send_packet(SilcSKE ske,
79                                          SilcBuffer packet,
80                                          SilcPacketType type,
81                                          void *context);
82 SilcSKEStatus silc_client_protocol_ke_verify_key(SilcSKE ske,
83                                                  unsigned char *pk_data,
84                                                  unsigned int pk_len,
85                                                  SilcSKEPKType pk_type,
86                                                  void *context);
87 void silc_client_protocol_ke_set_keys(SilcSKE ske,
88                                       SilcSocketConnection sock,
89                                       SilcSKEKeyMaterial *keymat,
90                                       SilcCipher cipher,
91                                       SilcPKCS pkcs,
92                                       SilcHash hash,
93                                       SilcHmac hmac);
94
95 #endif