Merge branch 'topic/mm-fixes' of git://208.110.73.182/silc into silc.1.1.branch
[silc.git] / lib / silcske / silcske_i.h
1 /*
2
3   silcske_i.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2005 - 2007 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; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef SILCSKE_I_H
21 #define SILCSKE_I_H
22
23 /* Packet retry counter and timer defines for UDP transport. */
24 #define SILC_SKE_RETRY_COUNT   4          /* Max packet retry count */
25 #define SILC_SKE_RETRY_MUL     2          /* Retry timer interval growth */
26 #define SILC_SKE_RETRY_RAND    2          /* Randomizer, timeout += rnd % 2 */
27 #define SILC_SKE_RETRY_MIN     1          /* Min retry timeout, seconds */
28
29 /* Length of cookie in Start Payload */
30 #define SILC_SKE_COOKIE_LEN 16
31
32 /* SKE context */
33 struct SilcSKEStruct {
34   SilcPacketStream stream;
35   SilcRng rng;
36   SilcSKR repository;
37   SilcSKECallbacks callbacks;
38   void *user_data;
39   SilcSKEStatus status;
40
41   /* Negotiated Security properties.  May be NULL in case of error. */
42   SilcSKESecurityProperties prop;
43
44   /* Key Exchange payloads filled during key negotiation with
45      remote data. Responder may save local data here as well. */
46   SilcSKEStartPayload start_payload;
47   SilcSKEKEPayload ke1_payload;
48   SilcSKEKEPayload ke2_payload;
49
50   /* Temporary copy of the KE Start Payload used in the
51      HASH computation. */
52   SilcBuffer start_payload_copy;
53
54   /* Random number x, 1 < x < q. This is the secret exponent
55      used in Diffie Hellman computations. */
56   SilcMPInt *x;
57
58   /* The secret shared key */
59   SilcMPInt *KEY;
60
61   /* The hash value HASH of the key exchange */
62   unsigned char *hash;
63   SilcUInt32 hash_len;
64
65   char *version;                      /* Local version */
66   char *remote_version;               /* Remote version */
67
68   SilcPublicKey public_key;
69   SilcPrivateKey private_key;
70   SilcSKEPKType pk_type;
71   SilcPacket packet;
72   SilcSKESecurityPropertyFlag flags;
73   SilcSKEKeyMaterial keymat;
74   SilcSKERekeyMaterial rekey;
75   SilcSchedule schedule;
76   SilcFSMStruct fsm;
77   SilcAsyncOperationStruct op;
78   SilcUInt16 session_port;
79
80   /* Packet retransmission */
81   SilcUInt16 retry_timer;
82   SilcUInt16 retry_count;
83   struct SilcSKEPacketRetransmission {
84     SilcPacketType type;
85     SilcPacketFlags flags;
86     unsigned char *data;
87     SilcUInt32 data_len;
88   } retrans;
89
90   SilcUInt16 timeout;                 /* SKE timeout */
91   SilcUInt16 refcnt;                  /* Reference counter */
92
93   unsigned int aborted    : 1;        /* Set when SKE aborted */
94   unsigned int freed      : 1;        /* Set when freed during session */
95   unsigned int responder  : 1;        /* Set when we are responder side */
96   unsigned int running    : 1;        /* Set when SKE is running */
97   unsigned int rekeying   : 1;        /* Set when rekeying */
98 };
99
100 #endif /* SILCSKE_I_H */