engines/ccgost: GOST fixes [from master].
[openssl.git] / engines / ccgost / gost89.c
index 7ebae0f71f82a009b53842e785a9da1efe188c35..b0568c6b3c8446e1dd5f1432b90f93f674e42400 100644 (file)
@@ -369,7 +369,13 @@ int gost_mac(gost_ctx *ctx,int mac_len,const unsigned char *data,
                memset(buf2,0,8);
                memcpy(buf2,data+i,data_len-i);
                mac_block(ctx,buffer,buf2);
                memset(buf2,0,8);
                memcpy(buf2,data+i,data_len-i);
                mac_block(ctx,buffer,buf2);
-               }       
+               i+=8;
+               }
+       if (i==8)
+               {
+               memset(buf2,0,8);
+               mac_block(ctx,buffer,buf2);
+               }
        get_mac(buffer,mac_len,mac);
        return 1;
        }
        get_mac(buffer,mac_len,mac);
        return 1;
        }
@@ -389,7 +395,13 @@ int gost_mac_iv(gost_ctx *ctx,int mac_len,const unsigned char *iv,const unsigned
                memset(buf2,0,8);
                memcpy(buf2,data+i,data_len-i);
                mac_block(ctx,buffer,buf2);
                memset(buf2,0,8);
                memcpy(buf2,data+i,data_len-i);
                mac_block(ctx,buffer,buf2);
+               i+=8;
                }       
                }       
+       if (i==8)
+               {
+               memset(buf2,0,8);
+               mac_block(ctx,buffer,buf2);
+               }
        get_mac(buffer,mac_len,mac);
        return 1;
        }
        get_mac(buffer,mac_len,mac);
        return 1;
        }