- old = avl_search(active_tree, cl);
- if(old)
- {
- syslog(LOG_ERR, _("%s is listening on %s:%hd, which is already in use by %s!"),
- cl->name, cl->hostname, cl->port, old->name);
- return -1;
- }
-
- /* Activate this connection */
+ We do not use one of the PKCS padding schemes here.
+ This is allowed, because we encrypt a totally random string
+ with a length equal to that of the modulus of the RSA key.
+ */
+
+ if(RSA_public_encrypt(len, c->outkey, buffer, c->rsa_key, RSA_NO_PADDING) != len)
+ {
+ syslog(LOG_ERR, _("Error during encryption of meta key for %s (%s)"), c->name, c->hostname);
+ free(buffer);
+ return -1;
+ }
+cp
+ /* Convert the encrypted random data to a hexadecimal formatted string */
+
+ bin2hex(buffer, buffer, len);
+ buffer[len*2] = '\0';