Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1608493

Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver

From Stephan Müller <smueller@chronox.de>
Newsgroups linux.kernel
Subject Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver
Date 2017-03-24 15:40 +0100
Message-ID <toyxI-2SC-9@gated-at.bofh.it> (permalink)
References <toyo1-2Pm-3@gated-at.bofh.it> <toyo1-2Pm-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 15:30 +0100
  Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Stephan Müller <smueller@chronox.de> - 2017-03-24 15:40 +0100
    Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Stephan Müller <smueller@chronox.de> - 2017-03-24 15:50 +0100
      Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 16:00 +0100
      Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Stephan Müller <smueller@chronox.de> - 2017-03-24 16:00 +0100
      Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 16:00 +0100
    Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 15:50 +0100
  Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-03-24 16:30 +0100
    Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 16:50 +0100
      Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-03-24 17:20 +0100
        Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 17:30 +0100
          Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-03-24 17:50 +0100
            Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-24 18:10 +0100

csiph-web