<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/crypto/ansi_cprng.c, branch v3.0.95</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Fix common misspellings</title>
<updated>2011-03-31T14:26:23+00:00</updated>
<author>
<name>Lucas De Marchi</name>
<email>lucas.demarchi@profusion.mobi</email>
</author>
<published>2011-03-31T01:57:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=25985edcedea6396277003854657b5f3cb31a628'/>
<id>25985edcedea6396277003854657b5f3cb31a628</id>
<content type='text'>
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi &lt;lucas.demarchi@profusion.mobi&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi &lt;lucas.demarchi@profusion.mobi&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - Move FIPS functions under CONFIG_CRYPTO_FIPS</title>
<updated>2009-11-23T12:25:50+00:00</updated>
<author>
<name>Jaswinder Singh Rajput</name>
<email>jaswinderrajput@gmail.com</email>
</author>
<published>2009-11-23T12:25:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2f32bfd834d5d7eb230bcbf39aaacccd2a01d767'/>
<id>2f32bfd834d5d7eb230bcbf39aaacccd2a01d767</id>
<content type='text'>
fips_cprng_get_random and fips_cprng_reset is used only by
CONFIG_CRYPTO_FIPS. This also fixes compilation warnings:

 crypto/ansi_cprng.c:360: warning: ‘fips_cprng_get_random’ defined but not used
 crypto/ansi_cprng.c:393: warning: ‘fips_cprng_reset’ defined but not used

Signed-off-by: Jaswinder Singh Rajput &lt;jaswinderrajput@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
fips_cprng_get_random and fips_cprng_reset is used only by
CONFIG_CRYPTO_FIPS. This also fixes compilation warnings:

 crypto/ansi_cprng.c:360: warning: ‘fips_cprng_get_random’ defined but not used
 crypto/ansi_cprng.c:393: warning: ‘fips_cprng_reset’ defined but not used

Signed-off-by: Jaswinder Singh Rajput &lt;jaswinderrajput@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - Fix test in get_prng_bytes</title>
<updated>2009-10-27T10:51:33+00:00</updated>
<author>
<name>Roel Kluin</name>
<email>roel.kluin@gmail.com</email>
</author>
<published>2009-10-27T10:51:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2024e7d6804b3f6251b28126eceb7f6bf2e3a4e8'/>
<id>2024e7d6804b3f6251b28126eceb7f6bf2e3a4e8</id>
<content type='text'>
size_t nbytes cannot be less than 0 and the test was redundant.

Signed-off-by: Roel Kluin &lt;roel.kluin@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
size_t nbytes cannot be less than 0 and the test was redundant.

Signed-off-by: Roel Kluin &lt;roel.kluin@gmail.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - Add FIPS wrapper</title>
<updated>2009-10-19T02:57:02+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2009-10-19T02:57:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=667b6294bf088445996c8395b723ae9c9467e72b'/>
<id>667b6294bf088445996c8395b723ae9c9467e72b</id>
<content type='text'>
Patch to add fips(ansi_cprng) alg, which is ansi_cprng plus a continuous test

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: Jarod Wilson &lt;jarod@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Patch to add fips(ansi_cprng) alg, which is ansi_cprng plus a continuous test

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: Jarod Wilson &lt;jarod@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - Fix module initialization</title>
<updated>2009-08-29T07:36:25+00:00</updated>
<author>
<name>Steffen Klassert</name>
<email>steffen.klassert@secunet.com</email>
</author>
<published>2009-08-29T07:36:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a367b17f34e1280270a6b577c11d5ecff093f9ae'/>
<id>a367b17f34e1280270a6b577c11d5ecff093f9ae</id>
<content type='text'>
Return the value we got from crypto_register_alg() instead of
returning 0 in any case.

Signed-off-by: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Return the value we got from crypto_register_alg() instead of
returning 0 in any case.

