<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/pycrypto.git/lib/Crypto/SelfTest, branch pyca</title>
<subtitle>github.com: dlitz/pycrypto.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/'/>
<entry>
<title>Do not run multiprocessing test if multiprocessing.synchronize is not working</title>
<updated>2013-10-17T17:56:11+00:00</updated>
<author>
<name>Sebastian Ramacher</name>
<email>sebastian+dev@ramacher.at</email>
</author>
<published>2013-10-17T17:56:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=845055208d8f5fa153faf646f18876c4a1b9cc84'/>
<id>845055208d8f5fa153faf646f18876c4a1b9cc84</id>
<content type='text'>
On platforms that do not have a working sem_open implementation, importing
multiprocessing.synchronize will fail with an ImportError. While creating a
multiprocessing.Pool instance, multiprocessing.synchronize will be imported and
might throw an ImportError.

Signed-off-by: Sebastian Ramacher &lt;sebastian+dev@ramacher.at&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On platforms that do not have a working sem_open implementation, importing
multiprocessing.synchronize will fail with an ImportError. While creating a
multiprocessing.Pool instance, multiprocessing.synchronize will be imported and
might throw an ImportError.

Signed-off-by: Sebastian Ramacher &lt;sebastian+dev@ramacher.at&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Random: Make Crypto.Random.atfork() set last_reseed=None (CVE-2013-1445)</title>
<updated>2013-10-14T21:37:35+00:00</updated>
<author>
<name>Dwayne Litzenberger</name>
<email>dlitz@dlitz.net</email>
</author>
<published>2013-10-14T21:37:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=19dcf7b15d61b7dc1a125a367151de40df6ef175'/>
<id>19dcf7b15d61b7dc1a125a367151de40df6ef175</id>
<content type='text'>
== Summary ==

In PyCrypto before v2.6.1, the Crypto.Random pseudo-random number
generator (PRNG) exhibits a race condition that may cause it to generate
the same 'random' output in multiple processes that are forked from each
other.  Depending on the application, this could reveal sensitive
information or cryptographic keys to remote attackers.

An application may be affected if, within 100 milliseconds, it performs
the following steps (which may be summarized as "read-fork-read-read"):

1. Read from the Crypto.Random PRNG, causing an internal reseed;
2. Fork the process and invoke Crypto.Random.atfork() in the child;
3. Read from the Crypto.Random PRNG again, in at least two different
   processes (parent and child, or multiple children).

Only applications that invoke Crypto.Random.atfork() and perform the
above steps are affected by this issue.  Other applications are
unaffected.

Note: Some PyCrypto functions, such as key generation and PKCS#1-related
functions, implicitly read from the Crypto.Random PRNG.

== Technical details ==

Crypto.Random uses Fortuna[1] to generate random numbers.  The flow of
entropy looks something like this:

    /dev/urandom  -\
                    +-&gt; "accumulator" --&gt; "generator" --&gt; output
    other sources -/   (entropy pools)     (AES-CTR)

- The "accumulator" maintains several pools that collect entropy from
  the environment.

