- return h;
-}
-
-/* Hash binary data. The `user_context' is the data length. */
-
-SilcUInt32 silc_hash_data(void *key, void *user_context)
-{
- SilcUInt32 len = SILC_PTR_TO_32(user_context), h = 0;
- unsigned char *data = (unsigned char *)key;
- int i;
-
- h = (data[0] * data[len - 1] + 1) * len;
- for (i = 0; i < len; i++)
- h ^= data[i];
-
- return h;
-}
-
-/* Hash public key of any type. */
-
-SilcUInt32 silc_hash_public_key(void *key, void *user_context)
-{
- SilcPublicKey public_key = key;
- unsigned char *pk;
- SilcUInt32 pk_len;
- SilcUInt32 hash = 0;
-
- pk = silc_pkcs_public_key_encode(public_key, &pk_len);
- if (!pk)
- return hash;
-
- hash = silc_hash_data(pk, SILC_32_TO_PTR(pk_len));
- silc_free(pk);
-
- return hash;
-}
-
-/* Compares two strings. It may be used as SilcHashTable comparison
- function. */
-
-SilcBool silc_hash_string_compare(void *key1, void *key2, void *user_context)
-{
- return !strcasecmp((char *)key1, (char *)key2);
-}
-
-/* Compares two ID's. May be used as SilcHashTable comparison function.
- The Client ID's compares only the hash of the Client ID not any other
- part of the Client ID. Other ID's are fully compared. */
-
-SilcBool silc_hash_id_compare(void *key1, void *key2, void *user_context)
-{
- SilcIdType id_type = (SilcIdType)SILC_PTR_TO_32(user_context);
- return (id_type == SILC_ID_CLIENT ?
- SILC_ID_COMPARE_HASH((SilcClientID *)key1, (SilcClientID *)key2) :
- SILC_ID_COMPARE_TYPE(key1, key2, id_type));
-}
-
-/* Compares two ID's. Compares full IDs. */
-
-SilcBool silc_hash_id_compare_full(void *key1, void *key2, void *user_context)
-{
- SilcIdType id_type = (SilcIdType)SILC_PTR_TO_32(user_context);
- return SILC_ID_COMPARE_TYPE(key1, key2, id_type);
-}
-
-/* Compare two Client ID's entirely and not just the hash from the ID. */
-
-SilcBool silc_hash_client_id_compare(void *key1, void *key2,
- void *user_context)
-{
- return SILC_ID_COMPARE_TYPE(key1, key2, SILC_ID_CLIENT);
-}
-
-/* Compares binary data. May be used as SilcHashTable comparison function. */
-
-SilcBool silc_hash_data_compare(void *key1, void *key2, void *user_context)
-{
- SilcUInt32 len = SILC_PTR_TO_32(user_context);
- return !memcmp(key1, key2, len);
-}
-
-/* Compares UTF-8 string. */
-
-SilcBool silc_hash_utf8_compare(void *key1, void *key2, void *user_context)
-{
- int l1 = strlen((char *)key1);
- int l2 = strlen((char *)key2);
- if (l1 != l2)
- return FALSE;
- return !memcmp(key1, key2, l2);
-}