aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint
Commit message (Collapse)AuthorAgeFilesLines
* Make MemoryRegion::set protected, change all callerslloyd2010-10-291-0/+9
|
* BigInt::get_substring really shouldn't return size_t. Revert tolloyd2010-10-182-3/+3
| | | | | | 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.
* For const BigInt::operator[], return a const reference instead of alloyd2010-10-181-1/+1
| | | | | value, so you can always safely capture the result by a const reference.
* Use size_t in all of math, remove to_u32bitlloyd2010-10-128-136/+111
|
* At some point I 'simplified' the divide code to always run thelloyd2010-09-261-1/+5
| | | | | | | | | | division algorithm unless x == y, but this could result in n - t + 1 being negative which would cause an attempt to allocate about 4 gigabytes of memory. Fix this, and also add an assertion check in the code to ensure that can't happen in any other way. Never reproduced this with 32 bit digits but it would show up if the build used 8 or 16 bit words.
* Move the core MPI functions to src/math/mp, leaving src/math/bigint justlloyd2010-09-2427-3742/+1
| | | | for the implementation of the BigInt class
* Delete obsolete asm versionslloyd2010-09-247-781/+0
|
* Minor performance tweak, avoid zeroing things we'll immediately writelloyd2010-09-241-2/+1
| | | | to. Helps more than I would have thought.
* Modify bigint_monty_redc to take an additional workspace argument.lloyd2010-09-242-27/+30
| | | | | | | Modify it to avoid a timing condition during the compare at the end; this is done by always doing the subtraction, and then copying to the output either the pre-subtraction or post-subtraction value depending on if the final borrow was set or not.
* s/carry/borrow/ in subtraction routineslloyd2010-09-241-14/+18
|
* s/j/i for loop variableslloyd2010-09-241-36/+36
|
* Cleanuplloyd2010-09-232-16/+24
|
* Make these functions mostly constant-time, and in particular notlloyd2010-09-231-29/+9
| | | | | depending on the value of the final carry out for anything control-flow related.
* Update all uses of MemoryRegion::append to use either push_back or operator+=lloyd2010-09-151-4/+3
|
* More changes to avoid vector to pointer implicit conversionslloyd2010-09-142-6/+6
|
* More vector->pointer conversion removals.lloyd2010-09-131-2/+2
| | | | | | | | | | | Add RandomNumberGenerator::random_vec, which takes an length n and returns a new SecureVector with randomized contents of that size. This nicely covers most of the cases where randomize was being called on a vector, and is a little cleaner in the code as well, instead of vec.resize(length); rng.randomize(&vec[0], vec.size()); we just write vec = rng.random_vec(length);
* Anywhere where we use MemoryRegion::begin to get access to the raw pointerlloyd2010-09-133-4/+4
| | | | | representation (rather than in an interator context), instead use &buf[0], which works for both MemoryRegion and std::vector
* Big, invasive but mostly automated change, with a further attempt atlloyd2010-09-073-5/+5
| | | | | | | | | | | | | | 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-072-5/+5
| | | | | | | | | | | | | | | | | | 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.
* Update some callers that were using Hex_Encoder or Hex_Decoder butlloyd2010-09-031-15/+17
| | | | | | | | | | | | | | | | | | really didn't need to. The ones in symkey and big_code were actually calling accessor functions to do the encoding themselves without a Pipe (should have definitely recognized that as a code smell). These versions have changed semantically with this checkin - previously they would completely ignore bad inputs, but now invalid inputs are rejected. For instance, you cannot say SymmetricKey key("Only some of this is hex, most of it isn't"); And expect to get a valid key formed by filtering out the non-hex characters and then decoding it. This is almost certainly a good thing. Also fix include in Botan.xs
* Interesting factoid, turns out that overloading std::swap is notlloyd2010-09-021-1/+5
| | | | | | | allowed by the standard, however specializing it is. Fix this for BigInt; it appears the Flexsecure guys knew this since the CurveGFp and PointGFp classes already uses the template specialization rather than an overload.
* Rename mp_amd64_msvc to mp_msvc64 since it supports both AMD64 andlloyd2010-08-253-2/+2
| | | | | IA-64 (and, hypothetically, any other 64 bit CPU Visual C++ might target in the future).
* Also allow clang with 32-bit assembly code, everything seems to worklloyd2010-08-081-0/+1
| | | | fine with latest SVN.
* Clang understands at least some GCC inline asm syntax as well as whatlloyd2010-08-081-0/+1
| | | | an .S file is, so allow it for x86-64. Tested/works with Clang SVN.
* Make round_up and round_down templates instead of fixed to use u32bitslloyd2010-06-291-5/+5
|
* Use mode(TI) operations to get access to MIPS 64-bit multiply.lloyd2010-06-171-1/+4
| | | | Required after GCC 4.4
* Doxygen for divide.hlloyd2010-06-161-1/+11
|
* More Doxygen updates. Also, don't expose divide() in numthry.hlloyd2010-06-161-26/+27
| | | | anymore, only in divide.h
* More BigInt Doxygen comment updateslloyd2010-06-161-19/+20
|
* Cleanup some BigInt doxygen commentslloyd2010-06-161-31/+44
|
* Replace "@return a blah" and "@return the blah" with just "@return blah"lloyd2010-06-161-2/+2
|
* Fix a few hundred Doxygen warningslloyd2010-06-151-4/+11
|
* Include generic mp_asmi.h for MSVClloyd2010-06-112-0/+2
| | | | | | | Don't use /EHc; it says "C" functions are nothrow, which is not true for bigint_sub2_rev. Include needed <intrin.h> for mp_asm.h
* Have to add it as explicit dep in bigintlloyd2010-06-111-1/+1
|
* Add (untested) support for VC++'s _umul128 intrinsic, which apparentlylloyd2010-06-112-0/+76
| | | | works on both x86-64 and ia64. Will allow using 64-bit limbs on Windows.
* In BigInt::bits, cache sig_words() result instead of calling twicelloyd2010-06-071-2/+4
|
* Add a special handler for the case of doing a subtraction as in:lloyd2010-03-167-391/+470
| | | | | | | | x -= y; where abs(x) < abs(y). This change alone increases ECDSA performance by 5 to 15%
* Name other params. Remove decls of functions that don't existlloyd2010-03-151-14/+36
|
* Name paramslloyd2010-03-151-16/+25
|
* If workspace is NULL, skip Karatsuba mul/sqrlloyd2010-03-151-2/+6
|
* Correct Doxygen commentlloyd2010-03-131-3/+3
|
* Name args to bigint_{mul,sqr} in headerlloyd2010-03-131-5/+5
|
* 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-164-5/+5
| | | | | | | | | | | | | 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-1630-57/+63
|
* Fix typolloyd2009-11-181-1/+1
|
* Clean up BigInt doxygen commentslloyd2009-11-181-471/+458
|
* Rename/remove some secmem member variables for better matching with STLlloyd2009-11-172-6/+6
| | | | | | | | containers (specifically vector). Rename is_empty to empty Remove has_items Rename create to resize
* Instead of having two asm_macr.h files being switched in based on modulelloyd2009-11-143-3/+3
| | | | build magic, name them asm_macr_ARCH.h. Change all including files accordingly.