#include "netutl.h"
#include "node.h"
#include "protocol.h"
-#include "rsa.h"
#include "utils.h"
#include "xalloc.h"
bool send_id(connection_t *c) {
cp();
+ gettimeofday(&c->start, NULL);
+
return send_request(c, "%d %s %d", ID, myself->connection->name,
myself->connection->protocol_version);
}
bool send_metakey(connection_t *c) {
char *buffer;
- unsigned int len;
+ int len;
bool x;
cp();
- len = get_rsa_size(&c->rsa_key);
+ len = RSA_size(c->rsa_key);
/* Allocate buffers for the meta key */
with a length equal to that of the modulus of the RSA key.
*/
- if(!rsa_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, &c->rsa_key)) {
+ if(RSA_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, c->rsa_key, RSA_NO_PADDING) != len) {
logger(LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
c->name, c->hostname);
return false;
return false;
}
- len = get_rsa_size(&myself->connection->rsa_key);
+ len = RSA_size(myself->connection->rsa_key);
/* Check if the length of the meta key is all right */
/* Decrypt the meta key */
- if(!rsa_private_decrypt(len, (unsigned char *)buffer, (unsigned char *)c->inkey, &myself->connection->rsa_key)) {
- logger(LOG_ERR, _("Error during encryption of meta key for %s (%s)"), c->name, c->hostname);
+ 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, _("Error during encryption of meta key for %s (%s)"),
+ c->name, c->hostname);
return false;
}
/* CHECKME: what is most reasonable value for len? */
- len = get_rsa_size(&c->rsa_key);
+ len = RSA_size(c->rsa_key);
/* Allocate buffers for the challenge */
return false;
}
- len = get_rsa_size(&myself->connection->rsa_key);
+ len = RSA_size(myself->connection->rsa_key);
/* Check if the length of the challenge is all right */
/* Calculate the hash from the challenge we received */
if(!EVP_DigestInit(&ctx, c->indigest)
- || !EVP_DigestUpdate(&ctx, c->mychallenge, get_rsa_size(&myself->connection->rsa_key))
+ || !EVP_DigestUpdate(&ctx, c->mychallenge, RSA_size(myself->connection->rsa_key))
|| !EVP_DigestFinal(&ctx, (unsigned char *)hash, NULL)) {
logger(LOG_ERR, _("Error during calculation of response for %s (%s): %s"),
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
/* Calculate the hash from the challenge we sent */
if(!EVP_DigestInit(&ctx, c->outdigest)
- || !EVP_DigestUpdate(&ctx, c->hischallenge, get_rsa_size(&c->rsa_key))
+ || !EVP_DigestUpdate(&ctx, c->hischallenge, RSA_size(c->rsa_key))
|| !EVP_DigestFinal(&ctx, (unsigned char *)myhash, NULL)) {
logger(LOG_ERR, _("Error during calculation of response from %s (%s): %s"),
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));