From patchwork Sat Apr 18 17:37:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Mueller X-Patchwork-Id: 6237411 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9DFF9F1C4 for ; Sat, 18 Apr 2015 17:38:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 114B3203C1 for ; Sat, 18 Apr 2015 17:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFD65203C0 for ; Sat, 18 Apr 2015 17:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932112AbbDRRib (ORCPT ); Sat, 18 Apr 2015 13:38:31 -0400 Received: from mail.eperm.de ([89.247.134.16]:34195 "EHLO mail.eperm.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbbDRRia (ORCPT ); Sat, 18 Apr 2015 13:38:30 -0400 Received: from myon.chronox.de (unknown [75.144.245.226]) by mail.eperm.de (Postfix) with ESMTPSA id 1C5D02A003B; Sat, 18 Apr 2015 19:38:28 +0200 (CEST) From: Stephan Mueller To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org Subject: [PATCH v3 3/3] crypto: drbg - leave cipher handles operational Date: Sat, 18 Apr 2015 19:37 +0200 Message-ID: <6244692.WBb0ZOZ1TI@myon.chronox.de> User-Agent: KMail/4.14.6 (Linux/3.19.3-200.fc21.x86_64; KDE/4.14.6; x86_64; ; ) In-Reply-To: <1702481.h2hMdNkdaF@myon.chronox.de> References: <1702481.h2hMdNkdaF@myon.chronox.de> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As the DRBG does not operate on shadow copies of the DRBG instance any more, the cipher handles only need to be allocated once during initalization time and deallocated during uninstantiate time. Signed-off-by: Stephan Mueller --- crypto/drbg.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crypto/drbg.c b/crypto/drbg.c index 3683bb3..1ceb76c 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1249,11 +1249,6 @@ static int drbg_generate(struct drbg_state *drbg, if ((drbg_max_requests(drbg)) < drbg->reseed_ctr) drbg->seeded = false; - /* allocate cipher handle */ - len = drbg->d_ops->crypto_init(drbg); - if (len) - goto err; - if (drbg->pr || !drbg->seeded) { pr_devel("DRBG: reseeding before generation (prediction " "resistance: %s, state %s)\n", @@ -1325,7 +1320,6 @@ static int drbg_generate(struct drbg_state *drbg, */ len = 0; err: - drbg->d_ops->crypto_fini(drbg); return len; } @@ -1424,9 +1418,10 @@ static int drbg_instantiate(struct drbg_state *drbg, struct drbg_string *pers, if (drbg->d_ops->crypto_init(drbg)) goto err; ret = drbg_seed(drbg, pers, false); - drbg->d_ops->crypto_fini(drbg); - if (ret) + if (ret) { + drbg->d_ops->crypto_fini(drbg); goto err; + } mutex_unlock(&drbg->drbg_mutex); return 0; @@ -1450,6 +1445,7 @@ unlock: static int drbg_uninstantiate(struct drbg_state *drbg) { mutex_lock(&drbg->drbg_mutex); + drbg->d_ops->crypto_fini(drbg); drbg_dealloc_state(drbg); /* no scrubbing of test_data -- this shall survive an uninstantiate */ mutex_unlock(&drbg->drbg_mutex);