[Dovecot] Plugin like zlib
Timo Sirainen
tss at iki.fi
Sat Mar 13 23:11:18 EET 2010
On Thu, 2010-03-11 at 19:33 -0300, Alex Baule wrote:
> do {
> ret = read(zstream->fd ,crypttext, size);
> fprintf(zstream->debug,"DENTRO DA READ RET = %d -- ERRNO = %d -- STR
> = |%s|\n", ret, errno, strerror(errno));
> if(ret > 0){
> EVP_DecryptUpdate(&ctx, plaintext, &plain_len, crypttext, ret);
> memcpy(stream->w_buffer + stream->pos , plaintext, plain_len);
>
> bzero (plaintext, DEFAULT_MAX_BUFFER_SIZE);
> EVP_DecryptFinal(&ctx, plaintext, &plain_len_final);
> memcpy(stream->w_buffer + stream->pos + plain_len , plaintext,
> plain_len_final);
I think you should do some kind of internal buffering here that contains
the unused part of crypttext, and reuse it for next DecryptUpdate().
v1.x's zlib plugin lets zlib library take care of that, so it makes the
code a lot simpler.
Maybe you should look at hg version of v2.0 and its istream-bzlib.c.
That's probably a lot closer to what you need to do. (But note that
there are some other istream changes in v2.0, so you can't just use the
same code with v1.x without some more changes.)
And I don't think you should call EVP_DecryptFinal() until you've seen
EOF from the parent fd?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20100313/d72680c1/attachment.bin
More information about the dovecot
mailing list