All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pan, Miaoqing" <miaoqing-Rm6X0d1/PG5y9aJCnZT0Uw@public.gmane.org>
To: Stephan Mueller
	<smueller-T9tCv8IpfcWELgA04lAiVw@public.gmane.org>,
	Herbert Xu
	<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
Cc: Matt Mackall <mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org>,
	"miaoqing-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org"
	<miaoqing-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	"Valo, Kalle" <kvalo-A+ZNKFmMK5xy9aJCnZT0Uw@public.gmane.org>,
	"linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	ath9k-devel <ath9k-devel-A+ZNKFmMK5xy9aJCnZT0Uw@public.gmane.org>,
	"linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org"
	<jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
	"Sepehrdad,
	Pouyan" <pouyans-Rm6X0d1/PG5y9aJCnZT0Uw@public.gmane.org>
Subject: Re: [PATCH 2/2] ath9k: disable RNG by default
Date: Wed, 10 Aug 2016 02:35:04 +0000	[thread overview]
Message-ID: <1470796501856.53342@qti.qualcomm.com> (raw)
In-Reply-To: <1645997.7cVzaEi3NG-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>

Hi Stephan,

For those less perfect noise source, can't pass the FIPS test.

static int update_kernel_random(int random_step,
        unsigned char *buf, fips_ctx_t *fipsctx_in)
{
        unsigned char *p; 
        int fips;

        fips = fips_run_rng_test(fipsctx_in, buf);
        if (fips)
                return 1;

        for (p = buf; p + random_step <= &buf[FIPS_RNG_BUFFER_SIZE];
                 p += random_step) {
                random_add_entropy(p, random_step);
                random_sleep();
        }
        return 0;
}

--
Miaoqing
________________________________________
From: Stephan Mueller <smueller-T9tCv8IpfcWELgA04lAiVw@public.gmane.org>
Sent: Tuesday, August 9, 2016 5:37 PM
To: Herbert Xu
Cc: Pan, Miaoqing; Matt Mackall; miaoqing-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org; Valo, Kalle; linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; ath9k-devel; linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org; Sepehrdad, Pouyan
Subject: Re: [PATCH 2/2] ath9k: disable RNG by default

Am Dienstag, 9. August 2016, 17:17:55 CEST schrieb Herbert Xu:

Hi Herbert,

> On Tue, Aug 09, 2016 at 11:02:58AM +0200, Stephan Mueller wrote:
> > But shouldn't the default of the rngd then be adjusted a bit?
>
> Please elaborate.

