Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1715367rdb; Mon, 2 Oct 2023 20:44:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFodMDWqyYJmJDyJZJjKvnmHjib43nDu6jKXCVdvOeZNQgHv21ACIXxuAowqss46ywegpHk X-Received: by 2002:a05:6a00:80e:b0:666:e1f4:5153 with SMTP id m14-20020a056a00080e00b00666e1f45153mr13634511pfk.0.1696304683994; Mon, 02 Oct 2023 20:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696304683; cv=none; d=google.com; s=arc-20160816; b=vCZQ5UXbpooaoOJJIs0qmDjCLup2/jv51YwHySdT6N2Sau8YGaq+7CUVPK+T7jIwCz qRC9wSn3Nd6xuuFOn3iUiKenNOHy5B9Jco7BE941UW/8vpNhbZ2TIaQB6w2mmi+L9bX2 Bd1ue2Ksyv2xITfZnx+wXhKtdHAA1alP9XWVDm4GRESg+B0ym0980CdR0/xH0JqiZs+u bM8JmoGldwDr+30bREVEKCpcFHxp87B9mtq88ZeDS/LooiK6SL/9VGUkD3MY15oios4r YSuTVNFzcbQug1bhxETDs5055EmV7U7u4nY0tsnMrWX3yP/GLV3EATVEJOMpMb+kUrGV Iw1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iNGtUjoZiFS3QAoEQa5YycDkY7g6biJhLZnTZgYk+oc=; fh=l82EBe4859Giv8r8zr9oFIexxRwnYkkBFWiaDDuu954=; b=mxnWfWGBcK7xabJ1F1d/qCMGm9z+dwkviJosuu0RxGJGPcOyQl07CoSWno2X1ed+FZ 3ZWcmnpV+KWEdst+wvWjegH6tVDmiVBr0UZFo+jidOvHsat0CD9Tvvw3XmRdHFIFX0ee Z7+yYBjnIflbiDvYuXwAqPBHfUAdFr/5OULb2TmHOoAJIe8ieMDoeVSsKor59d1BN1rb PjL4SKfHmIP2XQE93OJPjqY8V2z2I999nfCbQDz5/w0WFSga3jM0WZZ4q6qXPBo4LCYc i6VifHCMMlVDoFgeo8Wlt9FxnRzQoZcnsvjnYbNAEK/Qo2yOyrHQnQ8HPi/gvz7YSuTu 64ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id cj5-20020a056a00298500b00690f8edee16si531837pfb.275.2023.10.02.20.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 20:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DE970802393B; Mon, 2 Oct 2023 20:44:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbjJCDom (ORCPT + 99 others); Mon, 2 Oct 2023 23:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjJCDol (ORCPT ); Mon, 2 Oct 2023 23:44:41 -0400 Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD0C1B8 for ; Mon, 2 Oct 2023 20:44:38 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1qnWKo-002wQf-0r; Tue, 03 Oct 2023 11:44:35 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Tue, 03 Oct 2023 11:44:38 +0800 From: Herbert Xu To: Linux Crypto Mailing List Cc: Shinichiro Kawasaki , Herbert Xu Subject: [PATCH 03/16] crypto: essiv - Handle lskcipher spawns Date: Tue, 3 Oct 2023 11:43:20 +0800 Message-Id: <20231003034333.1441826-4-herbert@gondor.apana.org.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003034333.1441826-1-herbert@gondor.apana.org.au> References: <20231003034333.1441826-1-herbert@gondor.apana.org.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 20:44:43 -0700 (PDT) Add code to handle an underlying lskcihper object when grabbing an skcipher spawn. Fixes: 31865c4c4db2 ("crypto: skcipher - Add lskcipher") Signed-off-by: Herbert Xu --- crypto/essiv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crypto/essiv.c b/crypto/essiv.c index f7d4ef4837e5..e63fc6442e32 100644 --- a/crypto/essiv.c +++ b/crypto/essiv.c @@ -442,6 +442,7 @@ static bool essiv_supported_algorithms(const char *essiv_cipher_name, static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) { + struct skcipher_alg_common *skcipher_alg = NULL; struct crypto_attr_type *algt; const char *inner_cipher_name; const char *shash_name; @@ -450,7 +451,6 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) struct crypto_instance *inst; struct crypto_alg *base, *block_base; struct essiv_instance_ctx *ictx; - struct skcipher_alg *skcipher_alg = NULL; struct aead_alg *aead_alg = NULL; struct crypto_alg *_hash_alg; struct shash_alg *hash_alg; @@ -475,7 +475,7 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) mask = crypto_algt_inherited_mask(algt); switch (type) { - case CRYPTO_ALG_TYPE_SKCIPHER: + case CRYPTO_ALG_TYPE_LSKCIPHER: skcipher_inst = kzalloc(sizeof(*skcipher_inst) + sizeof(*ictx), GFP_KERNEL); if (!skcipher_inst) @@ -489,9 +489,10 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) inner_cipher_name, 0, mask); if (err) goto out_free_inst; - skcipher_alg = crypto_spawn_skcipher_alg(&ictx->u.skcipher_spawn); + skcipher_alg = crypto_spawn_skcipher_alg_common( + &ictx->u.skcipher_spawn); block_base = &skcipher_alg->base; - ivsize = crypto_skcipher_alg_ivsize(skcipher_alg); + ivsize = skcipher_alg->ivsize; break; case CRYPTO_ALG_TYPE_AEAD: @@ -574,18 +575,17 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) base->cra_alignmask = block_base->cra_alignmask; base->cra_priority = block_base->cra_priority; - if (type == CRYPTO_ALG_TYPE_SKCIPHER) { + if (type == CRYPTO_ALG_TYPE_LSKCIPHER) { skcipher_inst->alg.setkey = essiv_skcipher_setkey; skcipher_inst->alg.encrypt = essiv_skcipher_encrypt; skcipher_inst->alg.decrypt = essiv_skcipher_decrypt; skcipher_inst->alg.init = essiv_skcipher_init_tfm; skcipher_inst->alg.exit = essiv_skcipher_exit_tfm; - skcipher_inst->alg.min_keysize = crypto_skcipher_alg_min_keysize(skcipher_alg); - skcipher_inst->alg.max_keysize = crypto_skcipher_alg_max_keysize(skcipher_alg); + skcipher_inst->alg.min_keysize = skcipher_alg->min_keysize; + skcipher_inst->alg.max_keysize = skcipher_alg->max_keysize; skcipher_inst->alg.ivsize = ivsize; - skcipher_inst->alg.chunksize = crypto_skcipher_alg_chunksize(skcipher_alg); - skcipher_inst->alg.walksize = crypto_skcipher_alg_walksize(skcipher_alg); + skcipher_inst->alg.chunksize = skcipher_alg->chunksize; skcipher_inst->free = essiv_skcipher_free_instance; @@ -616,7 +616,7 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb) out_free_hash: crypto_mod_put(_hash_alg); out_drop_skcipher: - if (type == CRYPTO_ALG_TYPE_SKCIPHER) + if (type == CRYPTO_ALG_TYPE_LSKCIPHER) crypto_drop_skcipher(&ictx->u.skcipher_spawn); else crypto_drop_aead(&ictx->u.aead_spawn); -- 2.39.2