- logger(LOG_DEBUG, _("Received encrypted %d bytes"), inlen);
- evbuffer_expand(c->buffer->input, c->buffer->input->off + inlen);
- result = EVP_DecryptUpdate(c->inctx, (unsigned char *)c->buffer->input->buffer + c->buffer->input->off, &outlen, (unsigned char *)bufp, inlen);
- if(!result || outlen != inlen) {
- logger(LOG_ERR, _("Error while decrypting metadata from %s (%s): %s"),
- c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
+ size_t outlen = inlen;
+ ifdebug(META) logger(LOG_DEBUG, "Received encrypted %d bytes", inlen);
+
+ if(!cipher_decrypt(&c->incipher, bufp, inlen, buffer_prepare(&c->inbuf, inlen), &outlen, false) || inlen != outlen) {
+ logger(LOG_ERR, "Error while decrypting metadata from %s (%s)",
+ c->name, c->hostname);