- const unsigned char *iv, int enc, int paramNID,int mode) {
-struct ossl_gost_cipher_ctx *c=ctx->cipher_data;
-if (!gost_cipher_set_param(c,paramNID)) return 0;
-if (key) gost_key(&(c->cctx),key);
-if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
-memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
-return 1;
-}
-
-/* Initializes EVP_CIPHER_CTX with fixed cryptopro A paramset */
-int gost_cipher_init_cpa(EVP_CIPHER_CTX *ctx, const unsigned char *key,
- const unsigned char *iv, int enc) {
-struct ossl_gost_cipher_ctx *c=ctx->cipher_data;
-gost_init(&(c->cctx),&Gost28147_CryptoProParamSetA);
-c->key_meshing=1;
-c->count=0;
-gost_key(&(c->cctx),key);
-if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
-memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
-return 1;
-}
-/* Initializes EVP_CIPHER_CTX with fixed vizir paramset */
-int gost_cipher_init_vizir(EVP_CIPHER_CTX *ctx, const unsigned char *key,
- const unsigned char *iv, int enc) {
-struct ossl_gost_cipher_ctx *c=ctx->cipher_data;
-gost_init(&(c->cctx),&GostR3411_94_CryptoProParamSet);
-c->key_meshing=0;
-c->count=0;
-gost_key(&(c->cctx),key);
-
-if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
-memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
-return 1;
-}
+ const unsigned char *iv, int enc, int paramNID,int mode)
+ {
+ struct ossl_gost_cipher_ctx *c=ctx->cipher_data;
+ if (ctx->app_data == NULL)
+ {
+ if (!gost_cipher_set_param(c,paramNID)) return 0;
+ ctx->app_data = ctx->cipher_data;
+ }
+ if (key) gost_key(&(c->cctx),key);
+ if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
+ memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
+ return 1;
+ }
+
+static int gost_cipher_init_cpa(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ const unsigned char *iv, int enc)
+ {
+ struct ossl_gost_cipher_ctx *c=ctx->cipher_data;
+ gost_init(&(c->cctx),&Gost28147_CryptoProParamSetA);
+ c->key_meshing=1;
+ c->count=0;
+ if(key) gost_key(&(c->cctx),key);
+ if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
+ memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
+ return 1;
+ }