X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_crypt.c;h=2bede853fd617919f4d83bb239b0f9ffe1ae8692;hb=69040682b1d04049668bb63712458f28a5c448d4;hp=ffb577db84dbae00eee4d700dc1b11c336faf8ed;hpb=9cf021b8f3cc7b0f49ecd2f165bd1864903c90d0;p=openssl-gost%2Fengine.git diff --git a/gost_crypt.c b/gost_crypt.c index ffb577d..2bede85 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -774,10 +774,11 @@ int magma_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out, d[7 - i] = in_ptr[i]; } gostdecrypt(&(c->cctx), d, b); + memcpy(d, in_ptr, 8); for (i = 0; i < 8; i++) { out_ptr[i] = iv[i] ^ b[7 - i]; } - memcpy(iv, in_ptr, 8); + memcpy(iv, d, 8); out_ptr += 8; in_ptr += 8; inl -= 8; @@ -866,6 +867,9 @@ static int magma_cipher_do_ctr_acpkm_omac(EVP_CIPHER_CTX *ctx, unsigned char *ou if (in == NULL && inl == 0) /* Final call */ return gost2015_final_call(ctx, c->omac_ctx, MAGMA_MAC_MAX_SIZE, c->tag, magma_cipher_do_ctr); + if (in == NULL) + return -1; + /* As in and out can be the same pointer, process unencrypted here */ if (EVP_CIPHER_CTX_encrypting(ctx)) EVP_DigestSignUpdate(c->omac_ctx, in, inl);