OpenSSL random function
(self, size)
| 466 | return res |
| 467 | |
| 468 | def rand(self, size): |
| 469 | """ |
| 470 | OpenSSL random function |
| 471 | """ |
| 472 | buffer = self.malloc(0, size) |
| 473 | # This pyelliptic library, by default, didn't check the return value of RAND_bytes. It is |
| 474 | # evidently possible that it returned an error and not-actually-random data. However, in |
| 475 | # tests on various operating systems, while generating hundreds of gigabytes of random |
| 476 | # strings of various sizes I could not get an error to occur. Also Bitcoin doesn't check |
| 477 | # the return value of RAND_bytes either. |
| 478 | # Fixed in Bitmessage version 0.4.2 (in source code on 2013-10-13) |
| 479 | while self.RAND_bytes(buffer, size) != 1: |
| 480 | import time |
| 481 | time.sleep(1) |
| 482 | return buffer.raw |
| 483 | |
| 484 | def malloc(self, data, size): |
| 485 | """ |
no test coverage detected