in rngd_linux.c:random_add_entropy(void *buf, size_t size):

        entropy.ent_count = size * 8;
        entropy.size = size;
        memcpy(entropy.data, buf, size);

        if (ioctl(random_fd, RNDADDENTROPY, &entropy) != 0) {

...


in rngd.c:do_loop():

                        retval = iter->xread(buf, sizeof buf, iter);
...
                        rc = update_kernel_random(random_step,
                                             buf, iter->fipsctx);

where update_kernel_random simply invokes random_add_entropy in chunks.

Hence, the rngd reads some bytes from /dev/hwrand and injects it into /dev/
random with an entropy estimate that is equal to the read bytes.

With less than perfect noise sources, entropy.ent_count should be much
smaller.
>
> Thanks,



Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "Pan, Miaoqing" <miaoqing@qti.qualcomm.com>
To: Stephan Mueller <smueller@chronox.de>,
	Herbert Xu <herbert@gondor.apana.org.au>
Cc: Matt Mackall <mpm@selenic.com>,
	"miaoqing@codeaurora.org" <miaoqing@codeaurora.org>,
	"Valo, Kalle" <kvalo@qca.qualcomm.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	ath9k-devel <ath9k-devel@qca.qualcomm.com>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"jason@lakedaemon.net" <jason@lakedaemon.net>,
	"Sepehrdad, Pouyan" <pouyans@qti.qualcomm.com>
Subject: Re: [PATCH 2/2] ath9k: disable RNG by default
Date: Wed, 10 Aug 2016 02:35:04 +0000	[thread overview]
Message-ID: <1470796501856.53342@qti.qualcomm.com> (raw)
In-Reply-To: <1645997.7cVzaEi3NG@tauon.atsec.com>

Hi Stephan,

For those less perfect noise source, can't pass the FIPS test.

static int update_kernel_random(int random_step,
        unsigned char *buf, fips_ctx_t *fipsctx_in)
{
        unsigned char *p; 
        int fips;

        fips = fips_run_rng_test(fipsctx_in, buf);
        if (fips)
                return 1;

        for (p = buf; p + random_step <= &buf[FIPS_RNG_BUFFER_SIZE];
                 p += random_step) {
                random_add_entropy(p, random_step);
                random_sleep();
        }
        return 0;
}

--
Miaoqing
________________________________________
From: Stephan Mueller <smueller@chronox.de>
Sent: Tuesday, August 9, 2016 5:37 PM
To: Herbert Xu
Cc: Pan, Miaoqing; Matt Mackall; miaoqing@codeaurora.org; Valo, Kalle; linux-wireless@vger.kernel.org; ath9k-devel; linux-crypto@vger.kernel.org; jason@lakedaemon.net; Sepehrdad, Pouyan
Subject: Re: [PATCH 2/2] ath9k: disable RNG by default

Am Dienstag, 9. August 2016, 17:17:55 CEST schrieb Herbert Xu:

Hi Herbert,

> On Tue, Aug 09, 2016 at 11:02:58AM +0200, Stephan Mueller wrote:
> > But shouldn't the default of the rngd then be adjusted a bit?
>
> Please elaborate.

in rngd_linux.c:random_add_entropy(void *buf, size_t size):

        entropy.ent_count = size * 8;
        entropy.size = size;
        memcpy(entropy.data, buf, size);

        if (ioctl(random_fd, RNDADDENTROPY, &entropy) != 0) {

...


in rngd.c:do_loop():

                        retval = iter->xread(buf, sizeof buf, iter);
...
                        rc = update_kernel_random(random_step,
                                             buf, iter->fipsctx);

where update_kernel_random simply invokes random_add_entropy in chunks.

Hence, the rngd reads some bytes from /dev/hwrand and injects it into /dev/
random with an entropy estimate that is equal to the read bytes.

With less than perfect noise sources, entropy.ent_count should be much
smaller.
>
> Thanks,



Ciao
Stephan

  parent reply	other threads:[~2016-08-10  2:35 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09  7:02 [PATCH 1/2] ath9k: change entropy formula for easier understanding miaoqing
2016-08-09  7:02 ` [PATCH 2/2] ath9k: disable RNG by default miaoqing
     [not found]   ` <1470726147-30095-2-git-send-email-miaoqing-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-08-09  7:14     ` Stephan Mueller
2016-08-09  7:14       ` Stephan Mueller
2016-08-09  7:35       ` Pan, Miaoqing
2016-08-09  8:07         ` Stephan Mueller
2016-08-09  8:58           ` Herbert Xu
2016-08-09  9:02             ` Stephan Mueller
     [not found]               ` <2569442.q63FVBJjUH-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>
2016-08-09  9:17                 ` Herbert Xu
2016-08-09  9:17                   ` Herbert Xu
     [not found]                   ` <20160809091755.GA6370-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2016-08-09  9:37                     ` Stephan Mueller
2016-08-09  9:37                       ` Stephan Mueller
2016-08-09  9:46                       ` Herbert Xu
2016-08-09  9:56                         ` Stephan Mueller
2016-08-09  9:56                           ` Herbert Xu
2016-08-09 10:06                             ` Stephan Mueller
     [not found]                               ` <11316081.S4pPZmZMrt-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>
2016-08-09 10:24                                 ` Henrique de Moraes Holschuh
2016-08-09 10:24                                   ` Henrique de Moraes Holschuh
2016-08-09 17:51                                   ` Jason Cooper
     [not found]                       ` <1645997.7cVzaEi3NG-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>
2016-08-10  2:35                         ` Pan, Miaoqing [this message]
2016-08-10  2:35                           ` Pan, Miaoqing
     [not found]                           ` <1470796501856.53342-Rm6X0d1/PG5y9aJCnZT0Uw@public.gmane.org>
2016-08-10  5:29                             ` Stephan Mueller
2016-08-10  5:29                               ` Stephan Mueller
     [not found]                               ` <1543667.vXsZDTRgbm-jJGQKZiSfeo1haGO/jJMPxvVK+yQ3ZXh@public.gmane.org>
2016-08-10  6:04                                 ` Pan, Miaoqing
2016-08-10  6:04                                   ` Pan, Miaoqing
2016-08-10  6:25                                   ` Stephan Mueller
     [not found]                                     ` <14565196.xaXq375WQg-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>
2016-08-10  6:46                                       ` Pan, Miaoqing
2016-08-10  6:46                                         ` Pan, Miaoqing
2016-08-10  6:51                                         ` Stephan Mueller
2016-08-10  7:15                                           ` Pan, Miaoqing
     [not found]                                             ` <c0951e085764481d8d85637734e2e14b-fhY3XlRGNI1pWAYlkNb9jaRtKmQZhJ7pQQ4Iyu8u01E@public.gmane.org>
2016-08-10  7:27                                               ` Stephan Mueller
2016-08-10  7:27                                                 ` Stephan Mueller
     [not found]                                                 ` <4321952.1nMxxDi7Wz-jJGQKZiSfeo1haGO/jJMPxvVK+yQ3ZXh@public.gmane.org>
2016-08-10  7:40                                                   ` Pan, Miaoqing
2016-08-10  7:40                                                     ` Pan, Miaoqing
     [not found]                                                     ` <1e8e88ad7de64c528f08c75ff9176ab8-fhY3XlRGNI1pWAYlkNb9jaRtKmQZhJ7pQQ4Iyu8u01E@public.gmane.org>
2016-08-10  7:43                                                       ` Pan, Miaoqing
2016-08-10  7:43                                                         ` Pan, Miaoqing
     [not found]                                                         ` <389c3c1fdde2447aacf31a8b4aadfc08-fhY3XlRGNI1pWAYlkNb9jaRtKmQZhJ7pQQ4Iyu8u01E@public.gmane.org>
2016-08-10 13:24                                                           ` Jason Cooper
2016-08-10 13:24                                                             ` Jason Cooper
2016-08-11  2:54                                                             ` miaoqing
     [not found]                                                               ` <14a3879458f3bfc36068c2e8294ca448-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-08-11 13:14                                                                 ` Jason Cooper
2016-08-11 13:14                                                                   ` Jason Cooper
2016-08-09 17:48     ` Jason Cooper
2016-08-09 17:48       ` Jason Cooper
2016-09-28 10:00   ` [2/2] " Kalle Valo
     [not found] ` <1470726147-30095-1-git-send-email-miaoqing-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-09-27 14:53   ` [1/2] ath9k: change entropy formula for easier understanding Kalle Valo
2016-09-27 14:53     ` Kalle Valo
2016-10-13 14:23   ` Kalle Valo
2016-10-13 14:23     ` Kalle Valo

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=1470796501856.53342@qti.qualcomm.com \
    --to=miaoqing-rm6x0d1/pg5y9ajcnzt0uw@public.gmane.org \
    --cc=ath9k-devel-A+ZNKFmMK5xy9aJCnZT0Uw@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=kvalo-A+ZNKFmMK5xy9aJCnZT0Uw@public.gmane.org \
    --cc=linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=miaoqing-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org \
    --cc=pouyans-Rm6X0d1/PG5y9aJCnZT0Uw@public.gmane.org \
    --cc=smueller-T9tCv8IpfcWELgA04lAiVw@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.