]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Get ASN.1 IV using public functions
authorRichard Levitte <richard@levitte.org>
Wed, 17 Feb 2016 11:32:16 +0000 (12:32 +0100)
committerRichard Levitte <richard@levitte.org>
Wed, 17 Feb 2016 11:32:16 +0000 (12:32 +0100)
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

index 259939dde80814ad86588f0c406a0da9a5690ca3..8132a1eaaffee8b3e899bbae60b362dc5d221113 100644 (file)
@@ -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);