"make update" (partial)
[openssl.git] / engines / ccgost / gost_md.c
index 445679daa9a9f444e3d57e3ad765db45d4f58b92..417e10887bc29c8a5fdc7c1501fb350c1372c1d3 100644 (file)
@@ -59,12 +59,17 @@ int gost_digest_final(EVP_MD_CTX *ctx,unsigned char *md)
 
 int gost_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from) 
        {
-       memcpy(to->md_data,from->md_data,sizeof(struct ossl_gost_digest_ctx));
+       struct ossl_gost_digest_ctx *md_ctx=to->md_data;
+       if (to->md_data && from->md_data) {
+               memcpy(to->md_data,from->md_data,sizeof(struct ossl_gost_digest_ctx));
+               md_ctx->dctx.cipher_ctx=&(md_ctx->cctx);
+       }
        return 1;
        }               
 
 int gost_digest_cleanup(EVP_MD_CTX *ctx) 
        {
+       if (ctx->md_data)
        memset(ctx->md_data,0,sizeof(struct ossl_gost_digest_ctx));
        return 1;
        }