Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/bind9/isc
File: hash.h
/*
[0] Fix | Delete
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
[1] Fix | Delete
*
[2] Fix | Delete
* This Source Code Form is subject to the terms of the Mozilla Public
[3] Fix | Delete
* License, v. 2.0. If a copy of the MPL was not distributed with this
[4] Fix | Delete
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
[5] Fix | Delete
*
[6] Fix | Delete
* See the COPYRIGHT file distributed with this work for additional
[7] Fix | Delete
* information regarding copyright ownership.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
#ifndef ISC_HASH_H
[11] Fix | Delete
#define ISC_HASH_H 1
[12] Fix | Delete
[13] Fix | Delete
#include <stdbool.h>
[14] Fix | Delete
[15] Fix | Delete
#include <isc/deprecated.h>
[16] Fix | Delete
#include <isc/types.h>
[17] Fix | Delete
[18] Fix | Delete
/*****
[19] Fix | Delete
***** Module Info
[20] Fix | Delete
*****/
[21] Fix | Delete
[22] Fix | Delete
/*! \file isc/hash.h
[23] Fix | Delete
*
[24] Fix | Delete
* \brief The hash API
[25] Fix | Delete
* provides an unpredictable hash value for variable length data.
[26] Fix | Delete
* A hash object contains a random vector (which is hidden from clients
[27] Fix | Delete
* of this API) to make the actual hash value unpredictable.
[28] Fix | Delete
*
[29] Fix | Delete
* The algorithm used in the API guarantees the probability of hash
[30] Fix | Delete
* collision; in the current implementation, as long as the values stored
[31] Fix | Delete
* in the random vector are unpredictable, the probability of hash
[32] Fix | Delete
* collision between arbitrary two different values is at most 1/2^16.
[33] Fix | Delete
*
[34] Fix | Delete
* Although the API is generic about the hash keys, it mainly expects
[35] Fix | Delete
* DNS names (and sometimes IPv4/v6 addresses) as inputs. It has an
[36] Fix | Delete
* upper limit of the input length, and may run slow to calculate the
[37] Fix | Delete
* hash values for large inputs.
[38] Fix | Delete
*
[39] Fix | Delete
* This API is designed to be general so that it can provide multiple
[40] Fix | Delete
* different hash contexts that have different random vectors. However,
[41] Fix | Delete
* it should be typical to have a single context for an entire system.
[42] Fix | Delete
* To support such cases, the API also provides a single-context mode.
[43] Fix | Delete
*
[44] Fix | Delete
* \li MP:
[45] Fix | Delete
* The hash object is almost read-only. Once the internal random vector
[46] Fix | Delete
* is initialized, no write operation will occur, and there will be no
[47] Fix | Delete
* need to lock the object to calculate actual hash values.
[48] Fix | Delete
*
[49] Fix | Delete
* \li Reliability:
[50] Fix | Delete
* In some cases this module uses low-level data copy to initialize the
[51] Fix | Delete
* random vector. Errors in this part are likely to crash the server or
[52] Fix | Delete
* corrupt memory.
[53] Fix | Delete
*
[54] Fix | Delete
* \li Resources:
[55] Fix | Delete
* A buffer, used as a random vector for calculating hash values.
[56] Fix | Delete
*
[57] Fix | Delete
* \li Security:
[58] Fix | Delete
* This module intends to provide unpredictable hash values in
[59] Fix | Delete
* adversarial environments in order to avoid denial of service attacks
[60] Fix | Delete
* to hash buckets.
[61] Fix | Delete
* Its unpredictability relies on the quality of entropy to build the
[62] Fix | Delete
* random vector.
[63] Fix | Delete
*
[64] Fix | Delete
* \li Standards:
[65] Fix | Delete
* None.
[66] Fix | Delete
*/
[67] Fix | Delete
[68] Fix | Delete
/***
[69] Fix | Delete
*** Imports
[70] Fix | Delete
***/
[71] Fix | Delete
[72] Fix | Delete
#include <isc/types.h>
[73] Fix | Delete
[74] Fix | Delete
/***
[75] Fix | Delete
*** Functions
[76] Fix | Delete
***/
[77] Fix | Delete
ISC_LANG_BEGINDECLS
[78] Fix | Delete
[79] Fix | Delete
LIBISC_EXTERNAL_DATA extern isc_hash_t *isc_hashctx;
[80] Fix | Delete
[81] Fix | Delete
isc_result_t
[82] Fix | Delete
isc_hash_ctxcreate(isc_mem_t *mctx, isc_entropy_t *entropy, size_t limit,
[83] Fix | Delete
isc_hash_t **hctx);
[84] Fix | Delete
isc_result_t
[85] Fix | Delete
isc_hash_create(isc_mem_t *mctx, isc_entropy_t *entropy, size_t limit);
[86] Fix | Delete
/*!<
[87] Fix | Delete
* \brief Create a new hash object.
[88] Fix | Delete
*
[89] Fix | Delete
* isc_hash_ctxcreate() creates a different object.
[90] Fix | Delete
*
[91] Fix | Delete
* isc_hash_create() creates a module-internal object to support the
[92] Fix | Delete
* single-context mode. It should be called only once.
[93] Fix | Delete
*
[94] Fix | Delete
* 'entropy' must be NULL or a valid entropy object. If 'entropy' is NULL,
[95] Fix | Delete
* pseudo random values will be used to build the random vector, which may
[96] Fix | Delete
* weaken security.
[97] Fix | Delete
*
[98] Fix | Delete
* 'limit' specifies the maximum number of hash keys. If it is too large,
[99] Fix | Delete
* these functions may fail.
[100] Fix | Delete
*/
[101] Fix | Delete
[102] Fix | Delete
void
[103] Fix | Delete
isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp)
[104] Fix | Delete
ISC_DEPRECATED;
[105] Fix | Delete
/*!<
[106] Fix | Delete
* \brief Attach to a hash object.
[107] Fix | Delete
*
[108] Fix | Delete
* This function is only necessary for the multiple-context mode.
[109] Fix | Delete
*/
[110] Fix | Delete
[111] Fix | Delete
void
[112] Fix | Delete
isc_hash_ctxdetach(isc_hash_t **hctxp)
[113] Fix | Delete
ISC_DEPRECATED;
[114] Fix | Delete
/*!<
[115] Fix | Delete
* \brief Detach from a hash object.
[116] Fix | Delete
*
[117] Fix | Delete
* This function is for the multiple-context mode, and takes a valid
[118] Fix | Delete
* hash object as an argument.
[119] Fix | Delete
*/
[120] Fix | Delete
[121] Fix | Delete
void
[122] Fix | Delete
isc_hash_destroy(void);
[123] Fix | Delete
/*!<
[124] Fix | Delete
* \brief This function is for the single-context mode, and is expected to be used
[125] Fix | Delete
* as a counterpart of isc_hash_create().
[126] Fix | Delete
*
[127] Fix | Delete
* A valid module-internal hash object must have been created, and this
[128] Fix | Delete
* function should be called only once.
[129] Fix | Delete
*/
[130] Fix | Delete
[131] Fix | Delete
/*@{*/
[132] Fix | Delete
void
[133] Fix | Delete
isc_hash_ctxinit(isc_hash_t *hctx);
[134] Fix | Delete
void
[135] Fix | Delete
isc_hash_init(void);
[136] Fix | Delete
/*!<
[137] Fix | Delete
* \brief Initialize a hash object.
[138] Fix | Delete
*
[139] Fix | Delete
* It fills in the random vector with a proper
[140] Fix | Delete
* source of entropy, which is typically from the entropy object specified
[141] Fix | Delete
* at the creation. Thus, it is desirable to call these functions after
[142] Fix | Delete
* initializing the entropy object with some good entropy sources.
[143] Fix | Delete
*
[144] Fix | Delete
* These functions should be called before the first hash calculation.
[145] Fix | Delete
*
[146] Fix | Delete
* isc_hash_ctxinit() is for the multiple-context mode, and takes a valid hash
[147] Fix | Delete
* object as an argument.
[148] Fix | Delete
*
[149] Fix | Delete
* isc_hash_init() is for the single-context mode. A valid module-internal
[150] Fix | Delete
* hash object must have been created, and this function should be called only
[151] Fix | Delete
* once.
[152] Fix | Delete
*/
[153] Fix | Delete
/*@}*/
[154] Fix | Delete
[155] Fix | Delete
/*@{*/
[156] Fix | Delete
unsigned int
[157] Fix | Delete
isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
[158] Fix | Delete
unsigned int keylen, bool case_sensitive)
[159] Fix | Delete
ISC_DEPRECATED;
[160] Fix | Delete
unsigned int
[161] Fix | Delete
isc_hash_calc(const unsigned char *key, unsigned int keylen,
[162] Fix | Delete
bool case_sensitive)
[163] Fix | Delete
ISC_DEPRECATED;
[164] Fix | Delete
/*!<
[165] Fix | Delete
* \brief Calculate a hash value.
[166] Fix | Delete
*
[167] Fix | Delete
* isc_hash_ctxinit() is for the multiple-context mode, and takes a valid hash
[168] Fix | Delete
* object as an argument.
[169] Fix | Delete
*
[170] Fix | Delete
* isc_hash_init() is for the single-context mode. A valid module-internal
[171] Fix | Delete
* hash object must have been created.
[172] Fix | Delete
*
[173] Fix | Delete
* 'key' is the hash key, which is a variable length buffer.
[174] Fix | Delete
*
[175] Fix | Delete
* 'keylen' specifies the key length, which must not be larger than the limit
[176] Fix | Delete
* specified for the corresponding hash object.
[177] Fix | Delete
*
[178] Fix | Delete
* 'case_sensitive' specifies whether the hash key should be treated as
[179] Fix | Delete
* case_sensitive values. It should typically be false if the hash key
[180] Fix | Delete
* is a DNS name.
[181] Fix | Delete
*/
[182] Fix | Delete
/*@}*/
[183] Fix | Delete
[184] Fix | Delete
void
[185] Fix | Delete
isc__hash_setvec(const uint16_t *vec)
[186] Fix | Delete
ISC_DEPRECATED;
[187] Fix | Delete
[188] Fix | Delete
/*!<
[189] Fix | Delete
* \brief Set the contents of the random vector used in hashing.
[190] Fix | Delete
*
[191] Fix | Delete
* WARNING: This function is meant to be used only in testing code. It
[192] Fix | Delete
* must not be used anywhere in normally running code.
[193] Fix | Delete
*
[194] Fix | Delete
* The hash context must have been created beforehand, otherwise this
[195] Fix | Delete
* function is a nop.
[196] Fix | Delete
*
[197] Fix | Delete
* 'vec' is not documented here on purpose. You should know what you are
[198] Fix | Delete
* doing before using this function.
[199] Fix | Delete
*/
[200] Fix | Delete
[201] Fix | Delete
const void *
[202] Fix | Delete
isc_hash_get_initializer(void);
[203] Fix | Delete
[204] Fix | Delete
void
[205] Fix | Delete
isc_hash_set_initializer(const void *initializer);
[206] Fix | Delete
[207] Fix | Delete
uint32_t
[208] Fix | Delete
isc_hash_function(const void *data, size_t length,
[209] Fix | Delete
bool case_sensitive,
[210] Fix | Delete
const uint32_t *previous_hashp);
[211] Fix | Delete
uint32_t
[212] Fix | Delete
isc_hash_function_reverse(const void *data, size_t length,
[213] Fix | Delete
bool case_sensitive,
[214] Fix | Delete
const uint32_t *previous_hashp);
[215] Fix | Delete
/*!<
[216] Fix | Delete
* \brief Calculate a hash over data.
[217] Fix | Delete
*
[218] Fix | Delete
* This hash function is useful for hashtables. The hash function is
[219] Fix | Delete
* opaque and not important to the caller. The returned hash values are
[220] Fix | Delete
* non-deterministic and will have different mapping every time a
[221] Fix | Delete
* process using this library is run, but will have uniform
[222] Fix | Delete
* distribution.
[223] Fix | Delete
*
[224] Fix | Delete
* isc_hash_function() calculates the hash from start to end over the
[225] Fix | Delete
* input data. isc_hash_function_reverse() calculates the hash from the
[226] Fix | Delete
* end to the start over the input data. The difference in order is
[227] Fix | Delete
* useful in incremental hashing; for example, a previously hashed
[228] Fix | Delete
* value for 'com' can be used as input when hashing 'example.com'.
[229] Fix | Delete
*
[230] Fix | Delete
* This is a new variant of isc_hash_calc() and will supersede
[231] Fix | Delete
* isc_hash_calc() eventually.
[232] Fix | Delete
*
[233] Fix | Delete
* 'data' is the data to be hashed.
[234] Fix | Delete
*
[235] Fix | Delete
* 'length' is the size of the data to be hashed.
[236] Fix | Delete
*
[237] Fix | Delete
* 'case_sensitive' specifies whether the hash key should be treated as
[238] Fix | Delete
* case_sensitive values. It should typically be false if the hash key
[239] Fix | Delete
* is a DNS name.
[240] Fix | Delete
*
[241] Fix | Delete
* 'previous_hashp' is a pointer to a previous hash value returned by
[242] Fix | Delete
* this function. It can be used to perform incremental hashing. NULL
[243] Fix | Delete
* must be passed during first calls.
[244] Fix | Delete
*/
[245] Fix | Delete
[246] Fix | Delete
ISC_LANG_ENDDECLS
[247] Fix | Delete
[248] Fix | Delete
#endif /* ISC_HASH_H */
[249] Fix | Delete
[250] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function