- The "generator" is a deterministic PRNG that is reseeded by the
  accumulator.  Reseeding normally occurs during each request for random
  numbers, but never more than once every 100 ms (the "minimum reseed
  interval").

When a process is forked, the parent's state is duplicated in the child.
In order to continue using the PRNG, the child process must invoke
Crypto.Random.atfork(), which collects new entropy from /dev/urandom and
adds it to the accumulator.  When new PRNG output is subsequently
requested, some of the new entropy in the accumulator is used to reseed
the generator, causing the output of the child to diverge from its
parent.

However, in previous versions of PyCrypto, Crypto.Random.atfork() did
not explicitly reset the child's rate-limiter, so if the child requested
PRNG output before the minimum reseed interval of 100 ms had elapsed, it
would generate its output using state inherited from its parent.

This created a race condition between the parent process and its forked
children that could cause them to produce identical PRNG output for the
duration of the 100 ms minimum reseed interval.

== Demonstration ==

Here is some sample code that illustrates the problem:

    from binascii import hexlify
    import multiprocessing, pprint, time
    import Crypto.Random

    def task_main(arg):
        a = Crypto.Random.get_random_bytes(8)
        time.sleep(0.1)
        b = Crypto.Random.get_random_bytes(8)
        rdy, ack = arg
        rdy.set()
        ack.wait()
        return "%s,%s" % (hexlify(a).decode(),
                          hexlify(b).decode())

    n_procs = 4
    manager = multiprocessing.Manager()
    rdys = [manager.Event() for i in range(n_procs)]
    acks = [manager.Event() for i in range(n_procs)]
    Crypto.Random.get_random_bytes(1)
    pool = multiprocessing.Pool(processes=n_procs,
                                initializer=Crypto.Random.atfork)
    res_async = pool.map_async(task_main, zip(rdys, acks))
    pool.close()
    [rdy.wait() for rdy in rdys]
    [ack.set() for ack in acks]
    res = res_async.get()
    pprint.pprint(sorted(res))
    pool.join()

The output should be random, but it looked like this:

    ['c607803ae01aa8c0,2e4de6457a304b34',
     'c607803ae01aa8c0,af80d08942b4c987',
     'c607803ae01aa8c0,b0e4c0853de927c4',
     'c607803ae01aa8c0,f0362585b3fceba4']

== Solution ==

The solution is to upgrade to PyCrypto v2.6.1 or later, which properly
resets the rate-limiter when Crypto.Random.atfork() is invoked in the
child.

== References ==

[1] N. Ferguson and B. Schneier, _Practical Cryptography_,
    Indianapolis: Wiley, 2003, pp. 155-184.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
== Summary ==

In PyCrypto before v2.6.1, the Crypto.Random pseudo-random number
generator (PRNG) exhibits a race condition that may cause it to generate
the same 'random' output in multiple processes that are forked from each
other.  Depending on the application, this could reveal sensitive
information or cryptographic keys to remote attackers.

An application may be affected if, within 100 milliseconds, it performs
the following steps (which may be summarized as "read-fork-read-read"):

1. Read from the Crypto.Random PRNG, causing an internal reseed;
2. Fork the process and invoke Crypto.Random.atfork() in the child;
3. Read from the Crypto.Random PRNG again, in at least two different
   processes (parent and child, or multiple children).

Only applications that invoke Crypto.Random.atfork() and perform the
above steps are affected by this issue.  Other applications are
unaffected.

Note: Some PyCrypto functions, such as key generation and PKCS#1-related
functions, implicitly read from the Crypto.Random PRNG.

== Technical details ==

Crypto.Random uses Fortuna[1] to generate random numbers.  The flow of
entropy looks something like this:

    /dev/urandom  -\
                    +-&gt; "accumulator" --&gt; "generator" --&gt; output
    other sources -/   (entropy pools)     (AES-CTR)

- The "accumulator" maintains several pools that collect entropy from
  the environment.

- The "generator" is a deterministic PRNG that is reseeded by the
  accumulator.  Reseeding normally occurs during each request for random
  numbers, but never more than once every 100 ms (the "minimum reseed
  interval").

When a process is forked, the parent's state is duplicated in the child.
In order to continue using the PRNG, the child process must invoke
Crypto.Random.atfork(), which collects new entropy from /dev/urandom and
adds it to the accumulator.  When new PRNG output is subsequently
requested, some of the new entropy in the accumulator is used to reseed
the generator, causing the output of the child to diverge from its
parent.

However, in previous versions of PyCrypto, Crypto.Random.atfork() did
not explicitly reset the child's rate-limiter, so if the child requested
PRNG output before the minimum reseed interval of 100 ms had elapsed, it
would generate its output using state inherited from its parent.

This created a race condition between the parent process and its forked
children that could cause them to produce identical PRNG output for the
duration of the 100 ms minimum reseed interval.

== Demonstration ==

Here is some sample code that illustrates the problem:

    from binascii import hexlify
    import multiprocessing, pprint, time
    import Crypto.Random

    def task_main(arg):
        a = Crypto.Random.get_random_bytes(8)
        time.sleep(0.1)
        b = Crypto.Random.get_random_bytes(8)
        rdy, ack = arg
        rdy.set()
        ack.wait()
        return "%s,%s" % (hexlify(a).decode(),
                          hexlify(b).decode())

    n_procs = 4
    manager = multiprocessing.Manager()
    rdys = [manager.Event() for i in range(n_procs)]
    acks = [manager.Event() for i in range(n_procs)]
    Crypto.Random.get_random_bytes(1)
    pool = multiprocessing.Pool(processes=n_procs,
                                initializer=Crypto.Random.atfork)
    res_async = pool.map_async(task_main, zip(rdys, acks))
    pool.close()
    [rdy.wait() for rdy in rdys]
    [ack.set() for ack in acks]
    res = res_async.get()
    pprint.pprint(sorted(res))
    pool.join()

The output should be random, but it looked like this:

    ['c607803ae01aa8c0,2e4de6457a304b34',
     'c607803ae01aa8c0,af80d08942b4c987',
     'c607803ae01aa8c0,b0e4c0853de927c4',
     'c607803ae01aa8c0,f0362585b3fceba4']

== Solution ==

The solution is to upgrade to PyCrypto v2.6.1 or later, which properly
resets the rate-limiter when Crypto.Random.atfork() is invoked in the
child.

== References ==

[1] N. Ferguson and B. Schneier, _Practical Cryptography_,
    Indianapolis: Wiley, 2003, pp. 155-184.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix block ciphers allowing empty string as IV</title>
<updated>2012-05-24T12:44:49+00:00</updated>
<author>
<name>Dwayne C. Litzenberger</name>
<email>dlitz@dlitz.net</email>
</author>
<published>2012-05-24T11:51:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=411f60f58cea79f7e93476ba0c069b80a2a4c1a0'/>
<id>411f60f58cea79f7e93476ba0c069b80a2a4c1a0</id>
<content type='text'>
Bug report: https://bugs.launchpad.net/pycrypto/+bug/997464
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Bug report: https://bugs.launchpad.net/pycrypto/+bug/997464
</pre>
</div>
</content>
</entry>
<entry>
<title>Add ability to import RSAPublicKey objects (encoded in DER or PEM)</title>
<updated>2012-05-18T20:54:57+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-18T18:44:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=cdcc48b064f298f7ea53b651ca726ed7f0aef81c'/>
<id>cdcc48b064f298f7ea53b651ca726ed7f0aef81c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Describe unit tests for importKey</title>
<updated>2012-05-18T20:54:57+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-18T18:16:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=6a8f175f86d60814df3d07bb23fa7a897107b553'/>
<id>6a8f175f86d60814df3d07bb23fa7a897107b553</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Added test vectors from NIST 800-38A</title>
<updated>2012-05-18T11:37:24+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-18T11:37:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=7f4abae9e2f9436098d571b7090a96daa0306f3b'/>
<id>7f4abae9e2f9436098d571b7090a96daa0306f3b</id>
<content type='text'>
Test vectors cover ECB, CBC, OFB, CFB-8, CFB-128, and CTR modes
for AES-128, AES-192, and AES-256.

Test vectors for CFB-1 have not been added because it is not a mode
supported by PyCrypto.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Test vectors cover ECB, CBC, OFB, CFB-8, CFB-128, and CTR modes
for AES-128, AES-192, and AES-256.

Test vectors for CFB-1 have not been added because it is not a mode
supported by PyCrypto.
</pre>
</div>
</content>
</entry>
<entry>
<title>Added OPENPGP mode to RoundTripTests</title>
<updated>2012-05-17T20:57:38+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-17T20:57:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=17e5370d948e94135338111363f97cc9d513c92a'/>
<id>17e5370d948e94135338111363f97cc9d513c92a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Added OpenPGP mode</title>
<updated>2012-05-17T20:17:38+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-17T11:28:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=62f2c4154c89fecbacb722efaed2af01bcecab3a'/>
<id>62f2c4154c89fecbacb722efaed2af01bcecab3a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Removed PGP mode from block ciphers</title>
<updated>2012-05-14T17:52:30+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-14T17:52:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=67d8cd1aaf1863cd7510baebbef9b395015312e4'/>
<id>67d8cd1aaf1863cd7510baebbef9b395015312e4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixes to make test suite pass for Python 2.1 and Python 3</title>
<updated>2012-05-11T20:57:49+00:00</updated>
<author>
<name>Legrandin</name>
<email>gooksankoo@hoiptorrow.mailexpire.com</email>
</author>
<published>2012-05-11T20:57:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/pycrypto.git/commit/?id=4ce6b8d7f1c070687f0144736dd9a14b4b603b7d'/>
<id>4ce6b8d7f1c070687f0144736dd9a14b4b603b7d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
