- bool result = send_request(c, "%d %d %d %d %d %s", METAKEY,
- cipher_get_nid(&c->outcipher),
- digest_get_nid(&c->outdigest), c->outmaclength,
- c->outcompression, hexkey);
-
- c->status.encryptout = true;
- return result;
+ x = send_request(c, "%d %d %d %d %d %s", METAKEY,
+ c->outcipher ? c->outcipher->nid : 0,
+ c->outdigest ? c->outdigest->type : 0, c->outmaclength,
+ c->outcompression, buffer);
+
+ /* Further outgoing requests are encrypted with the key we just generated */
+
+ if(c->outcipher) {
+ if(!EVP_EncryptInit(c->outctx, c->outcipher,
+ (unsigned char *)c->outkey + len - c->outcipher->key_len,
+ (unsigned char *)c->outkey + len - c->outcipher->key_len -
+ c->outcipher->iv_len)) {
+ logger(LOG_ERR, _("Error during initialisation of cipher for %s (%s): %s"),
+ c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
+ return false;
+ }
+
+ c->status.encryptout = true;
+ }
+
+ return x;