updates.
[silc.git] / lib / silcclient / silcapi.h
index 17bb058aa6e6614dfd7c6adef1bb5d0b59e8cbad..0c2b85f0fcadba79677928ece5c7ce7bb5d2975b 100644 (file)
 /* Key agreement status types indicating the status of the protocol. */
 typedef enum {
   SILC_KEY_AGREEMENT_OK,              /* Everything is Ok */
-  SILC_KEY_AGREEMENT_ERROR,           /* Unknown error occured */
+  SILC_KEY_AGREEMENT_ERROR,           /* Unknown error occurred */
   SILC_KEY_AGREEMENT_FAILURE,         /* The protocol failed */
   SILC_KEY_AGREEMENT_TIMEOUT,         /* The protocol timeout */
 } SilcKeyAgreementStatus;
 
 /* Key agreement callback that is called after the key agreement protocol
-   has been performed. This is called also if error occured during the
+   has been performed. This is called also if error occurred during the
    key agreement protocol. The `key' is the allocated key material and
    the caller is responsible of freeing it. The `key' is NULL if error
-   has occured. The application can freely use the `key' to whatever
+   has occurred. The application can freely use the `key' to whatever
    purpose it needs. See lib/silcske/silcske.h for the definition of
    the SilcSKEKeyMaterial structure. */
 typedef void (*SilcKeyAgreementCallback)(SilcClient client,
@@ -84,6 +84,18 @@ typedef struct {
 
 ******************************************************************************/
 
+/* Ask passphrase callback. This is called by the application when the
+   library calls `ask_passphrase' client operation.  The callback delivers
+   the passphrase to the library. */
+typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
+                                 uint32 passphrase_len,
+                                 void *context);
+
+/* Public key (or certificate) verification callback. This is called
+   by the application to indicate that the public key verification was
+   either success or failure. */
+typedef void (*SilcVerifyPublicKey)(bool success, void *context);
+
 /* SILC Client Operations. These must be implemented by the application. */
 typedef struct {
   /* Message sent to the application by library. `conn' associates the
@@ -116,7 +128,7 @@ typedef struct {
   /* Command handler. This function is called always in the command function.
      If error occurs it will be called as well. `conn' is the associated
      client connection. `cmd_context' is the command context that was
-     originally sent to the command. `success' is FALSE if error occured
+     originally sent to the command. `success' is FALSE if error occurred
      during command. `command' is the command being processed. It must be
      noted that this is not reply from server. This is merely called just
      after application has called the command. Just to tell application
@@ -135,7 +147,7 @@ typedef struct {
      payload data received from server and it can be ignored. It is provided
      if the application would like to re-parse the received command data,
      however, it must be noted that the data is parsed already by the library
-     thus the payload can be ignored. `success' is FALSE if error occured.
+     thus the payload can be ignored. `success' is FALSE if error occurred.
      In this case arguments are not sent to the application. The `status' is
      the command reply status server returned. The `command' is the command
      reply being processed. The function has variable argument list and each
@@ -166,17 +178,18 @@ typedef struct {
 
   /* Verifies received public key. The `conn_type' indicates which entity
      (server, client etc.) has sent the public key. If user decides to trust
-     the key may be saved as trusted public key for later use. If user does
-     not trust the key this returns FALSE. If everything is Ok this returns
-     TRUE. */ 
-  int (*verify_public_key)(SilcClient client, SilcClientConnection conn,
-                          SilcSocketType conn_type, unsigned char *pk, 
-                          uint32 pk_len, SilcSKEPKType pk_type);
-
-  /* Ask (interact, that is) a passphrase from user. Returns the passphrase
-     or NULL on error. */
-  unsigned char *(*ask_passphrase)(SilcClient client, 
-                                  SilcClientConnection conn);
+     the key may be saved as trusted public key for later use. The 
+     `completion' must be called after the public key has been verified. */
+  void (*verify_public_key)(SilcClient client, SilcClientConnection conn,
+                           SilcSocketType conn_type, unsigned char *pk, 
+                           uint32 pk_len, SilcSKEPKType pk_type,
+                           SilcVerifyPublicKey completion, void *context);
+
+  /* Ask (interact, that is) a passphrase from user. The passphrase is
+     returned to the library by calling the `completion' callback with
+     the `context'. */
+  void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
+                        SilcAskPassphrase completion, void *context);
 
   /* Notifies application that failure packet was received.  This is called
      if there is some protocol active in the client.  The `protocol' is the
@@ -227,7 +240,7 @@ void silc_client_free(SilcClient client);
 
 /* Initializes the client. This makes all the necessary steps to make
    the client ready to be run. One must call silc_client_run to run the
-   client. Returns FALSE if error occured, TRUE otherwise. */
+   client. Returns FALSE if error occurred, TRUE otherwise. */
 int silc_client_init(SilcClient client);
 
 /* Runs the client. This starts the scheduler from the utility library.
@@ -322,7 +335,7 @@ void silc_client_send_channel_message(SilcClient client,
 /* Sends private message to remote client. If private message key has
    not been set with this client then the message will be encrypted using
    normal session keys. Private messages are special packets in SILC
-   network hence we need this own function for them. This is similiar
+   network hence we need this own function for them. This is similar
    to silc_client_packet_send_to_channel except that we send private
    message. The `data' is the private message. If the `force_send' is
    TRUE the packet is sent immediately. */