Ulf Möller
aecb0b018f
test_mod_mul is useful, let's run it more often.
2000-12-06 04:14:30 +00:00
Ulf Möller
90e7ce363a
Use assert as in the rest of the BN library.
2000-12-05 02:00:40 +00:00
Richard Levitte
6a2347ee45
Remove the last bn_wexpand()s that made us break constness. Of
...
course, that means we need to handle the cases where the two arrays to
bn_mul_recursive() and bn_mul_part_recursive() differ in size.
I haven't yet changed the comments that describe bn_mul_recursive()
and bn_mul_part_recursive(). I want this to be tested by more people
before I consider this change final. Please test away!
2000-12-04 17:11:59 +00:00
Bodo Möller
e5164b7041
Change error message to "bignum too long"
2000-12-04 09:24:54 +00:00
Bodo Möller
addb309ad6
include <limits.h>
2000-12-03 09:55:08 +00:00
Bodo Möller
152a689cf9
Don't allow BIGNUMs to become so large that computations with dmax
...
might overflow.
2000-12-03 09:39:04 +00:00
Richard Levitte
c21c35e6a4
Add a comment to explain the purpose of bn_cmp_part_words().
2000-12-02 21:16:13 +00:00
Ulf Möller
b26f84cbbd
last commit was wrong. Now it works. :)
2000-12-02 20:51:47 +00:00
Ulf Möller
0dba0613ea
argl
2000-12-02 19:34:42 +00:00
Ulf Möller
ea1b7fe6d4
forgot to remove the loop variable
2000-12-02 16:20:04 +00:00
Ulf Möller
db88223baa
Loops like this one:
...
if (bp == NULL)
for (j=0; j<10000; j++)
BN_add(&c,&a,&b);
seem to be pretty useless, and bp never is NULL anyway.
2000-12-02 16:13:27 +00:00
Ulf Möller
111482cf2e
New function BN_bntest_rand() to detect more BN library bugs.
...
The bn_cmp_part_words bug was only caught in the BN_mod_mul() test,
not in the BN_mul() test, so apparently the choice of parameters in
some cases is bad.
2000-12-02 07:32:57 +00:00
Ulf Möller
52a1bab2d9
Fix bn_cmp_part_words() and move it to bn_lib.c.
2000-12-02 07:28:43 +00:00
Bodo Möller
5a12df5c40
functionality for BN_mod_sqrt timings
2000-12-01 09:41:21 +00:00
Bodo Möller
b5a25a430a
"make depend"
2000-12-01 08:48:42 +00:00
Bodo Möller
12cfcc128c
Fix the recently introduced test that checks if the result is 0
2000-11-30 22:58:27 +00:00
Bodo Möller
fc2e05c2d5
Fix BN_rshift, which caused lots of trouble.
2000-11-30 22:34:57 +00:00
Bodo Möller
b2993bdea1
Remove randomness from the test. These constants give me a segment
...
violation in test_kron on a 32 bit system.
2000-11-30 21:03:13 +00:00
Bodo Möller
470fa98f8a
BN_mod_exp(r,a,p,m,ctx) should not be called with r == p.
...
But even if this is avoided, there are still segmentation violations
(during one of the BN_free()s at the end of test_kron
in some cases, in other cases during BN_kronecker, or
later in BN_sqrt; choosing a different exponentiation
algorithm in bntest.c appears to influence when the SIGSEGV
takes place).
2000-11-30 20:03:24 +00:00
Bodo Möller
de6e207db6
It's "#elif", not "#elsif".
2000-11-30 19:35:51 +00:00
Bodo Möller
db5bda670f
Changes to Lenka's Montgomery implementation.
...
Submitted by: Lenka Fibikova
2000-11-30 17:35:17 +00:00
Bodo Möller
19cda70045
Corrections to the comments in BN_mod_inverse.
2000-11-30 12:53:53 +00:00
Bodo Möller
04ca16890b
BN_mod_exp problems ...
2000-11-30 11:47:04 +00:00
Bodo Möller
25439b76ad
Move reduction step from BN_mod_exp to BN_mod_exp_mont_word.
...
Fix BN_mod_exp_simple for a==0 (mod m).
Skip useless round in BN_mod_sqrt (1 is always a square, no need
to test BN_kronecker for it).
2000-11-30 09:45:26 +00:00
Bodo Möller
ac445acf69
bn_modfs.c is no longer needed, a BN_sqrt implementation
...
exists in bn_sqrt.c now
2000-11-30 00:43:41 +00:00
Bodo Möller
77ac92d00a
Fix bntest.c problem -- one of the primes got lost
2000-11-30 00:37:49 +00:00
Bodo Möller
73c2522c7c
Handle special cases correctly in exponentation functions.
...
test_bn still fails in the BN_sqrt test because
small primes appear to turn into zero for no
obvious reason, leading to "div by zero" errors.
2000-11-30 00:33:18 +00:00
Bodo Möller
cd2eebfd64
BN_sqrt
2000-11-30 00:18:19 +00:00
Bodo Möller
01e62900c7
BN_legendre is no longer needed now that OpenSSL has BN_kronecker.
2000-11-29 19:59:59 +00:00
Bodo Möller
eb1f1b0a34
Fix BN_kronecker so that it works correctly if 'a' is negative
...
(we need the two's complement of BN_lsw then).
2000-11-29 19:26:33 +00:00
Bodo Möller
14697d9d6d
BN_to_montgomery expects its inputs to be in the interval 0 .. modulus-1,
...
so we have to reduce the random numbers used in test_mont.
Before this change, test_mont failed in [debug-]solaris-sparcv9-gcc
configurations ("Montgomery multiplication test failed!" because
the multiplication result obtained with Montgomery multiplication
differed from the result obtained by BN_mod_mul).
Substituing the old version of bn_gcd.c (BN_mod_inverse) did not avoid
the problem.
The strange thing is that it I did not observe any problems
when using debug-solaris-sparcv8-gcc and solaris-sparcv9-cc,
as well as when compiling OpenSSL 0.9.6 in the solaric-sparcv9-gcc
configuration on the same system.
2000-11-29 18:08:24 +00:00
Bodo Möller
429b8162c6
add missing braces
2000-11-29 16:43:03 +00:00
Bodo Möller
03a0848922
Fix warnings in expspeed.c (but the segmentation fault remains)
...
Improve readability of bn_shift.c.
Add comment in bn_lib.c (why zero data between top and max?)
Change bntest.c output for BN_kronecker test
2000-11-29 13:40:08 +00:00
Bodo Möller
9161672950
BN_bin2bn did *not* contain an off-by-one error;
...
I'm still investigating what caused the segementation fault
(maybe "make clean; make" will cure it ...).
But BN_bin2bn should always reset ret->neg.
2000-11-29 12:53:41 +00:00
Bodo Möller
a08bcccc67
Expand expspeed.c to make BN_kronecker timings.
...
This caused a segmentation fault in calls to malloc, so I cleaned up
bn_lib.c a little so that it is easier to see what is going on.
The bug turned out to be an off-by-one error in BN_bin2bn.
2000-11-29 12:32:10 +00:00
Bodo Möller
bdec3c5323
Implement BN_kronecker test.
...
Modify "CHANGES" entry for BN_mod_inverse (it's not just avoiding BN_div
that increases performance, avoiding BN_mul also helps)
2000-11-29 11:06:50 +00:00
Bodo Möller
b6cafbd7d8
Make BN_mod_inverse a little faster
2000-11-29 09:57:13 +00:00
Bodo Möller
499e167fda
Improve BN_mod_inverse performance.
...
Get the BN_mod_exp_mont bugfix (for handling negative inputs) correct
this time.
2000-11-29 09:41:19 +00:00
Richard Levitte
0135e33511
Copy and paste error... bn_add_part_words() should of course call
...
bn_add_words(), not bn_sub_words()...
2000-11-29 09:36:48 +00:00
Bodo Möller
adcc64cd9e
Use BN_pseudo_rand instead of BN_rand
2000-11-28 11:49:12 +00:00
Bodo Möller
c94b6de017
Timings.
2000-11-28 11:47:51 +00:00
Bodo Möller
d79cab27a5
Correct a bug in BN_kronecker.
...
Sketch the test for BN_kronecker.
2000-11-28 07:53:35 +00:00
Bodo Möller
c782089611
Add test_kron function, which will contain a test for BN_kronecker.
2000-11-28 06:41:05 +00:00
Bodo Möller
265592b99a
Add bn_kron.c (BN_kronecker), which I forgot in the previous commit.
...
Also add the next file in advance so that I can't forget this one :-)
2000-11-28 06:37:43 +00:00
Bodo Möller
077ff61eef
Undo previous commit, which was an accident.
2000-11-27 21:22:45 +00:00
Bodo Möller
dcbd0d74d5
Fix BN_is_... macros.
...
Fix BN_gcd.
Analyze BN_mod_inverse.
Add BN_kronecker.
"make update".
2000-11-27 21:17:20 +00:00
Bodo Möller
1ec0a3862e
Change submitted files so that they compile (in particular,
...
use BN_CTX_start/get/end instead of accessing ctx->tos).
Change indentation to "EAY" style.
2000-11-26 19:20:56 +00:00
Bodo Möller
946cd9a540
Change submitted files so that they compile (in particular,
...
use BN_CTX_start/get/end instead of accessing ctx->tos).
Change indentation to "EAY" style.
2000-11-26 19:13:52 +00:00
Bodo Möller
5acaa49504
More BN_mod_... functions.
2000-11-26 18:31:32 +00:00
Bodo Möller
535b9b5724
Add bn_mod.c (should have happend in the previous commit ...).
...
BN_swap manual page.
2000-11-26 16:46:57 +00:00
Bodo Möller
78a0c1f18d
modular arithmetics
...
"make update"
2000-11-26 16:42:38 +00:00
Bodo Möller
6cc5e19d47
Remove CR at line ends.
2000-11-26 12:55:19 +00:00
Bodo Möller
7e0c5264e7
Elliptic curves over GF(p), new BIGNUM functions, Montgomery re-implementation.
...
These new files will not be included literally in OpenSSL, but I intend
to integrate most of their contents. Most file names will change,
and when the integration is done, the superfluous files will be deleted.
Submitted by: Lenka Fibikova <fibikova@exp-math.uni-essen.de>
2000-11-26 12:12:35 +00:00
Richard Levitte
73343ac38a
Correct a number of syntax errors.
2000-11-22 18:20:31 +00:00
Richard Levitte
c4f3542abf
Reimplement bn_div_words, bn_add_words and bn_sub_words for VAX.
...
I'm a little bit nervous about bn_div_words, as I don't know what it's
supposed to return on overflow. For now, I trust the rest of the
system to give it numbers that will not cause any overflow...
2000-11-21 23:32:38 +00:00
Richard Levitte
c799770060
Avoid getting warnings about unary - being used on unsigned integer.
2000-11-21 23:29:55 +00:00
Richard Levitte
baa257f1ed
Remove two bn_wexpand() from BN_mul(), which is a step toward getting
...
BN_mul() correctly constified, avoids two realloc()'s that aren't
really necessary and saves memory to boot. This required a small
change in bn_mul_part_recursive() and the addition of variants of
bn_cmp_words(), bn_add_words() and bn_sub_words() that can take arrays
with differing sizes.
The test results show a performance that very closely matches the
original code from before my constification. This may seem like a
very small win from a performance point of view, but if one remembers
that the variants of bn_cmp_words(), bn_add_words() and bn_sub_words()
are not at all optimized for the moment (and there's no corresponding
assembler code), and that their use may be just as non-optimal, I'm
pretty confident there are possibilities...
This code needs reviewing!
2000-11-18 22:58:26 +00:00
Richard Levitte
e06cc57118
Remove a declaration for a function that does not exist.
2000-11-18 20:52:14 +00:00
Richard Levitte
0450d28759
Make the definition of bn_add_words() match the definition.
2000-11-18 20:49:02 +00:00
Richard Levitte
227385b719
Make sure BN_DIV2W is not defining when defining it, and remove the
...
declarations of bn_add_part_words() and bn_sub_part_words() since they
do not exist.
2000-11-17 12:01:55 +00:00
Bodo Möller
28fd5c60de
Constify bn_dump1 implementation so that it matches the prototype
...
in bn.h
2000-11-17 08:36:10 +00:00
Richard Levitte
cbd48ba626
More constification of the BN library.
2000-11-16 22:43:32 +00:00
Richard Levitte
67d93e6f49
Make sure to print the BN counting (BN_COUNT) to stderr instead of
...
stdout. bc gets so confused by bean counts.
2000-11-16 22:42:39 +00:00
Richard Levitte
afb83c45e6
Oops, when I clean, I should do it thoroughly.
2000-11-16 22:41:26 +00:00
Richard Levitte
43fcc1b096
I've checked again and again. There really is no need to expand a to
...
4 times it's size when bn_sqr_recursive() won't look farther than the
original length. Thereby, constification is no longer a problem.
2000-11-16 21:35:41 +00:00
Ben Laurie
757e392d4e
Make Rijndael work! Those long flights have some good points.
2000-11-12 02:13:38 +00:00
Bodo Möller
e1a8ac495b
tmp2 is not used in BN_mod_mul_montgomery.
2000-11-09 16:39:01 +00:00
Bodo Möller
7f7b8d6871
BN_CTX-related fixes.
2000-11-08 10:05:34 +00:00
Bodo Möller
e0bf5c11ea
Handle BN_copy failure after successful BN_new.
2000-11-07 09:39:51 +00:00
Bodo Möller
58f0f52e67
handle the case when BN_new returns NULL
2000-11-07 09:35:19 +00:00
Richard Levitte
020fc820dc
Constify the BIGNUM routines a bit more. The only trouble were the
...
two functions that did expansion on in parameters (BN_mul() and
BN_sqr()). The problem was solved by making bn_dup_expand() which is
a mix of bn_expand2() and BN_dup().
2000-11-06 21:15:54 +00:00
Richard Levitte
5270e7025e
Merge the engine branch into the main trunk. All conflicts resolved.
...
At the same time, add VMS support for Rijndael.
2000-10-26 21:07:28 +00:00
Richard Levitte
6df3553255
A compiler warning removed. Thanks to the folks at HP!
2000-09-27 13:54:28 +00:00
Richard Levitte
4e20a4e688
'ranlib' doesn't always run on some systems. That's actually
...
acceptable, since all that happens if it fails is a library with
an index, which makes linking slower, but still working correctly.
2000-09-25 08:53:15 +00:00
Bodo Möller
fe03519704
Totally remove the supposedly 'faster' variant in
...
BN_mod_mul_montgomery, which calls bn_sqr_recursive
without much preparation.
bn_sqr_recursive requires the length of its argument to be
a power of 2, which is not always the case here.
There's no reason for not using BN_sqr -- if a simpler
approach to squaring made sense, then why not change
BN_sqr? (Using BN_sqr should also speed up DH where g is chosen
such that it becomes small [e.g., 2] when converted
to Montgomery representation.)
Case closed :-)
2000-09-19 23:25:00 +00:00
Bodo Möller
a45bd29535
Document BN_mod_mul_montgomery bug;
...
make disabled code slightly more correct (this does not solve
the problem though).
2000-09-19 18:02:15 +00:00
Bodo Möller
f4364e0730
Disable buggy code variant in BN_mod_mul_montgomery that was enabled
...
in 0.9.6-beta1 and 0.9.6-beta2 and caused the BN_mont_exp_mont_word()
failure (bug report "openssh 2.2.0p1 fails with openssl 0.9.6-beta1").
2000-09-19 17:21:52 +00:00
Richard Levitte
d0c2ebf414
A patch from HP for better performance.
...
Submitted by Kevin Steves <ks@hp.se> 3 months ago...
2000-09-17 20:04:42 +00:00
Ulf Möller
1d84fd64fc
Bug fix: Montgomery multiplication could produce results with the wrong
...
sign.
2000-09-14 18:37:53 +00:00
Richard Levitte
62ab514e98
'make update'
2000-09-07 08:46:51 +00:00
Bodo Möller
bbb8de0966
Avoid abort() throughout the library, except when preprocessor
...
symbols for debugging are defined.
2000-09-04 15:34:43 +00:00
Bodo Möller
5e38616380
Fix for BN_mul_word(a, 0).
2000-09-04 15:30:14 +00:00
Ben Laurie
c9b51693dc
max -> dmax in bn_check_top.
2000-08-22 21:23:09 +00:00
Dr. Stephen Henson
2d978cbd30
Changes needed for Tandem NSK, supplied by Scott Uroff (scott@xypro.com).
...
Fix warnings with BIO_dump_indent().
2000-08-04 00:01:39 +00:00
Richard Levitte
8083e1bd9e
There's a slight possibility that a is 0 in BN_sub_word(), and might
...
therefore have unallocated parts. Therefore, a check for the 0 case
is needed, resulting with the same thing as when a is negative.
2000-07-27 21:32:23 +00:00
Richard Levitte
8b4e27e26e
In the case where a < 0 and |a| < w, the result (assigned to a) from
...
BN_add_word becomes wrongly negative...
This was discovered by Darrel Hankerson <dhankers@cacr.math.uwaterloo.ca>
2000-07-27 21:17:14 +00:00
Richard Levitte
47ff5de8c2
Darrel Hankerson <dhankers@cacr.math.uwaterloo.ca> correctly discovered
...
that of the result pointer to bn_mul was the same as one of the two arguments,
That argument might have it's sign destroyed. He provided this fix.
2000-07-26 01:14:16 +00:00
Bodo Möller
904cb691f3
Return bignum '0' when BN_rand is asked for a 0 bit random number.
2000-07-02 19:42:19 +00:00
Ben Laurie
69b5d3c51f
Don't let top go below zero!
2000-07-01 16:30:27 +00:00
Bodo Möller
fc57ebc057
Actually comment out the parts of BN_MOD_MUL_WORD that I inteded to
...
comment out in the previous commit
2000-06-23 08:10:28 +00:00
Bodo Möller
e958c5afe7
In BN_mod_exp_mont_word, avoid one application of BN_MOD_MUL_WORD,
...
and for small 'a' also a couple of calls to
BN_mod_mul_montgomery(r, r, r, ...).
2000-06-23 05:51:37 +00:00
Ulf Möller
8415060e1e
use faster version
2000-06-21 21:20:46 +00:00
Bodo Möller
24bec03beb
This probably fixes a BN_rshift bug.
2000-06-13 15:07:39 +00:00
Bodo Möller
c3b1424cc0
Use BN_CTX_end when exiting early from BN_mod_exp_mont_word because
...
BN_mod_exp_atalla could be used.
2000-06-13 13:50:42 +00:00
Geoff Thorpe
8ba6d1b0cc
The atalla functionality doesn't work with the "word" version of
...
BN_mod_exp. Call the regular atalla mod_exp operation instead.
2000-06-13 13:18:51 +00:00
Geoff Thorpe
1c4f90a05d
Enable DSO support on alpha (OSF1), cc and gcc.
...
Also, "make update" has added some missing functions to libeay.num,
updated the TABLE for the alpha changes, and updated thousands of
dependancies that have changed from recent commits.
2000-06-13 12:59:38 +00:00
Bodo Möller
814ed26cfa
Comment for increased code clarity.
2000-06-09 09:11:30 +00:00
Bodo Möller
dc434bbcb0
Slightly faster DSA verification (BN_mod_exp2_mont),
...
marginally faster BN_mod_exp for 1024 bit exponents.
2000-06-08 20:26:03 +00:00
Bodo Möller
f8989a2155
Use the equivalent of a sliding window (without precomputation
...
because we're only handling words anyway) in BN_mod_exp_mont_word
making it a little faster for very small exponents,
and adjust the performance gain estimate in CHANGES according
to slightly more thorough measurements.
(15% faster than BN_mod_exp_mont for "large" base,
20% faster than BN_mod_exp_mont for small base.)
2000-06-08 09:39:28 +00:00
Bodo Möller
6dad7bd69c
Speed up DH with small generator.
2000-06-07 21:29:25 +00:00