Signed-off-by: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_prng - alloc cipher just in init</title>
<updated>2009-07-03T04:10:47+00:00</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>sebastian@breakpoint.cc</email>
</author>
<published>2009-07-03T04:10:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fd09d7facb7cf3a884979eb5f843338ce1ce9b43'/>
<id>fd09d7facb7cf3a884979eb5f843338ce1ce9b43</id>
<content type='text'>
As reported by Eric Sesterhenn the re-allocation of the cipher in reset leads
to:
|BUG: sleeping function called from invalid context at kernel/rwsem.c:21
|in_atomic(): 1, irqs_disabled(): 0, pid: 4926, name: modprobe
|INFO: lockdep is turned off.
|Pid: 4926, comm: modprobe Tainted: G   M 2.6.31-rc1-22297-g5298976 #24
|Call Trace:
| [&lt;c011dd93&gt;] __might_sleep+0xf9/0x101
| [&lt;c0777aa0&gt;] down_read+0x16/0x68
| [&lt;c048bf04&gt;] crypto_alg_lookup+0x16/0x34
| [&lt;c048bf52&gt;] crypto_larval_lookup+0x30/0xf9
| [&lt;c048c038&gt;] crypto_alg_mod_lookup+0x1d/0x62
| [&lt;c048c13e&gt;] crypto_alloc_base+0x1e/0x64
| [&lt;c04bf991&gt;] reset_prng_context+0xab/0x13f
| [&lt;c04e5cfc&gt;] ? __spin_lock_init+0x27/0x51
| [&lt;c04bfce1&gt;] cprng_init+0x2a/0x42
| [&lt;c048bb4c&gt;] __crypto_alloc_tfm+0xfa/0x128
| [&lt;c048c153&gt;] crypto_alloc_base+0x33/0x64
| [&lt;c04933c9&gt;] alg_test_cprng+0x30/0x1f4
| [&lt;c0493329&gt;] alg_test+0x12f/0x19f
| [&lt;c0177f1f&gt;] ? __alloc_pages_nodemask+0x14d/0x481
| [&lt;d09219e2&gt;] do_test+0xf9d/0x163f [tcrypt]
| [&lt;d0920de6&gt;] do_test+0x3a1/0x163f [tcrypt]
| [&lt;d0926035&gt;] tcrypt_mod_init+0x35/0x7c [tcrypt]
| [&lt;c010113c&gt;] _stext+0x54/0x12c
| [&lt;d0926000&gt;] ? tcrypt_mod_init+0x0/0x7c [tcrypt]
| [&lt;c01398a3&gt;] ? up_read+0x16/0x2b
| [&lt;c0139fc4&gt;] ? __blocking_notifier_call_chain+0x40/0x4c
| [&lt;c014ee8d&gt;] sys_init_module+0xa9/0x1bf
| [&lt;c010292b&gt;] sysenter_do_call+0x12/0x32

because a spin lock is held and crypto_alloc_base() may sleep.
There is no reason to re-allocate the cipher, the state is resetted in
-&gt;setkey(). This patches makes the cipher allocation a one time thing and
moves it to init.

