+#include "server_internal.h"
+
+/******************************************************************************
+
+ Common functions
+
+******************************************************************************/
+
+/* This function is used to add keys and stuff to common ID entry data
+ structure. */
+
+void silc_idlist_add_data(void *entry, SilcIDListData idata)
+{
+ SilcIDListData data = (SilcIDListData)entry;
+ data->send_key = idata->send_key;
+ data->receive_key = idata->receive_key;
+ data->hmac_send = idata->hmac_send;
+ data->hmac_receive = idata->hmac_receive;
+ data->psn_send = idata->psn_send;
+ data->psn_receive = idata->psn_receive;
+ data->hash = idata->hash;
+ data->public_key = idata->public_key;
+ memcpy(data->fingerprint, idata->fingerprint, sizeof(data->fingerprint));
+ data->rekey = idata->rekey;
+ data->last_receive = idata->last_receive;
+ data->last_sent = idata->last_sent;
+ data->status = idata->status;
+
+ data->created = time(0); /* Update creation time */
+}
+
+/* Free's all data in the common ID entry data structure. */
+
+void silc_idlist_del_data(void *entry)
+{
+ SilcIDListData idata = (SilcIDListData)entry;
+ if (idata->send_key)
+ silc_cipher_free(idata->send_key);
+ if (idata->receive_key)
+ silc_cipher_free(idata->receive_key);
+ if (idata->rekey) {
+ if (idata->rekey->send_enc_key) {
+ memset(idata->rekey->send_enc_key, 0, idata->rekey->enc_key_len);
+ silc_free(idata->rekey->send_enc_key);
+ }
+ silc_free(idata->rekey);
+ }
+ if (idata->hmac_send)
+ silc_hmac_free(idata->hmac_send);
+ if (idata->hmac_receive)
+ silc_hmac_free(idata->hmac_receive);
+ if (idata->hash)
+ silc_hash_free(idata->hash);
+ if (idata->public_key)
+ silc_pkcs_public_key_free(idata->public_key);
+
+ idata->send_key = NULL;
+ idata->receive_key = NULL;
+ idata->rekey = NULL;
+ idata->hmac_send = NULL;
+ idata->hmac_receive = NULL;
+ idata->hash = NULL;
+ idata->public_key = NULL;
+}
+
+/* Purges ID cache */
+
+SILC_TASK_CALLBACK_GLOBAL(silc_idlist_purge)
+{
+ SilcServer server = app_context;
+ SilcIDListPurge i = (SilcIDListPurge)context;
+
+ SILC_LOG_DEBUG(("Purging cache"));
+
+ silc_idcache_purge(i->cache);
+ silc_schedule_task_add(server->schedule, 0, silc_idlist_purge,
+ (void *)i, i->timeout, 0,
+ SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
+}