Do no try to pretend we're at the end of anything unless we're at the end
[openssl.git] / crypto / evp / bio_md.c
index 4543d4d..76ff9fe 100644 (file)
@@ -153,7 +153,7 @@ static int md_write(BIO *b, const char *in, int inl)
                {
                if (ret > 0)
                        {
-                       EVP_DigestUpdate(ctx,(unsigned char *)in,
+                       EVP_DigestUpdate(ctx,(const unsigned char *)in,
                                (unsigned int)ret);
                        }
                }
@@ -176,10 +176,11 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
                {
        case BIO_CTRL_RESET:
                if (b->init)
-                       EVP_DigestInit(ctx,ctx->digest);
+                       ret = EVP_DigestInit_ex(ctx,ctx->digest, NULL);
                else
                        ret=0;
-               ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
+               if (ret > 0)
+                       ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
                break;
        case BIO_C_GET_MD:
                if (b->init)
@@ -207,13 +208,14 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
 
        case BIO_C_SET_MD:
                md=ptr;
-               EVP_DigestInit(ctx,md);
-               b->init=1;
+               ret = EVP_DigestInit_ex(ctx,md, NULL);
+               if (ret > 0)
+                       b->init=1;
                break;
        case BIO_CTRL_DUP:
                dbio=ptr;
                dctx=dbio->ptr;
-               EVP_MD_CTX_copy(dctx,ctx);
+               EVP_MD_CTX_copy_ex(dctx,ctx);
                b->init=1;
                break;
        default:
@@ -246,7 +248,7 @@ static int md_gets(BIO *bp, char *buf, int size)
        ctx=bp->ptr;
        if (size < ctx->digest->md_size)
                return(0);
-       EVP_DigestFinal(ctx,(unsigned char *)buf,&ret);
+       EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret);
        return((int)ret);
        }