Reported-by: Eric Sesterhenn &lt;eric.sesterhenn@lsexperts.de&gt;
Signed-off-by: Sebastian Andrzej Siewior &lt;sebastian@breakpoint.cc&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As reported by Eric Sesterhenn the re-allocation of the cipher in reset leads
to:
|BUG: sleeping function called from invalid context at kernel/rwsem.c:21
|in_atomic(): 1, irqs_disabled(): 0, pid: 4926, name: modprobe
|INFO: lockdep is turned off.
|Pid: 4926, comm: modprobe Tainted: G   M 2.6.31-rc1-22297-g5298976 #24
|Call Trace:
| [&lt;c011dd93&gt;] __might_sleep+0xf9/0x101
| [&lt;c0777aa0&gt;] down_read+0x16/0x68
| [&lt;c048bf04&gt;] crypto_alg_lookup+0x16/0x34
| [&lt;c048bf52&gt;] crypto_larval_lookup+0x30/0xf9
| [&lt;c048c038&gt;] crypto_alg_mod_lookup+0x1d/0x62
| [&lt;c048c13e&gt;] crypto_alloc_base+0x1e/0x64
| [&lt;c04bf991&gt;] reset_prng_context+0xab/0x13f
| [&lt;c04e5cfc&gt;] ? __spin_lock_init+0x27/0x51
| [&lt;c04bfce1&gt;] cprng_init+0x2a/0x42
| [&lt;c048bb4c&gt;] __crypto_alloc_tfm+0xfa/0x128
| [&lt;c048c153&gt;] crypto_alloc_base+0x33/0x64
| [&lt;c04933c9&gt;] alg_test_cprng+0x30/0x1f4
| [&lt;c0493329&gt;] alg_test+0x12f/0x19f
| [&lt;c0177f1f&gt;] ? __alloc_pages_nodemask+0x14d/0x481
| [&lt;d09219e2&gt;] do_test+0xf9d/0x163f [tcrypt]
| [&lt;d0920de6&gt;] do_test+0x3a1/0x163f [tcrypt]
| [&lt;d0926035&gt;] tcrypt_mod_init+0x35/0x7c [tcrypt]
| [&lt;c010113c&gt;] _stext+0x54/0x12c
| [&lt;d0926000&gt;] ? tcrypt_mod_init+0x0/0x7c [tcrypt]
| [&lt;c01398a3&gt;] ? up_read+0x16/0x2b
| [&lt;c0139fc4&gt;] ? __blocking_notifier_call_chain+0x40/0x4c
| [&lt;c014ee8d&gt;] sys_init_module+0xa9/0x1bf
| [&lt;c010292b&gt;] sysenter_do_call+0x12/0x32

because a spin lock is held and crypto_alloc_base() may sleep.
There is no reason to re-allocate the cipher, the state is resetted in
-&gt;setkey(). This patches makes the cipher allocation a one time thing and
moves it to init.

Reported-by: Eric Sesterhenn &lt;eric.sesterhenn@lsexperts.de&gt;
Signed-off-by: Sebastian Andrzej Siewior &lt;sebastian@breakpoint.cc&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_prng - Use just a BH lock</title>
<updated>2009-07-03T04:09:41+00:00</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>sebastian@breakpoint.cc</email>
</author>
<published>2009-07-03T04:09:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ed94070058033a3c99fe62c90d00c39dc443c679'/>
<id>ed94070058033a3c99fe62c90d00c39dc443c679</id>
<content type='text'>
The current code uses a mix of sping_lock() &amp; spin_lock_irqsave(). This can
lead to deadlock with the correct timming &amp; cprng_get_random() + cprng_reset()
sequence.
I've converted them to bottom half locks since all three user grab just a BH
lock so this runs probably in softirq :)

Signed-off-by: Sebastian Andrzej Siewior &lt;sebastian@breakpoint.cc&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The current code uses a mix of sping_lock() &amp; spin_lock_irqsave(). This can
lead to deadlock with the correct timming &amp; cprng_get_random() + cprng_reset()
sequence.
I've converted them to bottom half locks since all three user grab just a BH
lock so this runs probably in softirq :)

