From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933237AbbFIMXz (ORCPT ); Tue, 9 Jun 2015 08:23:55 -0400 Received: from mail.eperm.de ([89.247.134.16]:46168 "EHLO mail.eperm.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932874AbbFIMXv (ORCPT ); Tue, 9 Jun 2015 08:23:51 -0400 From: Stephan Mueller To: Herbert Xu Cc: Ted Tso , andreas.steffen@strongswan.org, sandyinchina@gmail.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] crypto: drbg - Use callback API for random readiness Date: Tue, 09 Jun 2015 14:23:39 +0200 Message-ID: <3448831.Xm980FM7Uq@tachyon.chronox.de> User-Agent: KMail/4.14.7 (Linux/4.0.4-303.fc22.x86_64; KDE/4.14.8; x86_64; ; ) In-Reply-To: References: <20150609101830.GA10521@gondor.apana.org.au> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Dienstag, 9. Juni 2015, 18:19:41 schrieb Herbert Xu: Hi Herbert, first of all, thanks a lot for your help. I have tested the patch set. ... > /* > * DRBG instantiation function as required by SP800-90A - this function > * sets up the DRBG handle, performs the initial seeding and all sanity > @@ -1517,15 +1531,23 @@ static int drbg_instantiate(struct drbg_state *drbg, > struct drbg_string *pers, if (drbg->d_ops->crypto_init(drbg)) > goto err; > > + ret = drbg_prepare_hrng(drbg); > + if (ret) > + goto free_everything; > + > + if (IS_ERR(drbg->jent)) { > + ret = PTR_ERR(drbg->jent); > + drbg->jent = NULL; > + goto free_everything; I am wondering about the error here. The Jitter RNG has in its init function a test to see whether the RNG really works on the hardware as there are still systems out there that have no high-res timer (e.g. I have seen that on old Android phones). If the Jitter RNG detects that the system is not appropriate, it will not register. On such systems, the error here would imply that the DRBG does not instantiate and we have no stdrng. > + } > + > reseed = false; > } > > ret = drbg_seed(drbg, pers, reseed); > > - if (ret && !reseed) { > - drbg->d_ops->crypto_fini(drbg); > - goto err; > - } > + if (ret && !reseed) > + goto free_everything; > > mutex_unlock(&drbg->drbg_mutex); > return ret; > @@ -1535,6 +1557,11 @@ err: > unlock: > mutex_unlock(&drbg->drbg_mutex); > return ret; > + > +free_everything: > + mutex_unlock(&drbg->drbg_mutex); > + drbg_uninstantiate(drbg); > + return ret; > } > -- Ciao Stephan