| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
They would previously leak for example if the requested shift was 0.
However, that should only happen in two situations: very dumb code
explicitly requested a shift of zero (in which case we don't care if
performance is poor, your code is dumb) or a variable shift that just
happens to be zero, in which case the variable may be a secret, for
instance this can be seen in the GCD computation.
|
| | |
|
|\ \
| |/
|/| |
|
| | |
|
|/ |
|
|
|
|
| |
Saves 5% for ECDSA
|
|
|
|
| |
If not negative we don't need to check the size
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This is still leaky, but much less than before.
|
|
|
|
| |
Unfortunately Barrett reductions API allows negative inputs
|
| |
|
|
|
|
| |
This would continually reallocate to larger sizes which is bad news.
|
| |
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Originally wrote it for div-by-word but that ends up requiring a dword
type which we don't always have. And uint8_t covers the most important
cases of n = 10 and n = 58 (whenever I get around to writing base58).
We could portably support up to div-by-uint32, but I don't think we need it.
Nicely for n = 10, this is actually faster than the variable time division.
|
|/
|
|
| |
This is still leaky, but better than nothing.
|
|
|
|
|
|
|
|
| |
It is stupid and slow (~50-100x slower than variable time version) but
still useful for protecting critical algorithms.
Not currently used, waiting for OSS-Fuzz to test it for a while before
we commit to it.
|
|
|
|
|
|
| |
If reducing a negative number modulo a power of 2, an incorrect
result would be returned. This only affected the versions taking
a single word as the modulo.
|
| |
|
| |
|
|
|
|
|
| |
Addition already has to handle negative numbers so make it do
double duty for subtraction.
|
| |
|
|
|
|
| |
In particular comparisons, calc sig words, and mod_sub are const time now.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Avoid throwing base Botan::Exception type, as it is difficult to
determine what the error is in that case.
Add Exception::error_code and Exception::error_type which allows
(for error code) more information about the error and (for error type)
allows knowing the error type without requiring a sequence of catches.
See GH #1742
|
|/ |
|
|
|
|
| |
Avoid recalculating significant words which slows down reduction
|
|
|
|
|
| |
We already assumed the args are < modulus so we can avoid the
call to sig_words. This provides a noticable speedup for ECDSA overall.
|
| |
|
|
|
|
|
|
| |
The definition of return value of sig_words() means the integer is
zero iff sig_words() returns zero, so there is no reason to scan
over the data twice.
|
|
|
|
| |
And forbid 0 length substrings, which did not work correctly anyway.
|
|
|
|
| |
It is the default...
|
|
|
|
|
| |
Gets hit about 2 million times in the test suite, avoids creating
a temp BigInt (with alloc+free) or checking size of y.
|
| |
|
|
|
|
| |
They returned an empty string instead
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instigated by finding a bug where BigInt::encode with decimal output
would often have a leading '0' char. Which is papered over in the IO
operator, but was exposed by botan_mp_to_str which called BigInt::encode
directly.
Split BigInt::encode/decode into two versions, one taking the Base
argument and the other using the (previously default) binary base.
With a view of eventually deprecating the versions taking a base.
Add BigInt::to_dec_string() and BigInt::to_hex_string()
|
|
|
|
|
|
|
|
|
|
| |
This eliminates an issue identified in the paper
"Prime and Prejudice: Primality Testing Under Adversarial Conditions"
by Albrecht, Massimo, Paterson and Somorovsky
where DL_Group::verify_group with strong=false would accept a composite
q with probability 1/4096, which is exactly as the error bound is
documented, but still unfortunate.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
-x*n % n would reduce to n instead of zero.
Also some small optimizations and cleanups.
|
|
|
|
| |
Improves P-256 a bit
|
| |
|
|
|
|
| |
Avoids needless allocations for expressions like x - 1 or y <= 4.
|