X-Git-Url: https://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_crypt.c;h=59d75d788a5493fb1c9d2c6d624f8085d2691a0b;hb=5d278740dd936d961e745cd37d7a60aa4a7659ac;hp=680406fc3b60b62a232178ad767c893cc31e0b6a;hpb=096f193c98ffbe23686f10c834b2c42092b65954;p=openssl-gost%2Fengine.git diff --git a/gost_crypt.c b/gost_crypt.c index 680406f..59d75d7 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -365,12 +365,12 @@ static void gost_cnt_next(void *ctx, unsigned char *iv, unsigned char *buf) int gost_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { - OPENSSL_assert(inl % 8 == 0); unsigned char b[8]; const unsigned char *in_ptr = in; unsigned char *out_ptr = out; int i; struct ossl_gost_cipher_ctx *c = ctx->cipher_data; + OPENSSL_assert(inl % 8 == 0); if (ctx->encrypt) { while (inl > 0) { for (i = 0; i < 8; i++) { @@ -558,7 +558,52 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) } else { return 0; } +#ifdef EVP_CTRL_SET_SBOX + case EVP_CTRL_SET_SBOX: + if (ptr) { + struct ossl_gost_cipher_ctx *c = ctx->cipher_data; + int nid; + int cur_meshing; + int ret; + if (c == NULL) { + return -1; + } + + if (c->count != 0) { + return -1; + } + + nid = OBJ_txt2nid(ptr); + if (nid == NID_undef) { + return 0; + } + + cur_meshing = c->key_meshing; + ret = gost_cipher_set_param(c, nid); + c->key_meshing = cur_meshing; + return ret; + } else { + return 0; + } +#endif +#ifdef EVP_CTRL_KEY_MESH + case EVP_CTRL_KEY_MESH: + { + struct ossl_gost_cipher_ctx *c = ctx->cipher_data; + + if (c == NULL) { + return -1; + } + + if (c->count != 0) { + return -1; + } + + c->key_meshing = arg; + return 1; + } +#endif default: GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND); @@ -649,7 +694,13 @@ 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; + tmp.value.octet_string = gcp->iv; + tmp.type = V_ASN1_OCTET_STRING; + EVP_CIPHER_get_asn1_iv(ctx, &tmp); + } GOST_CIPHER_PARAMS_free(gcp);