+ SilcUInt32 *auth_len);
+
+/****f* silccore/SilcAuthAPI/SilcAuthGenerated
+ *
+ * SYNOPSIS
+ *
+ * typedef void (*SilcAuthGenerated)(const SilcBuffer data, void *context);
+ *
+ * DESCRIPTION
+ *
+ * Callback of this type is given as argument to
+ * silc_auth_public_key_auth_generate and
+ * silc_auth_public_key_auth_generate_wpub to deliver the generated
+ * Authentication Payload. If `data' is NULL the generating failed.
+ *
+ ***/
+typedef void (*SilcAuthGenerated)(const SilcBuffer data, void *context);
+
+/****f* silccore/SilcAuthAPI/silc_auth_public_key_auth_generate
+ *
+ * SYNOPSIS
+ *
+ * SilcAsyncOperation
+ * silc_auth_public_key_auth_generate(SilcPublicKey public_key,
+ * SilcPrivateKey private_key,
+ * SilcRng rng,
+ * SilcHash hash,
+ * const void *id,
+ * SilcIdType type,
+ * SilcAuthGenerated generated,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * Generates Authentication Payload with authentication data. This is used
+ * to do public key based authentication. This generates the random data
+ * and the actual authentication data.
+ *
+ * The `private_key' is used to sign the payload. The `public_key', the
+ * and the `id' is encoded in the payload and signed. If the `rng' is
+ * NULL then global RNG is used, if non-NULL then `rng' is used as
+ * random number generator. Also random number is encoded in the
+ * payload before signing it with `private_key'.
+ *
+ * The `generated' is called to deliver the generated Authentication
+ * Payload.
+ *
+ ***/
+SilcAsyncOperation
+silc_auth_public_key_auth_generate(SilcPublicKey public_key,
+ SilcPrivateKey private_key,
+ SilcRng rng, SilcHash hash,
+ const void *id, SilcIdType type,
+ SilcAuthGenerated generated,
+ void *context);
+
+/****f* silccore/SilcAuthAPI/silc_auth_public_key_auth_generate_wpub
+ *
+ * SYNOPSIS
+ *
+ * SilcAsyncOperation
+ * silc_auth_public_key_auth_generate_wpub(SilcPublicKey public_key,
+ * SilcPrivateKey private_key,
+ * const unsigned char *pubdata,
+ * SilcUInt32 pubdata_len,
+ * SilcHash hash,
+ * SilcRng rng,
+ * const void *id,
+ * SilcIdType type,
+ * SilcAuthGenerated generated,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * Same as silc_auth_public_key_auth_generate but takes the public data
+ * (usually random data) as argument. This function can be used when
+ * the public data must be something else than purely random or its
+ * structure mut be set before signing.
+ *
+ * The `generated' is called to deliver the generated Authentication
+ * Payload.
+ *
+ ***/
+SilcAsyncOperation
+silc_auth_public_key_auth_generate_wpub(SilcPublicKey public_key,
+ SilcPrivateKey private_key,
+ const unsigned char *pubdata,
+ SilcUInt32 pubdata_len,
+ SilcHash hash,
+ SilcRng rng,
+ const void *id, SilcIdType type,
+ SilcAuthGenerated generated,
+ void *context);
+
+/****f* silccore/SilcAuthAPI/SilcAuthResult
+ *
+ * SYNOPSIS
+ *
+ * typedef void (*SilcAuthResult)(SilcBool success, void *context);
+ *
+ * DESCRIPTION
+ *
+ * Callback of this type is given as argument to silc_auth_verify,
+ * silc_auth_verify_data, silc_auth_public_key_auth_verify and
+ * silc_auth_public_key_auth_verify_data to deliver the result of
+ * the authentication verification. If `success' is FALSE the
+ * authentication failed.
+ *
+ ***/
+typedef void (*SilcAuthResultCb)(SilcBool success, void *context);
+
+/****f* silccore/SilcAuthAPI/silc_auth_public_key_auth_verify
+ *
+ * SYNOPSIS
+ *
+ * SilcAsyncOperation
+ * silc_auth_public_key_auth_verify(SilcAuthPayload payload,
+ * SilcPublicKey public_key,
+ * SilcHash hash,
+ * const void *id,
+ * SilcIdType type,
+ * SilcAuthResult result,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * Verifies the authentication data. Calls the `result' to deliver
+ * the result of the verification.
+ *
+ ***/
+SilcAsyncOperation
+silc_auth_public_key_auth_verify(SilcAuthPayload payload,
+ SilcPublicKey public_key,
+ SilcHash hash,
+ const void *id,
+ SilcIdType type,
+ SilcAuthResultCb result,
+ void *context);
+
+/****f* silccore/SilcAuthAPI/silc_auth_public_key_auth_verify_data
+ *
+ * SYNOPSIS
+ *
+ * SilcAsyncOperation
+ * silc_auth_public_key_auth_verify_data(const unsigned char *payload,
+ * SilcUInt32 payload_len,
+ * SilcPublicKey public_key,
+ * SilcHash hash,
+ * const void *id,
+ * SilcIdType type,
+ * SilcAuthResult result,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * Same as silc_auth_public_key_auth_verify but the payload has not
+ * been parsed yet. This will parse it. Calls the `result' to deliver
+ * the result of the verification.
+ *
+ ***/
+SilcAsyncOperation
+silc_auth_public_key_auth_verify_data(const unsigned char *payload,
+ SilcUInt32 payload_len,
+ SilcPublicKey public_key,
+ SilcHash hash,
+ const void *id,
+ SilcIdType type,
+ SilcAuthResultCb result,
+ void *context);
+
+/****f* silccore/SilcAuthAPI/silc_auth_verify
+ *
+ * SYNOPSIS
+ *
+ * SilcAsyncOperation
+ * silc_auth_verify(SilcAuthPayload payload,
+ * SilcAuthMethod auth_method,
+ * const void *auth_data,
+ * SilcUInt32 auth_data_len,
+ * SilcHash hash,
+ * const void *id, SilcIdType type,
+ * SilcAuthResult result, void *context);
+ *
+ * DESCRIPTION
+ *
+ * Verifies the authentication data directly from the Authentication
+ * Payload. Supports all authentication methods. If the authentication
+ * method is passphrase based then the `auth_data' and `auth_data_len'
+ * are the passphrase and its length. The passphrase MUST be UTF-8
+ * encoded. If the method is public key authentication then the
+ * `auth_data' is the SilcPublicKey and the `auth_data_len' is ignored.
+ * Calls the `result' to deliver the result of the verification.
+ *
+ ***/
+SilcAsyncOperation
+silc_auth_verify(SilcAuthPayload payload, SilcAuthMethod auth_method,
+ const void *auth_data, SilcUInt32 auth_data_len,
+ SilcHash hash, const void *id, SilcIdType type,
+ SilcAuthResultCb result, void *context);
+
+/****f* silccore/SilcAuthAPI/silc_auth_verify_data
+ *
+ * SYNOPSIS
+ *
+ * SilcAsyncOperation
+ * silc_auth_verify_data(const unsigned char *payload,
+ * SilcUInt32 payload_len,
+ * SilcAuthMethod auth_method,
+ * const void *auth_data,
+ * SilcUInt32 auth_data_len, SilcHash hash,
+ * const void *id, SilcIdType type,
+ * SilcAuthResult result, void *context);
+ *
+ * DESCRIPTION
+ *
+ * Same as silc_auth_verify but the payload has not been parsed yet.
+ * Verifies the authentication data directly from the Authentication
+ * Payload. Supports all authentication methods. If the authentication
+ * method is passphrase based then the `auth_data' and `auth_data_len'
+ * are the passphrase and its length. The passphrase MUST be UTF-8
+ * encoded. If the method is public key authentication then the
+ * `auth_data' is the SilcPublicKey and the `auth_data_len' is ignored.
+ * Calls the `result' to deliver the result of the verification.
+ *
+ ***/
+SilcAsyncOperation
+silc_auth_verify_data(const unsigned char *payload,
+ SilcUInt32 payload_len,
+ SilcAuthMethod auth_method,
+ const void *auth_data,
+ SilcUInt32 auth_data_len, SilcHash hash,
+ const void *id, SilcIdType type,
+ SilcAuthResultCb result, void *context);
+
+/****s* silccore/SilcAuthAPI/SilcKeyAgreementPayload
+ *
+ * NAME
+ *
+ * typedef struct SilcKeyAgreementPayloadStruct *SilcKeyAgreementPayload;
+ *
+ * DESCRIPTION
+ *
+ * This context is the actual Key Agreement Payload and is allocated
+ * by silc_key_agreement_payload_parse and given as argument usually to all
+ * silc_key_agreement_* functions. It is freed by the function
+ * silc_key_agreement_payload_free.
+ *
+ ***/
+typedef struct SilcKeyAgreementPayloadStruct *SilcKeyAgreementPayload;
+
+/****f* silccore/SilcAuthAPI/silc_key_agreement_payload_parse
+ *
+ * SYNOPSIS
+ *
+ * SilcKeyAgreementPayload
+ * silc_key_agreement_payload_parse(const unsigned char *payload,
+ * SilcUInt32 payload_len);
+ *
+ * DESCRIPTION
+ *
+ * Parses and returns an allocated Key Agreement payload.
+ *
+ ***/
+SilcKeyAgreementPayload
+silc_key_agreement_payload_parse(const unsigned char *payload,
+ SilcUInt32 payload_len);
+
+/****f* silccore/SilcAuthAPI/silc_key_agreement_payload_encode
+ *
+ * SYNOPSIS
+ *
+ * SilcBuffer silc_key_agreement_payload_encode(char *hostname,
+ * SilcUInt16 protocol,
+ * SilcUInt16 port);
+ *
+ * DESCRIPTION
+ *
+ * Encodes the Key Agreement payload and returns the encoded buffer.
+ * The `protocol' is 0 for TCP and 1 for UDP.
+ *
+ ***/
+SilcBuffer silc_key_agreement_payload_encode(const char *hostname,
+ SilcUInt16 protocol,
+ SilcUInt16 port);
+
+/****f* silccore/SilcAuthAPI/silc_key_agreement_payload_free
+ *
+ * SYNOPSIS
+ *
+ * void silc_key_agreement_payload_free(SilcKeyAgreementPayload payload);
+ *
+ * DESCRIPTION
+ *
+ * Frees the Key Agreement payload and all data in it.
+ *
+ ***/