aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* In es_unix, two changeslloyd2009-01-311-6/+3
| | | | | | | | | | | Make the fast poll significantly more pessimistic/realistic about how many bits of randomness we're getting from getrusage and stat. Don't cut out from execing programs if the desired poll bits is under 128. Simply poll until either the accumulator says we're done or we run out of sources. Assumption is that the poll won't be run at all unless it is ncessary (es_unix comes late in the list of sources to use since it is pretty slow).
* Recast to byte pointer in Entropy_Accumulator before passing to add_byteslloyd2009-01-311-4/+4
|
* propagate from branch 'net.randombit.botan' (head ↵lloyd2009-01-3132-848/+674
|\ | | | | | | | | | | 4518ef63a5e28e22a61d21a6066d0d4a5cf0616e) to branch 'net.randombit.botan.entropy-poll-redesign' (head c8e07f10a193b25bab726af99ea2ea77a0f30eaf)
| * Remove the notion of counting entropy bits in HMAC_RNG or Randpool.lloyd2009-01-314-35/+14
| | | | | | | | | | | | | | | | | | Instead simply consider the PRNG seeded if a poll kicked off from reseed met its goal, or if the user adds data. Doing anything else prevents creating (for instance) a PRNG seeded with 64 bits of entropy, which is unsafe for some purposes (key generation) but quite possibly safe enough for others (generating salts and such).
| * Change the max amount read from /dev/*random to 128 bits.lloyd2009-01-311-9/+4
| | | | | | | | | | | | Also, change the wait time to bits/16 milliseconds. For instance if 64 bits of entropy are requested, the reader will wait at most 4 ms in the select loop.
| * Track the collected entropy as a double instead of a unsigned int. Otherwiselloyd2009-01-311-3/+5
| | | | | | | | | | | | inputs might end up not contributing anything to the count even when they should. This was paricularly noticable with the proc walker - it uses an estimate of .01 bits / byte, so if the file was < 100 bytes it would not count for anything at all.
| * Make Entropy_Accumulator a pure virtual to allow other accumulationlloyd2009-01-313-7/+28
| | | | | | | | | | techniques, with the one using BufferedComputation being the new subclass with the charming name Entropy_Accumulator_BufferedComputation.
| * In the X9.31 PRNG, move the code that rekeys the cipher and generates V tolloyd2009-01-312-44/+53
| | | | | | | | | | | | | | | | a new member function rekey, calling it from both reseed and add_entropy. Previously add_entropy worked without this because the PRNG would reseed itself automatically if it was not at the point when randomize() was called, but once this was removed it was necessary to ensure a rekey kicked off, if appropriate, when calling add_entropy.
| * Double the static estimate in es_ftw. To collect 256 bits of estimatedlloyd2009-01-281-1/+1
| | | | | | | | | | entropy, the proc walker will read about 256K bytes. This seems plenty sufficient to me.
| * In the BeOS entropy poll, quit the loop early if the polling goal waslloyd2009-01-281-0/+3
| | | | | | | | achieved.
| * Go back to entropy bits per byte, instead of total estimated entropy oflloyd2009-01-281-4/+4
| | | | | | | | the buffer.
| * Have Entropy_Accumulator dump everything into a BufferedComputation.lloyd2009-01-275-108/+26
| | | | | | | | | | | | | | | | | | | | | | | | Since both Randpool and HMAC_RNG fed the input into a MAC anyway, this works nicely. (It would be nicer to use tr1::function but, argh, don't want to fully depend on TR1 quite yet. C++0x cannot come soon enough). This avoids requiring to do run length encoding, it just dumps everything as-is into the MAC. This ensures the buffer is not a potential narrow pipe for the entropy (for instance, one might imagine an entropy source which outputs one random byte every 16 bytes, and the rest some repeating pattern - using a 16 byte buffer, you would only get 8 bits of entropy total, no matter how many times you sampled).
| * Major change in RNG semantics: you must call reseed before callinglloyd2009-01-273-20/+4
| | | | | | | | randomize, or PRNG_Unseeded will be thrown.
| * Check in a branch with a major redesign on how entropy polling is performed.lloyd2009-01-2734-759/+674
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Combine the fast and slow polls, into a single poll() operation. Instead of being given a buffer to write output into, the EntropySource is passed an Entropy_Accumulator. This handles the RLE encoding that xor_into_buf used to do. It also contains a cached I/O buffer so entropy sources do not individually need to allocate memory for that with each poll. When data is added to the accumulator, the source specifies an estimate of the number of bits of entropy per byte, as a double. This is tracked in the accumulator. Once the estimated entropy hits a target (set by the constructor), the accumulator's member function predicate polling_goal_achieved flips to true. This signals to the PRNG that it can stop performing polling on sources, also polls that take a long time periodically check this flag and return immediately. The Win32 and BeOS entropy sources have been updated, but blindly; testing is needed. The test_es example program has been modified: now it polls twice and outputs the XOR of the two collected results. That helps show if the output is consistent across polls (not a good thing). I have noticed on the Unix entropy source, occasionally there are many 0x00 bytes in the output, which is not optimal. This also needs to be investigated. The RLE is not actually RLE anymore. It works well for non-random inputs (ASCII text, etc), but I noticed that when /dev/random output was fed into it, the output buffer would end up being RR01RR01RR01 where RR is a random byte and 00 is the byte count. The buffer sizing also needs to be examined carefully. It might be useful to choose a prime number for the size to XOR stuff into, to help ensure an even distribution of entropy across the entire buffer space. Or: feed it all into a hash function? This change should (perhaps with further modifications) help WRT the concerns Zack W raised about the RNG on the monotone-dev list.
* | A new warning in glibc triggers if memset is called with a constant sizelloyd2009-01-311-8/+8
|/ | | | | | | | | | of 0 (on the theory this is a mistake and the second and third arguments were swapped). However the GCC inliner apparently is good enough that it is triggering on code that just happens to create a zero length SecureVector or equivalent - the constants get propagated so __builtin_constant_p returns true. Add an if(n) in clear_mem so we skip calling memset if the size is zero.
* merge of '17ebb8fd6cdfe0a743092b2bf5b039a351cc23be'lloyd2009-01-214-6/+19
|\ | | | | | | and '76da4a953201fc0f0b510ea82d5a3986ec8ab44a'
| * Use printf instead of echo -n in botan-config, as according to bug reportslloyd2009-01-191-1/+1
| | | | | | | | | | | | | | | | | | echo -n does not work on (at least) Solaris 10 and MacOS X, while printf will do the right thing and is available at least as far back as 4.2 BSD (and as a policy, I'm not interested in supporting Unix distros that shipped before I was born). Patch from Markus Wanner.
| * In the Unix entropy source fast poll, clear the stat buf beforelloyd2009-01-031-0/+1
| | | | | | | | | | | | | | | | | | | | we call stat. Apparently on 32-bit Linux (or at least on Ubuntu 8.04/x86), struct stat has some padding bytes, which are not written to by the syscall, but valgrind doesn't realize that this is OK, and warns about uninitialized memory access when we read the contents of the struct. Since this data is then fed into the PRNG, the PRNG state and output becomes tainted, which makes valgrind's output rather useless.
| * Fix a memory leak in PKCS #8 load_key and encrypt_key that wouldlloyd2008-12-121-5/+9
| | | | | | | | | | | | | | | | | | | | occur because PKCS #5 v2.0 doesn't support empty passphrases (though maybe it should?). In this case pbe->set_key would throw an exception, causing the stack to be unwound without the (dynamically created) PBE object being deleted. Use auto_ptr to hold the PBE*, then .release() it when passing it to the Pipe (since Pipe takes ownership of its Filters). Noticed when looking at valgrind analysis of monotone's sync command.
| * Add a ref to a paper describing a chosen ciphertext attack on OAEPlloyd2008-12-081-0/+8
| | | | | | | | since it is relevant to the implementation.
| * DL_Group constructor taking three BigInts had the order of q and g swappedlloyd2008-12-081-1/+1
| | | | | | | | in the header.
* | Argh. Using printf in botan-config didn't work either, because somelloyd2009-01-211-3/+3
|/ | | | | | printfs would complain because it would think that the -L/lib/dir was an (unknown) option instead of the string. Instead use a plain echo in each branch of the if, slight code duplication but not a huge deal.
* Rickard Bondesson reported on botan-devel about some problems buildinglloyd2008-12-024-19/+7
| | | | | | | | | | | | | | | | | | | | on Solaris 10 with GCC 3.4.3. First, remove the definition of _XOPEN_SOURCE_EXTENDED=1 in mmap_mem.cpp and unix_cmd.cpp, because apparently on Solaris defining this macro breaks C++ compilation entirely with GCC: http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6395191 In es_egd.cpp and es_dev.cpp, include <fcntl.h> to get the declaration of open(), which is apparently where open(2) lives on Solaris - this matches the include the *BSD man pages for open(2) show, though AFAIK the BSDs all compiled fine without it (probably due to greater efforts to be source-compatible with Linux systems by *BSD developers). I have not been able to test these changes personally on Solaris but Rickard reports that with these changes everything compiles OK. Update lib version to 1.8.0-pre. ZOMG. Finally.
* Fix name of function in exception throwlloyd2008-11-301-1/+1
|
* In EMSA3_Raw::raw_data, clear message buffer (reset) before returninglloyd2008-11-281-1/+3
|
* Allow asking for EMSA3(Raw) in get_emsa (returning a new EMSA3_Raw object)lloyd2008-11-281-0/+4
|
* Add a variant of EMSA3 called EMSA3_Raw which does not hash the data orlloyd2008-11-282-46/+123
| | | | | | | add a digest identifier. This was a feature requested on the mailing list. Apparently this scheme is called CKM_RSA_PKCS in PKCS #11, and is supported by a number of libraries, including QCA.
* Add SHA-224 hash ids for EMSA2/X9.31 and EMSA3/PKCS #1 v1.5 public keylloyd2008-11-281-3/+14
| | | | signature padding schemes.
* Rickard Bondesson reported on the mailing list that he had noticedlloyd2008-11-281-11/+13
| | | | | | | | | | | | | | a discrepency between OpenSSL and Botan when generating SHA-512/EMSA3 signatures. In fact it turns out that the EMSA3 identifier for SHA-512 contained a typo and was incorrect. Unfortunately this means that SHA-512/EMSA3 signatures generated by Botan up until now will not be accepted by other implementations, and the signatures by other implementations would not be accepted by Botan. Currently I am not making any provision for backwards compatability with the old incorrect hash identifier, since I am assuming/guessing that SHA-512/EMSA3 is not a very common combination.
* Add Doxygen comment for Timer::clock. Fix @return in benchmark.h and x509_ca.hlloyd2008-11-253-2/+6
|
* If the read succeceed in EGD_EntropySource::slow_poll, the loop wouldlloyd2008-11-251-0/+2
| | | | | just continue on instead of returning the length of the buffer recv'ed from EGD.
* Disable using OpenSSL's AES - it is causing crashes for an unknown reason.lloyd2008-11-241-0/+6
| | | | | | Backtrace is deep inside EVP. Valgrind says it is writing after the end of the allocated buffer. Other ciphers (all 64-bit blocks) are fine. I do not know if the problem is 64/128 bit or some other reason.
* Fix a roundoff error in the block cipher benchmarkslloyd2008-11-241-16/+17
|
* In Pooling_Allocator::get_more_core, limit in_bytes to at most 1 MiB tolloyd2008-11-242-3/+4
| | | | avoid a potential integer overflow in the multiplication. Fixes bugid 27
* In pkg-config, don't link against a specific version number (eg -lbotan-1.8.0)lloyd2008-11-241-1/+1
| | | | | | | because that totally breaks with static libs. OTOH, not using the version number totally breaks if more than one version is installed. Kind of a tradeoff...
* Make X509_Store::CRL_Info public for IBM XLC 0.9 for Celllloyd2008-11-241-10/+14
|
* Wrap code and struct definitions internal to sha1_sse2_imp.cpp in anlloyd2008-11-241-0/+4
| | | | | anonymous namespace (in particular this should prevent Doxygen for generating documentation about the v4si union declared there).
* In es_ftw, remove check for if the return value of read() is largerlloyd2008-11-241-1/+1
| | | | | | than the value we gave it. This is pretty unlikely... also caused an annoying warning with some versions of GCC b/c it couldn't figure out the signed/unsigned comparison was safe in this case.
* Modify es_ftw to use xor_into_buflloyd2008-11-231-4/+4
|
* Reduce size of I/O buffer in HMAC_RNG from 128 to 96 bytes. Unlikely that anylloyd2008-11-231-1/+1
| | | | | entropy source will realistically be able to provide even 768 bits of entropy, so this is probably overkill even still.
* Previously es_unix would always try to get 16K, then return. Now itlloyd2008-11-231-4/+3
| | | | | | | tries to get an amount cooresponding with the size of the output buffer, specifically 128 times the output size. So, assuming we have enough working sources, each output byte will be the XOR of (at least) 128 bytes of text from the output programs. (Though RLE may reduce that somewhat)
* Add an Algorithm_Factory& argument to Engine::get_cipher to avoid alloyd2008-11-234-8/+13
| | | | dependency on libstate.h
* Remove openssl/gnump engine dep on libstate, no longer a deplloyd2008-11-232-8/+0
|
* Limit the output size of fast polls by the BeOS, Unix, and Win32 entropylloyd2008-11-233-0/+3
| | | | pollers that grab basic statistical data to 32 bytes.
* Use a simple run length encoding in xor_into_buf, so long blocks of spaces,lloyd2008-11-232-3/+22
| | | | | zero bytes, etc (relatively common, especially with the statistical pollers that use xor_into_buf) are removed. Counters wrap at 256.
* Compile fixlloyd2008-11-231-2/+2
|
* Remove now unused buf_es modulelloyd2008-11-233-134/+0
|
* Update BeOS entropy poller to also derive directly from EntropySourcelloyd2008-11-233-35/+46
| | | | | and use xor_into_buf. Completely untested, though it looks clean besides missing the BeOS headers+funcs if I try to compile on Linux.
* Fix return types in declarationlloyd2008-11-231-2/+3
|
* Convert Win32 stats polling entropy source to use xor_into_buf. Untested.lloyd2008-11-233-44/+59
|