PR: 2586
[openssl.git] / engines / ccgost / gost_crypt.c
index 44f4e49bc98014cf8ccc90b26bcacd4e77d7e1cc..565146aad5146b4c1ce99f671848f8fc4d032c13 100644 (file)
@@ -7,6 +7,7 @@
  *          Requires OpenSSL 0.9.9 for compilation                    *
  **********************************************************************/
 #include <string.h>
+#include <openssl/crypto.h>
 #include "gost89.h"
 #include <openssl/rand.h>
 #include "e_gost_err.h"
@@ -299,7 +300,7 @@ int gost_cipher_do_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out,
        if (i<inl)
                {
                gost_crypt_mesh(ctx->cipher_data,ctx->iv,ctx->buf);
-               if (!ctx->encrypt) memcpy(ctx->buf+8,in_ptr,j);
+               if (!ctx->encrypt) memcpy(ctx->buf+8,in_ptr,inl-i);
                for (j=0;i<inl;j++,i++)
                        {
                        out_ptr[j]=ctx->buf[j]^in_ptr[j];
@@ -495,7 +496,8 @@ int  gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx,ASN1_TYPE *params)
 int gost_imit_init_cpa(EVP_MD_CTX *ctx)
        {
        struct ossl_gost_imit_ctx *c = ctx->md_data;
-       memset(c->buffer,0,16);
+       memset(c->buffer,0,sizeof(c->buffer));
+       memset(c->partial_block,0,sizeof(c->partial_block));
        c->count = 0;
        c->bytes_left=0;
        c->key_meshing=1;