/*
protocol_auth.c -- handle the meta-protocol, authentication
Copyright (C) 1999-2005 Ivo Timmermans,
/*
protocol_auth.c -- handle the meta-protocol, authentication
Copyright (C) 1999-2005 Ivo Timmermans,
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
memcpy(hashbuf, data, 18);
memcpy(hashbuf + 18, fingerprint, sizeof(hashbuf) - 18);
sha512(hashbuf, sizeof(hashbuf), cookie);
memcpy(hashbuf, data, 18);
memcpy(hashbuf + 18, fingerprint, sizeof(hashbuf) - 18);
sha512(hashbuf, sizeof(hashbuf), cookie);
- fgets(buf, sizeof(buf), f);
+
+ if(!fgets(buf, sizeof(buf), f)) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Could not read invitation file %s\n", cookie);
+ return false;
+ }
+
if(!read_host_config(c->config_tree, c->name, false)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, c->name);
if(!read_host_config(c->config_tree, c->name, false)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, c->name);
- if(!(c->outdigest = digest_open_by_name("sha256", -1))) {
+ if(!digest_open_by_name(&c->outdigest, "sha256", DIGEST_ALGO_SIZE)) {
+ cipher_close(&c->outcipher);
- if(!cipher_set_key_from_rsa(c->outcipher, key, len, true)) {
+ if(!cipher_set_key_from_rsa(&c->outcipher, key, len, true)) {
/* Send the meta key */
bool result = send_request(c, "%d %d %d %d %d %s", METAKEY,
/* Send the meta key */
bool result = send_request(c, "%d %d %d %d %d %s", METAKEY,
- cipher_get_nid(c->outcipher),
- digest_get_nid(c->outdigest), c->outmaclength,
+ cipher_get_nid(&c->outcipher),
+ digest_get_nid(&c->outdigest), c->outmaclength,
c->outcompression, hexkey);
c->status.encryptout = true;
c->outcompression, hexkey);
c->status.encryptout = true;
- if(!(c->incipher = cipher_open_by_nid(cipher)) || !cipher_set_key_from_rsa(c->incipher, key, len, false)) {
+ if(!cipher_open_by_nid(&c->incipher, cipher) || !cipher_set_key_from_rsa(&c->incipher, key, len, false)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error during initialisation of cipher from %s (%s)", c->name, c->hostname);
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Error during initialisation of cipher from %s (%s)", c->name, c->hostname);
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Error during initialisation of digest from %s (%s)", c->name, c->hostname);
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Error during initialisation of digest from %s (%s)", c->name, c->hostname);
return false;
}
- if(!digest_create(c->indigest, c->mychallenge, len, digest)) {
+ if(!digest_create(&c->indigest, c->mychallenge, len, digest)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply length");
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply length");
return false;
}
- if(!digest_verify(c->outdigest, c->hischallenge, rsa_size(c->rsa), hishash)) {
+ if(!digest_verify(&c->outdigest, c->hischallenge, rsa_size(c->rsa), hishash)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply");
return false;
}
logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply");
return false;
}
}
return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (experimental ? (PROT_MINOR << 24) : 0));
}
return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (experimental ? (PROT_MINOR << 24) : 0));
- for splay_each(node_t, n, node_tree) {
- for splay_each(subnet_t, s, n->subnet_tree) {
+ for splay_each(node_t, n, &node_tree) {
+ for splay_each(subnet_t, s, &n->subnet_tree) {