updates.
[silc.git] / lib / silcske / silcske.h
index a5fead29e283f52f93daf6d6a321ea29d9bd42bf..880475e028f2183eed0fc4cbd835f576c2435d84 100644 (file)
@@ -31,13 +31,12 @@ typedef struct SilcSKESecurityPropertiesStruct *SilcSKESecurityProperties;
 
 /* Supported Public Key Types, defined by the protocol */
 typedef enum {
-  SILC_SKE_PK_TYPE_SILC = 1,   /* Mandatory type */
-  /* Optional types. These are not implemented currently
-  SILC_SKE_PK_TYPE_SSH2 = 2,
-  SILC_SKE_PK_TYPE_X509V3 = 3,
+  SILC_SKE_PK_TYPE_SILC    = 1,        /* Mandatory type */
+  /* Optional types. These are not implemented currently */
+  SILC_SKE_PK_TYPE_SSH2    = 2,
+  SILC_SKE_PK_TYPE_X509V3  = 3,
   SILC_SKE_PK_TYPE_OPENPGP = 4,
-  SILC_SKE_PK_TYPE_SPKI = 5
-  */
+  SILC_SKE_PK_TYPE_SPKI    = 5
 } SilcSKEPKType;
 
 /* Packet sending callback. Caller of the SKE routines must provide
@@ -70,6 +69,7 @@ typedef struct {
   unsigned int hmac_key_len;
 } SilcSKEKeyMaterial;
 
+/* Length of cookie in Start Payload */
 #define SILC_SKE_COOKIE_LEN 16
 
 #include "groups.h"
@@ -77,9 +77,9 @@ typedef struct {
 
 /* Security Property Flags. */
 typedef enum {
-  SILC_SKE_SP_FLAG_NONE = (1L << 0),
-  SILC_SKE_SP_FLAG_NO_REPLY = (1L << 1),
-  SILC_SKE_SP_FLAG_PFS = (1L << 2),
+  SILC_SKE_SP_FLAG_NONE      = (1L << 0),
+  SILC_SKE_SP_FLAG_NO_REPLY  = (1L << 1),
+  SILC_SKE_SP_FLAG_PFS       = (1L << 2),
 } SilcSKESecurityPropertyFlag;
 
 /* Security Properties negotiated between key exchange parties. This
@@ -92,7 +92,8 @@ struct SilcSKESecurityPropertiesStruct {
   SilcPKCS pkcs;
   SilcCipher cipher;
   SilcHash hash;
-  /* XXX SilcCompression comp; */
+  SilcHmac hmac;
+  /* XXX SilcZip comp; */
 };
 
 struct SilcSKEStruct {
@@ -119,10 +120,10 @@ struct SilcSKEStruct {
 
   /* Random number x, 1 < x < q. This is the secret exponent
      used in Diffie Hellman computations. */
-  SilcInt x;
+  SilcInt *x;
   
   /* The secret shared key */
-  SilcInt KEY;
+  SilcInt *KEY;
   
   /* The hash value HASH of the key exchange */
   unsigned char *hash;
@@ -135,6 +136,9 @@ struct SilcSKEStruct {
   /* Pointer to the what ever user data. This is set by the caller
      and is not touched by the SKE. The caller must also free this one. */
   void *user_data;
+
+  /* Current status of SKE */
+  SilcSKEStatus status;
 };
 
 /* Prototypes */
@@ -150,6 +154,7 @@ SilcSKEStatus silc_ske_initiator_phase_1(SilcSKE ske,
                                         SilcSKECb callback,
                                         void *context);
 SilcSKEStatus silc_ske_initiator_phase_2(SilcSKE ske,
+                                        SilcPublicKey public_key,
                                         SilcSKESendPacketCb send_packet,
                                         void *context);
 SilcSKEStatus silc_ske_initiator_finish(SilcSKE ske,
@@ -160,6 +165,7 @@ SilcSKEStatus silc_ske_initiator_finish(SilcSKE ske,
                                        void *context);
 SilcSKEStatus silc_ske_responder_start(SilcSKE ske, SilcRng rng,
                                       SilcSocketConnection sock,
+                                      char *version,
                                       SilcBuffer start_payload,
                                       SilcSKECb callback,
                                       void *context);
@@ -185,9 +191,12 @@ SilcSKEStatus silc_ske_abort(SilcSKE ske, SilcSKEStatus status,
                             void *context);
 SilcSKEStatus 
 silc_ske_assemble_security_properties(SilcSKE ske,
+                                     unsigned char flags,
+                                     char *version,
                                      SilcSKEStartPayload **return_payload);
 SilcSKEStatus 
 silc_ske_select_security_properties(SilcSKE ske,
+                                   char *version,
                                    SilcSKEStartPayload *payload,
                                    SilcSKEStartPayload *remote_payload);
 SilcSKEStatus silc_ske_create_rnd(SilcSKE ske, SilcInt n, 
@@ -196,9 +205,22 @@ SilcSKEStatus silc_ske_create_rnd(SilcSKE ske, SilcInt n,
 SilcSKEStatus silc_ske_make_hash(SilcSKE ske, 
                                 unsigned char *return_hash,
                                 unsigned int *return_hash_len);
+SilcSKEStatus 
+silc_ske_process_key_material_data(unsigned char *data,
+                                  unsigned int data_len,
+                                  unsigned int req_iv_len,
+                                  unsigned int req_enc_key_len,
+                                  unsigned int req_hmac_key_len,
+                                  SilcHash hash,
+                                  SilcSKEKeyMaterial *key);
 SilcSKEStatus silc_ske_process_key_material(SilcSKE ske, 
                                            unsigned int req_iv_len,
                                            unsigned int req_enc_key_len,
                                            unsigned int req_hmac_key_len,
                                            SilcSKEKeyMaterial *key);
+SilcSKEStatus silc_ske_check_version(SilcSKE ske,
+                                    unsigned char *version,
+                                    unsigned int version_len);
+void silc_ske_free_key_material(SilcSKEKeyMaterial *key);
+
 #endif