| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
| |
it should use add with carry or conditional moves if available.
Also remove the amd64 asm; the mp_amd64 code should be used for this case.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
for the implementation of the BigInt class
|
| |
|
|
|
|
| |
to. Helps more than I would have thought.
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
depending on the value of the final carry out for anything
control-flow related.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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);
|
| |
|
|
|
|
|
| |
representation (rather than in an interator context), instead use &buf[0],
which works for both MemoryRegion and std::vector
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
IA-64 (and, hypothetically, any other 64 bit CPU Visual C++ might
target in the future).
|
|
|
|
| |
fine with latest SVN.
|
|
|
|
| |
an .S file is, so allow it for x86-64. Tested/works with Clang SVN.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Required after GCC 4.4
|
| |
|
| |
|
|
|
|
| |
anymore, only in divide.h
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
works on both x86-64 and ia64. Will allow using 64-bit limbs on Windows.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
or throw an exception, with PointGFp::on_the_curve, which returns a bool.
Update callers.
This showed several cases where check_invaraints was being called
multiple times, for instance when decoding a point with OS2ECP,
check_invaraints was called; many callers of OS2ECP would then call
check_invaraints again on the same object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use 64 bit nonces in the Miller-Rabin test, instead of 40 bits.
Rename check_prime to quick_check_prime and is_prime to check_prime
Remove some internal functions which weren't used outside the
primality test code, along with the prime products table.
For quick checking, instead of doing Miller-Rabin with fixed base 2,
do a small number of randomized tests.
Always use random bases instead of the first n primes.
|
|
|
|
|
|
|
|
|
| |
*this = scalar * *this;
And operator* was doing a needless copy.
Instead make operator* a real multiplication operation, define *= in terms
of it.
|
| |
|
|
|
|
| |
which happened to be compatible enough to work.
|