mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-04 08:55:40 +03:00
In preparation for changing the make buildsystem to a fully autotools controlled system moving the core libcoap source files to a better logical place. All the library related header files moving to include/coap/ to get all the public and local header files in a separate place. Also moving the C source files of the libcoap library to the folder src/.
30 lines
631 B
C
30 lines
631 B
C
/* hashkey.c -- definition of hash key type and helper functions
|
|
*
|
|
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
|
|
*
|
|
* This file is part of the CoAP library libcoap. Please see
|
|
* README for terms of use.
|
|
*/
|
|
|
|
#include "hashkey.h"
|
|
|
|
/* Caution: When changing this, update COAP_DEFAULT_WKC_HASHKEY
|
|
* accordingly (see int coap_hash_path());
|
|
*/
|
|
void
|
|
coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h) {
|
|
size_t j;
|
|
|
|
while (len--) {
|
|
j = sizeof(coap_key_t)-1;
|
|
|
|
while (j) {
|
|
h[j] = ((h[j] << 7) | (h[j-1] >> 1)) + h[j];
|
|
--j;
|
|
}
|
|
|
|
h[0] = (h[0] << 7) + h[0] + *s++;
|
|
}
|
|
}
|
|
|