- if(debug_lvl >= DEBUG_SCARY_THINGS)
- {
- bin2hex(cl->cipher_outkey, buffer, len);
- buffer[len*2] = '\0';
- syslog(LOG_DEBUG, _("Generated random meta key (unencrypted): %s"), buffer);
- }
-
- /* Encrypt the random data */
-
- if(RSA_public_encrypt(len, cl->cipher_outkey, buffer, cl->rsa_key, RSA_NO_PADDING) != len) /* NO_PADDING because the message size equals the RSA key size and it is totally random */
- {
- syslog(LOG_ERR, _("Error during encryption of meta key for %s (%s)"), cl->name, cl->hostname);
- free(buffer);
- return -1;
- }
-cp
- /* Convert the encrypted random data to a hexadecimal formatted string */
-
- bin2hex(buffer, buffer, len);
- buffer[len*2] = '\0';
-
- /* Send the meta key */
-
- x = send_request(cl, "%d %s", METAKEY, buffer);
- free(buffer);
-
- /* Further outgoing requests are encrypted with the key we just generated */
-
- EVP_EncryptInit(cl->cipher_outctx, EVP_bf_cfb(),
- cl->cipher_outkey + len - EVP_bf_cfb()->key_len,
- cl->cipher_outkey + len - EVP_bf_cfb()->key_len - EVP_bf_cfb()->iv_len);
-
- cl->status.encryptout = 1;