aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint/bigint.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Shuffle things around. Add NIST X.509 test to build.lloyd2014-01-011-350/+0
|
* Cleanup BigInt::cmplloyd2012-08-011-6/+13
| | | | | | Move bigint_divcore to divide.cpp which is the only place it is used. Probably not computationally intensive enough to really be worth optimizing in asm.
* Remove all support for octal BigInt conversions.lloyd2012-08-011-6/+10
|
* Remove BigInt::get_reglloyd2012-08-011-3/+3
|
* m_ namespace BigInt memberslloyd2012-07-311-16/+16
|
* Remove BigInt::grow_reg which was only used by a few tests.lloyd2012-07-311-9/+1
|
* For block and stream ciphers, don't set the size of the key vectorslloyd2012-05-251-2/+1
| | | | | | | | | | | until we are actually setting a key. This avoids the problem of prototype objects consuming not just memory but the precious few bytes of mlock'able memory that we're given by Linux. Use clear_mem instead of a loop in BigInt::mask_bits If OS2ECP encounters an invalid format type, include what type it was in the exception message.
* Fairly huge update that replaces the old secmem types with std::vectorlloyd2012-05-181-8/+0
| | | | | | using a custom allocator. Currently our allocator just does new/delete with a memset before deletion, and the mmap and mlock allocators have been removed.
* Remove all uses of MemoryRegion::copy outside of internal uses inlloyd2012-05-181-13/+2
| | | | secmem.h. Mostly replaced by assign or copy_mem.
* Inline BigInt move operators and swaplloyd2011-06-131-28/+0
| | | | Add move constructor and assignment to PointGFp
* propagate from branch 'net.randombit.botan' (head ↵lloyd2011-06-131-1/+20
|\ | | | | | | | | | | 150bd11dd8090559ee1e83394b8283bf93a018de) to branch 'net.randombit.botan.c++0x' (head 7480693bb3f1e8a4e039a3e7ba3d9a7007f9730e)
| * propagate from branch 'net.randombit.botan' (head ↵lloyd2010-10-281-2/+2
| |\ | | | | | | | | | | | | | | | 2841fb518e20d2fe0a374e4f6b08bdbb14d5d158) to branch 'net.randombit.botan.c++0x' (head 0b9275139d6346bd3aa28d63bf8b8a03851d853d)
| * \ propagate from branch 'net.randombit.botan' (head ↵lloyd2010-10-131-1/+20
| |\ \ | | | | | | | | | | | | | | | | | | | | 2898d79f992f27a328a3e41d34b46eb1052da0de) to branch 'net.randombit.botan.c++0x' (head 6cba76268fd69a73195760c021b7f881b8a6552c)
| | * \ propagate from branch 'net.randombit.botan' (head ↵lloyd2010-07-091-1/+20
| | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | 161b5c0300b72baa746f101fda1e2b4a7c71818c) to branch 'net.randombit.botan.c++0x' (head 1fc3875bb8daf4ad0e90ba66db72642203cb9984)
| | | * \ propagate from branch 'net.randombit.botan' (head ↵lloyd2010-06-171-2/+4
| | | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 294e2082ce9231d6165276e2f2a4153a0116aca3) to branch 'net.randombit.botan.c++0x' (head 0b695fad10f924601e07b009fcd781191fafcb28)
| | | * \ \ propagate from branch 'net.randombit.botan' (head ↵lloyd2010-02-141-1/+20
| | | |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5bfc3e699003b86615c584f8ae40bd6e761f96c0) to branch 'net.randombit.botan.c++0x' (head 8c64a107b58d41f376bfffc69dfab4514d722c5c)
| | | | * \ \ propagate from branch 'net.randombit.botan' (head ↵lloyd2009-12-211-1/+20
| | | | |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 14c1d4dc8696d2705a70ec3d2403e01d2ca95265) to branch 'net.randombit.botan.c++0x' (head c567fa7310ba082a837562092728c4b4b882bf82)
| | | | | * \ \ propagate from branch 'net.randombit.botan' (head ↵lloyd2009-12-161-3/+3
| | | | | |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 744dccf92270cf16b80b50ee2759424c9866b256) to branch 'net.randombit.botan.c++0x' (head 2aa1acac1d05e8ea9991fe39015b1db9abc3b24e)
| | | | | * | | | Define move assignment and constructors in terms of std::swap (whichlloyd2009-11-191-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | boils down to BigInt::swap, which uses the memvec swap). Checking with g++ 4.5 -O3 shows it compiles down the same code as before.
| | | | | * | | | Add move assignment and constructor operators to BigInt. On macro benchmarkslloyd2009-11-191-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (timing the test suite) there doesn't seem to be much of a difference either way, but putting printfs in the implementations shows they are being used. Since they pretty much can't possibly hurt (right?) and might well help a lot in certain cases, it's worth including. Todo: adding overloads to binary operators taking move operations might be nice. Details in http://cpp-next.com/archive/2009/09/making-your-next-move/
* | | | | | | | | Add base64_decode. Seems to work OK, though incremental decoding islloyd2011-05-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | not well tested.
* | | | | | | | | Add back BigInt::to_u32bitlloyd2011-05-101-17/+38
| |_|_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix BigInt::get_substring when length is equal to 32 - an overflow would cause the mask to be equal to 0 thus producing nothing at all. Disable CVC by default, it's not ready for prime time in any sense.
* | | | | | | | BigInt::get_substring really shouldn't return size_t. Revert tolloyd2010-10-181-2/+2
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | u32bit. Maybe should be word? But that would restrict window sizes more than might be desirable (we couldn't use more than 8 bit window on the assumption that the lib might be using byte limbs). Messy.
* | | | | | | Use size_t in all of math, remove to_u32bitlloyd2010-10-121-59/+43
| | | | | | |
* | | | | | | Big, invasive but mostly automated change, with a further attempt atlloyd2010-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | harmonising MemoryRegion with std::vector: The MemoryRegion::clear() function would zeroise the buffer, but keep the memory allocated and the size unchanged. This is very different from STL's clear(), which is basically the equivalent to what is called destroy() in MemoryRegion. So to be able to replace MemoryRegion with a std::vector, we have to rename destroy() to clear() and we have to expose the current functionality of clear() in some other way, since vector doesn't support this operation. Do so by adding a global function named zeroise() which takes a MemoryRegion which is zeroed. Remove clear() to ensure all callers are updated.
* | | | | | | Realization while thinking about the recently added truncate: in a STLlloyd2010-09-071-2/+3
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | container like vector, truncate is simply resize, but what MemoryRegion called resize will zap the entire contents, and then what was resize was called grow_to. This is really problematic in terms of the goal of replacing MemoryRegion with a vector with a custom allocator. In this checkin: - Remove MemoryRegion::grow_to and MemoryRegion::truncate - Change the semantics of MemoryRegion::resize to change the size while keeping any current contents intact (up to the new size), zero initializing any new values. Unrelated, just noticed the lack while I was in there, add a version of CryptoBox::decrypt taking a std::string for the input.
* | | | | / Make round_up and round_down templates instead of fixed to use u32bitslloyd2010-06-291-5/+5
| |_|_|_|/ |/| | | |
* | | | | In BigInt::bits, cache sig_words() result instead of calling twicelloyd2010-06-071-2/+4
|/ / / /
* / / / Move the get_byte template to its own header, because many fileslloyd2010-02-021-1/+1
|/ / / | | | | | | | | | including loadstor.h actually just needed get_byte and nothing else.
* | / Un-internal loadstor.h (and its header deps, rotate.h andlloyd2009-12-211-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | bswap.h); too many external apps rely on loadstor.h existing. Define 64-bit generic bswap in terms of 32-bit bswap, since it's not much slower if 32-bit is also generic, and much faster if it's not. This may be quite helpful on 32-bit x86 in particular. Change formulation of generic 32-bit bswap. It may be faster or slower depending on the CPU, especially the latency and throuput of rotate instructions, but should be faster on an ideally superscalar processor with rotate instructions (ie, what I expect future CPUs to look more like).
* | Make many more headers internal-only.lloyd2009-12-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes for the amalgamation generator for internal headers. Remove BOTAN_DLL exporting macros from all internal-only headers; the classes/functions there don't need to be exported, and avoiding the PIC/GOT indirection can be a big win. Add missing BOTAN_DLLs where necessary, mostly gfpmath and cvc For GCC, use -fvisibility=hidden and set BOTAN_DLL to the visibility __attribute__ to export those classes/functions.
* | Full working amalgamation build, plus internal-only headers concept.lloyd2009-12-161-1/+1
|/
* Rename/remove some secmem member variables for better matching with STLlloyd2009-11-171-5/+5
| | | | | | | | containers (specifically vector). Rename is_empty to empty Remove has_items Rename create to resize
* Split up util.h into 3 fileslloyd2009-09-171-1/+1
| | | | | | | - rounding.h (round_up, round_down) - workfactor.h (dl_work_factor) - timer.h (system_time) And update all users of the previous util.h
* Thomas Moschny passed along a request from the Fedora packagers which camelloyd2009-03-301-88/+90
| | | | | | | | | | | | | | | up during the Fedora submission review, that each source file include some text about the license. One handy Perl script later and each file now has the line Distributed under the terms of the Botan license after the copyright notices. While I was in there modifying every file anyway, I also stripped out the remainder of the block comments (lots of astericks before and after the text); this is stylistic thing I picked up when I was first learning C++ but in retrospect it is not a good style as the structure makes it harder to modify comments (with the result that comments become fewer, shorter and are less likely to be updated, which are not good things).
* Rearrange BigInt directories:lloyd2008-09-301-0/+367
math/bigint - BigInt implementation math/numbertheory - Math stuff built on top of BigInt Coming soon: math/gfp (parts of pk/ecdsa) Update deps in the pk files