/*
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
return send_request(c, "%d %s %d", ID, myself->connection->name,
myself->connection->protocol_version);
}
return send_request(c, "%d %s %d", ID, myself->connection->name,
myself->connection->protocol_version);
}
if(sscanf(c->buffer, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) {
if(sscanf(c->buffer, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) {
- logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ID", c->name,
+ logger(LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name,
- logger(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ID", c->name,
+ logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ID", c->name,
- logger(LOG_ERR, _("Peer %s is %s instead of %s"), c->hostname, name,
+ logger(LOG_ERR, "Peer %s is %s instead of %s", c->hostname, name,
- logger(LOG_ERR, _("Peer %s had unknown identity (%s)"), c->hostname,
+ logger(LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname,
c->outkey = xrealloc(c->outkey, len);
if(!c->outctx)
c->outctx = xmalloc_and_zero(sizeof(*c->outctx));
c->outkey = xrealloc(c->outkey, len);
if(!c->outctx)
c->outctx = xmalloc_and_zero(sizeof(*c->outctx));
/* Copy random data to the buffer */
RAND_pseudo_bytes((unsigned char *)c->outkey, len);
/* Copy random data to the buffer */
RAND_pseudo_bytes((unsigned char *)c->outkey, len);
*/
if(RSA_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, c->rsa_key, RSA_NO_PADDING) != len) {
*/
if(RSA_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, c->rsa_key, RSA_NO_PADDING) != len) {
(unsigned char *)c->outkey + len - c->outcipher->key_len,
(unsigned char *)c->outkey + len - c->outcipher->key_len -
c->outcipher->iv_len)) {
(unsigned char *)c->outkey + len - c->outcipher->key_len,
(unsigned char *)c->outkey + len - c->outcipher->key_len -
c->outcipher->iv_len)) {
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
int cipher, digest, maclength, compression;
int len;
int cipher, digest, maclength, compression;
int len;
if(sscanf(c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, buffer) != 5) {
if(sscanf(c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, buffer) != 5) {
- logger(LOG_ERR, _("Got bad %s from %s (%s)"), "METAKEY", c->name,
+ logger(LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name,
- logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name, c->hostname, "wrong keylength");
+ logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong keylength");
/* Decrypt the meta key */
if(RSA_private_decrypt(len, (unsigned char *)buffer, (unsigned char *)c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) { /* See challenge() */
/* Decrypt the meta key */
if(RSA_private_decrypt(len, (unsigned char *)buffer, (unsigned char *)c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) { /* See challenge() */
- logger(LOG_ERR, _("%s (%s) uses unknown cipher!"), c->name, c->hostname);
+ logger(LOG_ERR, "%s (%s) uses unknown cipher!", c->name, c->hostname);
(unsigned char *)c->inkey + len - c->incipher->key_len,
(unsigned char *)c->inkey + len - c->incipher->key_len -
c->incipher->iv_len)) {
(unsigned char *)c->inkey + len - c->incipher->key_len,
(unsigned char *)c->inkey + len - c->incipher->key_len -
c->incipher->iv_len)) {
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
- logger(LOG_ERR, _("Node %s (%s) uses unknown digest!"), c->name, c->hostname);
+ logger(LOG_ERR, "Node %s (%s) uses unknown digest!", c->name, c->hostname);
- logger(LOG_ERR, _("%s (%s) uses bogus MAC length!"), c->name, c->hostname);
+ logger(LOG_ERR, "%s (%s) uses bogus MAC length!", c->name, c->hostname);
- logger(LOG_ERR, _("Got bad %s from %s (%s)"), "CHALLENGE", c->name,
+ logger(LOG_ERR, "Got bad %s from %s (%s)", "CHALLENGE", c->name,
- logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
+ logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name,
/* Calculate the hash from the challenge we received */
if(!EVP_DigestInit(&ctx, c->indigest)
|| !EVP_DigestUpdate(&ctx, c->mychallenge, RSA_size(myself->connection->rsa_key))
|| !EVP_DigestFinal(&ctx, (unsigned char *)hash, NULL)) {
/* Calculate the hash from the challenge we received */
if(!EVP_DigestInit(&ctx, c->indigest)
|| !EVP_DigestUpdate(&ctx, c->mychallenge, RSA_size(myself->connection->rsa_key))
|| !EVP_DigestFinal(&ctx, (unsigned char *)hash, NULL)) {
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
- logger(LOG_ERR, _("Got bad %s from %s (%s)"), "CHAL_REPLY", c->name,
+ logger(LOG_ERR, "Got bad %s from %s (%s)", "CHAL_REPLY", c->name,
/* Check if the length of the hash is all right */
if(strlen(hishash) != c->outdigest->md_size * 2) {
/* Check if the length of the hash is all right */
if(strlen(hishash) != c->outdigest->md_size * 2) {
- logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
- c->hostname, _("wrong challenge reply length"));
+ logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name,
+ c->hostname, "wrong challenge reply length");
if(!EVP_DigestInit(&ctx, c->outdigest)
|| !EVP_DigestUpdate(&ctx, c->hischallenge, RSA_size(c->rsa_key))
|| !EVP_DigestFinal(&ctx, (unsigned char *)myhash, NULL)) {
if(!EVP_DigestInit(&ctx, c->outdigest)
|| !EVP_DigestUpdate(&ctx, c->hischallenge, RSA_size(c->rsa_key))
|| !EVP_DigestFinal(&ctx, (unsigned char *)myhash, NULL)) {
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false;
}
/* Verify the incoming hash with the calculated hash */
if(memcmp(hishash, myhash, c->outdigest->md_size)) {
/* Verify the incoming hash with the calculated hash */
if(memcmp(hishash, myhash, c->outdigest->md_size)) {
- logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
- c->hostname, _("wrong challenge reply"));
+ logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name,
+ c->hostname, "wrong challenge reply");
ifdebug(SCARY_THINGS) {
bin2hex(myhash, hishash, SHA_DIGEST_LENGTH);
hishash[SHA_DIGEST_LENGTH * 2] = '\0';
ifdebug(SCARY_THINGS) {
bin2hex(myhash, hishash, SHA_DIGEST_LENGTH);
hishash[SHA_DIGEST_LENGTH * 2] = '\0';
- return send_request(c, "%d %s %d %lx", ACK, myport, c->estimated_weight, c->options);
+ return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, c->options);
- cp();
-
- if(sscanf(c->buffer, "%*d " MAX_STRING " %d %lx", hisport, &weight, &options) != 3) {
- logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ACK", c->name,
+ if(sscanf(c->buffer, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) {
+ logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name,
- ifdebug(CONNECTIONS) logger(LOG_DEBUG, _("Established a second connection with %s (%s), closing old connection"),
+ ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Established a second connection with %s (%s), closing old connection",
n->name, n->hostname);
terminate_connection(n->connection, false);
/* Run graph algorithm to purge key and make sure up/down scripts are rerun with new IP addresses and stuff */
n->name, n->hostname);
terminate_connection(n->connection, false);
/* Run graph algorithm to purge key and make sure up/down scripts are rerun with new IP addresses and stuff */
- ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection with %s (%s) activated"), c->name,
+ ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection with %s (%s) activated", c->name,