From d0e97865ae0499feb63e751b4cb2478c44d93247 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 17 Feb 2016 12:32:16 +0100 Subject: [PATCH] Get ASN.1 IV using public functions The function EVP_CIPHER_get_asn1_iv(), which is the default get_asn1_params implementation, can be used to set the "original IV". No need to reach into the inside of EVP_CIPHER_CTX, which makes it much more future proof. --- gost_crypt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gost_crypt.c b/gost_crypt.c index 259939d..8132a1e 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -649,7 +649,12 @@ int gost89_get_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params) GOST_CIPHER_PARAMS_free(gcp); return -1; } - memcpy(ctx->oiv, gcp->iv->data, len); + + { + ASN1_TYPE tmp; + ASN1_TYPE_set(&tmp, V_ASN1_OCTET_STRING, gcp->iv); + EVP_CIPHER_get_asn1_iv(ctx, &tmp); + } GOST_CIPHER_PARAMS_free(gcp); -- 2.39.2