Signed-off-by: Sebastian Andrzej Siewior &lt;sebastian@breakpoint.cc&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - Panic on CPRNG test failure when in FIPS mode       </title>
<updated>2009-02-18T08:48:07+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2009-02-05T05:01:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c5b1e545a567c52081239bd5d187669640d0146f'/>
<id>c5b1e545a567c52081239bd5d187669640d0146f</id>
<content type='text'>
FIPS 140-2 specifies that all access to various cryptographic modules be
prevented in the event that any of the provided self tests fail on the various
implemented algorithms.  We already panic when any of the test in testmgr.c
fail when we are operating in fips mode.  The continuous test in the cprng here
was missed when that was implmented.  This code simply checks for the
fips_enabled flag if the test fails, and warns us via syslog or panics the box
accordingly.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
FIPS 140-2 specifies that all access to various cryptographic modules be
prevented in the event that any of the provided self tests fail on the various
implemented algorithms.  We already panic when any of the test in testmgr.c
fail when we are operating in fips mode.  The continuous test in the cprng here
was missed when that was implmented.  This code simply checks for the
fips_enabled flag if the test fails, and warns us via syslog or panics the box
accordingly.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - Force reset on allocation</title>
<updated>2009-02-18T08:48:06+00:00</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@redhat.com</email>
</author>
<published>2009-01-28T04:20:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d7992f42c61d5dc6d164f7dddd05284485204ada'/>
<id>d7992f42c61d5dc6d164f7dddd05284485204ada</id>
<content type='text'>
Pseudo RNGs provide predictable outputs based on input parateters {key, V, DT},
the idea behind them is that only the user should know what the inputs are.
While its nice to have default known values for testing purposes, it seems
dangerous to allow the use of those default values without some sort of safety
measure in place, lest an attacker easily guess the output of the cprng.  This
patch forces the NEED_RESET flag on when allocating a cprng context, so that any
user is forced to reseed it before use.  The defaults can still be used for
testing, but this will prevent their inadvertent use, and be more secure.
   
Signed-off-by: Neil Horman &lt;nhorman@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pseudo RNGs provide predictable outputs based on input parateters {key, V, DT},
the idea behind them is that only the user should know what the inputs are.
While its nice to have default known values for testing purposes, it seems
dangerous to allow the use of those default values without some sort of safety
measure in place, lest an attacker easily guess the output of the cprng.  This
patch forces the NEED_RESET flag on when allocating a cprng context, so that any
user is forced to reseed it before use.  The defaults can still be used for
testing, but this will prevent their inadvertent use, and be more secure.
   
Signed-off-by: Neil Horman &lt;nhorman@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: ansi_cprng - fix inverted DT increment routine</title>
<updated>2008-12-25T00:01:49+00:00</updated>
<author>
<name>Jarod Wilson</name>
<email>jarod@redhat.com</email>
</author>
<published>2008-11-24T13:20:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=09fbf7c0f24176ef3b450c590f220ed8033dd2c3'/>
<id>09fbf7c0f24176ef3b450c590f220ed8033dd2c3</id>
<content type='text'>
The ANSI X9.31 PRNG docs aren't particularly clear on how to increment DT,
but empirical testing shows we're incrementing from the wrong end. A 10,000
iteration Monte Carlo RNG test currently winds up not getting the expected
result.

From http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf :

# CAVS 4.3
# ANSI931 MCT
[X9.31]
[AES 128-Key]

COUNT = 0
Key = 9f5b51200bf334b5d82be8c37255c848
DT = 6376bbe52902ba3b67c925fa701f11ac
V = 572c8e76872647977e74fbddc49501d1
R = 48e9bd0d06ee18fbe45790d5c3fc9b73

Currently, we get 0dd08496c4f7178bfa70a2161a79459a after 10000 loops.

Inverting the DT increment routine results in us obtaining the expected result
of 48e9bd0d06ee18fbe45790d5c3fc9b73. Verified on both x86_64 and ppc64.

Signed-off-by: Jarod Wilson &lt;jarod@redhat.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The ANSI X9.31 PRNG docs aren't particularly clear on how to increment DT,
but empirical testing shows we're incrementing from the wrong end. A 10,000
iteration Monte Carlo RNG test currently winds up not getting the expected
result.

From http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf :

# CAVS 4.3
# ANSI931 MCT
[X9.31]
[AES 128-Key]

COUNT = 0
Key = 9f5b51200bf334b5d82be8c37255c848
DT = 6376bbe52902ba3b67c925fa701f11ac
V = 572c8e76872647977e74fbddc49501d1
R = 48e9bd0d06ee18fbe45790d5c3fc9b73

Currently, we get 0dd08496c4f7178bfa70a2161a79459a after 10000 loops.

Inverting the DT increment routine results in us obtaining the expected result
of 48e9bd0d06ee18fbe45790d5c3fc9b73. Verified on both x86_64 and ppc64.

Signed-off-by: Jarod Wilson &lt;jarod@redhat.com&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
</feed>
