libimcv: Moved REST API from imv_swid and imv_swima to libimcv
[strongswan.git] / src / libsimaka / simaka_message.h
index c31df7f..2393d34 100644 (file)
 #ifndef SIMAKA_MESSAGE_H_
 #define SIMAKA_MESSAGE_H_
 
-#include <enum.h>
-#include <daemon.h>
+#include <utils/utils.h>
+#include <eap/eap.h>
 
 #include "simaka_crypto.h"
 
-typedef struct simaka_message_t simaka_message_t;
 typedef enum simaka_attribute_t simaka_attribute_t;
 typedef enum simaka_subtype_t simaka_subtype_t;
 typedef enum simaka_notification_t simaka_notification_t;
 typedef enum simaka_client_error_t simaka_client_error_t;
+typedef struct simaka_message_t simaka_message_t;
 
 /**
  * Subtypes of EAP-SIM/AKA messages
@@ -176,7 +176,7 @@ struct simaka_message_t {
         *
         * @return                      EAP message identifier
         */
-       u_int8_t (*get_identifier)(simaka_message_t *this);
+       uint8_t (*get_identifier)(simaka_message_t *this);
 
        /**
         * Get the EAP type of the message.
@@ -214,7 +214,9 @@ struct simaka_message_t {
         * Parse a message, with optional attribute decryption.
         *
         * This method does not verify message integrity, as the key is available
-        * only after the payload has been parsed.
+        * only after the payload has been parsed. It might be necessary to call
+        * parse twice, as key derivation data in EAP-SIM/AKA is in the same
+        * packet as encrypted data.
         *
         * @param crypto        EAP-SIM/AKA crypto helper
         * @return                      TRUE if message parsed successfully
@@ -234,9 +236,10 @@ struct simaka_message_t {
         * Generate a message, optionally encrypt attributes and create a MAC.
         *
         * @param sigdata       additional data to include in signature, if any
-        * @return                      generated eap payload, NULL if failed
+        * @param gen           allocated generated data, if successful
+        * @return                      TRUE if successful
         */
-       eap_payload_t* (*generate)(simaka_message_t *this, chunk_t sigdata);
+       bool (*generate)(simaka_message_t *this, chunk_t sigdata, chunk_t *gen);
 
        /**
         * Destroy a simaka_message_t.
@@ -254,18 +257,18 @@ struct simaka_message_t {
  * @param crypto               EAP-SIM/AKA crypto helper
  * @return                             empty message of requested kind, NULL on error
  */
-simaka_message_t *simaka_message_create(bool request, u_int8_t identifier,
+simaka_message_t *simaka_message_create(bool request, uint8_t identifier,
                                                                        eap_type_t type, simaka_subtype_t subtype,
                                                                        simaka_crypto_t *crypto);
 
 /**
  * Create an simaka_message from a chunk of data.
  *
- * @param payload              payload to create message from
+ * @param data                 message data to parse
  * @param crypto               EAP-SIM/AKA crypto helper
  * @return                             EAP message, NULL on error
  */
-simaka_message_t *simaka_message_create_from_payload(eap_payload_t *payload,
+simaka_message_t *simaka_message_create_from_payload(chunk_t data,
                                                                                                         simaka_crypto_t *crypto);
 
 #endif /** SIMAKA_MESSAGE_H_ @}*/