public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephan Müller" <smueller@chronox.de>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Kukjin Kim <kgene@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-crypto@vger.kernel.org,
	Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>
Subject: Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver
Date: Fri, 24 Mar 2017 15:37:59 +0100	[thread overview]
Message-ID: <2503592.nlbQnVP8UR@positron.chronox.de> (raw)
In-Reply-To: <20170324142446.31129-2-krzk@kernel.org>

Am Freitag, 24. März 2017, 15:24:44 CET schrieb Krzysztof Kozlowski:

Hi Krzysztof,

> +
> +static int exynos_rng_set_seed(struct exynos_rng_dev *rng,
> +			       const u8 *seed, unsigned int slen)
> +{
> +	int ret, i;
> +	u32 val;
> +
> +	dev_dbg(rng->dev, "Seeding with %u bytes\n", slen);
> +
> +	ret = clk_prepare_enable(rng->clk);
> +	if (ret)
> +		return ret;
> +
> +	if (slen < EXYNOS_RNG_SEED_SIZE) {
> +		dev_warn(rng->dev, "Seed too short (only %u bytes)\n", slen);
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	for (i = 0 ; i < EXYNOS_RNG_SEED_REGS ; i++) {
> +		val = seed[i * 4] << 24;
> +		val |= seed[i * 4 + 1] << 16;
> +		val |= seed[i * 4 + 2] << 8;
> +		val |= seed[i * 4 + 3] << 0;
> +
> +		exynos_rng_writel(rng, val, EXYNOS_RNG_SEED(i));
> +	}
> +
> +	val = exynos_rng_readl(rng, EXYNOS_RNG_STATUS);
> +	if (!(val & EXYNOS_RNG_STATUS_SEED_SETTING_DONE)) {
> +		dev_warn(rng->dev, "Seed setting not finished\n");
> +		ret = -EIO;
> +		goto out;
> +	}
> +
> +	ret = 0;
> +	/* Save seed for suspend */
> +	memcpy(rng->seed_save, seed, slen);

Is this really necessary? If you need to save some seed, shouldn't that be an 
output of the DRNG and not the real seed?

Besides, how do you know that slen is not larger than EXYNOS_RNG_SEED_SIZE?


Ciao
Stephan

  reply	other threads:[~2017-03-24 14:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 14:24 [PATCH 0/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 1/3] " Krzysztof Kozlowski
2017-03-24 14:37   ` Stephan Müller [this message]
2017-03-24 14:43     ` Krzysztof Kozlowski
2017-03-24 14:46       ` Stephan Müller
2017-03-24 14:51         ` Krzysztof Kozlowski
2017-03-24 14:55           ` Stephan Müller
2017-03-24 14:58             ` Krzysztof Kozlowski
2017-03-24 15:26   ` Bartlomiej Zolnierkiewicz
2017-03-24 15:46     ` Krzysztof Kozlowski
2017-03-24 16:11       ` Bartlomiej Zolnierkiewicz
2017-03-24 16:19         ` Krzysztof Kozlowski
2017-03-24 16:45           ` Bartlomiej Zolnierkiewicz
2017-03-24 17:01             ` Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 2/3] ARM: exynos_defconfig: Enable Exynos RNG and user-space crypto API Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 3/3] ARM: multi_v7_defconfig: " Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2503592.nlbQnVP8UR@positron.chronox.de \
    --to=smueller@chronox.de \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=javier@osg.samsung.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=olof@lixom.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox