merged with origin/1.1
This commit is contained in:
commit
b68eaa7ce4
7 changed files with 19 additions and 26 deletions
|
|
@ -9,6 +9,7 @@ AM_INIT_AUTOMAKE([std-options subdir-objects -Wall])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AM_PROG_AR
|
AM_PROG_AR
|
||||||
LT_INIT
|
LT_INIT
|
||||||
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
# Enable GNU extensions.
|
# Enable GNU extensions.
|
||||||
# Define this here, not in acconfig's @TOP@ section, since definitions
|
# Define this here, not in acconfig's @TOP@ section, since definitions
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
These files are used by a program called aclocal (part of the GNU automake
|
|
||||||
package). aclocal uses these files to create aclocal.m4 which is in turn
|
|
||||||
used by autoconf to create the configure script at the the top level in
|
|
||||||
this distribution.
|
|
||||||
|
|
||||||
The Makefile.am file in this directory is automatically generated
|
|
||||||
from the template file, Makefile.am.in. The generation will fail
|
|
||||||
if you don't have all the right tools.
|
|
||||||
|
|
@ -29,7 +29,7 @@ static uint32_t hash_function(const void *p, size_t len) {
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
for(int i = len > 4 ? 4 : len; --i;)
|
for(int i = len > 4 ? 4 : len; --i;)
|
||||||
hash += q[len - i] << (8 * i);
|
hash += (uint32_t)q[len - i] << (8 * i);
|
||||||
hash *= 0x9e370001UL; // Golden ratio prime.
|
hash *= 0x9e370001UL; // Golden ratio prime.
|
||||||
if(len <= 4)
|
if(len <= 4)
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -28,36 +28,38 @@ static void memxor(char *buf, char c, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const size_t mdlen = 64;
|
static const size_t mdlen = 64;
|
||||||
|
static const size_t blklen = 128;
|
||||||
|
|
||||||
static bool hmac_sha512(const char *key, size_t keylen, const char *msg, size_t msglen, char *out) {
|
static bool hmac_sha512(const char *key, size_t keylen, const char *msg, size_t msglen, char *out) {
|
||||||
char tmp[2 * mdlen];
|
char tmp[blklen + mdlen];
|
||||||
sha512_context md;
|
sha512_context md;
|
||||||
|
|
||||||
if(keylen <= mdlen) {
|
if(keylen <= blklen) {
|
||||||
memcpy(tmp, key, keylen);
|
memcpy(tmp, key, keylen);
|
||||||
memset(tmp + keylen, 0, mdlen - keylen);
|
memset(tmp + keylen, 0, blklen - keylen);
|
||||||
} else {
|
} else {
|
||||||
if(sha512(key, keylen, tmp) != 0)
|
if(sha512(key, keylen, tmp) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
memset(tmp + mdlen, 0, blklen - mdlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sha512_init(&md) != 0)
|
if(sha512_init(&md) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// ipad
|
// ipad
|
||||||
memxor(tmp, 0x36, mdlen);
|
memxor(tmp, 0x36, blklen);
|
||||||
if(sha512_update(&md, tmp, mdlen) != 0)
|
if(sha512_update(&md, tmp, blklen) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// message
|
// message
|
||||||
if(sha512_update(&md, msg, msglen) != 0)
|
if(sha512_update(&md, msg, msglen) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(sha512_final(&md, tmp + mdlen) != 0)
|
if(sha512_final(&md, tmp + blklen) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// opad
|
// opad
|
||||||
memxor(tmp, 0x36 ^ 0x5c, mdlen);
|
memxor(tmp, 0x36 ^ 0x5c, blklen);
|
||||||
if(sha512(tmp, sizeof tmp, out) != 0)
|
if(sha512(tmp, sizeof tmp, out) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -82,17 +84,17 @@ bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char
|
||||||
|
|
||||||
while(outlen > 0) {
|
while(outlen > 0) {
|
||||||
/* Inner HMAC */
|
/* Inner HMAC */
|
||||||
if(!hmac_sha512(data, sizeof data, secret, secretlen, data))
|
if(!hmac_sha512(secret, secretlen, data, sizeof data, data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Outer HMAC */
|
/* Outer HMAC */
|
||||||
if(outlen >= mdlen) {
|
if(outlen >= mdlen) {
|
||||||
if(!hmac_sha512(data, sizeof data, secret, secretlen, out))
|
if(!hmac_sha512(secret, secretlen, data, sizeof data, out))
|
||||||
return false;
|
return false;
|
||||||
out += mdlen;
|
out += mdlen;
|
||||||
outlen -= mdlen;
|
outlen -= mdlen;
|
||||||
} else {
|
} else {
|
||||||
if(!hmac_sha512(data, sizeof data, secret, secretlen, hash))
|
if(!hmac_sha512(secret, secretlen, data, sizeof data, hash))
|
||||||
return false;
|
return false;
|
||||||
memcpy(out, hash, outlen);
|
memcpy(out, hash, outlen);
|
||||||
out += outlen;
|
out += outlen;
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@ bool add_edge_h(connection_t *c, const char *request) {
|
||||||
} else {
|
} else {
|
||||||
logger(DEBUG_PROTOCOL, LOG_WARNING, "%s:%d %s -> %s - got edge we know from older version? (%d.%d)",
|
logger(DEBUG_PROTOCOL, LOG_WARNING, "%s:%d %s -> %s - got edge we know from older version? (%d.%d)",
|
||||||
__FUNCTION__, __LINE__, e->from->name, e->to->name, c->protocol_major, c->protocol_minor);
|
__FUNCTION__, __LINE__, e->from->name, e->to->name, c->protocol_major, c->protocol_minor);
|
||||||
|
sockaddrfree(&local_address);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ splay_tree_t *subnet_tree;
|
||||||
|
|
||||||
/* Subnet lookup cache */
|
/* Subnet lookup cache */
|
||||||
|
|
||||||
hash_t *ipv4_cache;
|
static hash_t *ipv4_cache;
|
||||||
hash_t *ipv6_cache;
|
static hash_t *ipv6_cache;
|
||||||
hash_t *mac_cache;
|
static hash_t *mac_cache;
|
||||||
|
|
||||||
void subnet_cache_flush(void) {
|
void subnet_cache_flush(void) {
|
||||||
hash_clear(ipv4_cache);
|
hash_clear(ipv4_cache);
|
||||||
|
|
|
||||||
|
|
@ -401,11 +401,8 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) {
|
||||||
len -= result;
|
len -= result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subnet->weight != DEFAULT_WEIGHT) {
|
if (subnet->weight != DEFAULT_WEIGHT)
|
||||||
snprintf(netstr, len, "#%d", subnet->weight);
|
snprintf(netstr, len, "#%d", subnet->weight);
|
||||||
netstr += result;
|
|
||||||
len -= result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue