X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fevp%2Fbio_enc.c;h=629bf4b95d9675db4d2e0fb21a548af3ccc3a0bc;hb=8d5b4ee1cab7cd02f9fe246fb60d7d018a315a86;hp=9aaba043c9263db6a8c50c30fb0dddc82f7dc893;hpb=ec577822f95a8bca0023c5c77cef1a4916822d4a;p=oweals%2Fopenssl.git diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c index 9aaba043c9..629bf4b95d 100644 --- a/crypto/evp/bio_enc.c +++ b/crypto/evp/bio_enc.c @@ -62,7 +62,6 @@ #include #include -#ifndef NOPROTO static int enc_write(BIO *h,char *buf,int num); static int enc_read(BIO *h,char *buf,int size); /*static int enc_puts(BIO *h,char *str); */ @@ -70,16 +69,7 @@ static int enc_read(BIO *h,char *buf,int size); static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); static int enc_new(BIO *h); static int enc_free(BIO *data); -#else -static int enc_write(); -static int enc_read(); -/*static int enc_puts(); */ -/*static int enc_gets(); */ -static long enc_ctrl(); -static int enc_new(); -static int enc_free(); -#endif - +static long enc_callback_ctrl(BIO *h,int cmd,void (*fp)()); #define ENC_BLOCK_SIZE (1024*4) typedef struct enc_struct @@ -103,6 +93,7 @@ static BIO_METHOD methods_enc= enc_ctrl, enc_new, enc_free, + enc_callback_ctrl, }; BIO_METHOD *BIO_f_cipher(void) @@ -195,9 +186,11 @@ static int enc_read(BIO *b, char *out, int outl) ctx->ok=i; ctx->buf_off=0; } - else + else + { ret=(ret == 0)?i:ret; - break; + break; + } } else { @@ -205,13 +198,19 @@ static int enc_read(BIO *b, char *out, int outl) (unsigned char *)ctx->buf,&ctx->buf_len, (unsigned char *)&(ctx->buf[8]),i); ctx->cont=1; + /* Note: it is possible for EVP_CipherUpdate to + * decrypt zero bytes because this is or looks like + * the final block: if this happens we should retry + * and either read more data or decrypt the final + * block + */ + if(ctx->buf_len == 0) continue; } if (ctx->buf_len <= outl) i=ctx->buf_len; else i=outl; - if (i <= 0) break; memcpy(out,ctx->buf,i); ret+=i; @@ -371,6 +370,20 @@ again: return(ret); } +static long enc_callback_ctrl(BIO *b, int cmd, void (*fp)()) + { + long ret=1; + + if (b->next_bio == NULL) return(0); + switch (cmd) + { + default: + ret=BIO_callback_ctrl(b->next_bio,cmd,fp); + break; + } + return(ret); + } + /* void BIO_set_cipher_ctx(b,c) BIO *b;