Commit graph

392 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
ea5b521c61 Add a simple test case for the allocator. 2017-05-11 00:08:45 +02:00
Dag-Erling Smørgrav
49c0d954ca Staticize an internal function. 2017-05-11 00:08:45 +02:00
Dag-Erling Smørgrav
5a8998d440 Replace pkg.m4 with our own pkg-config macros. 2017-05-06 02:03:14 +02:00
Dag-Erling Smørgrav
c09b83a2ad AC_HELP_STRING was renamed to AS_HELP_STRING ages ago. 2017-05-06 00:53:37 +02:00
Dag-Erling Smørgrav
fe3d11e87f New alpha release. 2017-05-02 13:26:36 +02:00
Dag-Erling Smørgrav
35e42e7479 Really fix flags for t_cxx.
48269ce tried to fix d43a6bf2 but actually just broke it in a different way.  Restore AM_CPPFLAGS so cross-tree builds work again.
2017-05-02 13:24:08 +02:00
Dag-Erling Smørgrav
8402429448 Bump version. 2017-05-02 13:15:10 +02:00
Dag-Erling Smørgrav
04783e88af Merge pull request #12 from cryb-to/cryb-core
String function improvements.
2017-05-02 13:07:01 +02:00
Dag-Erling Smørgrav
7d22bec7bc Improve man pages for strlcat() and strlcpy(). 2017-05-02 12:52:19 +02:00
Dag-Erling Smørgrav
e99877752f Pass the correct va_list to vsnprintf(). 2017-05-01 21:20:50 +02:00
Dag-Erling Smørgrav
5da37869f2 Use <unistd.h> instead of <sys/types.h> for ssize_t. 2017-05-01 21:20:50 +02:00
Dag-Erling Smørgrav
8ce323c899 Bump copyright year. 2017-05-01 21:20:50 +02:00
Dag-Erling Smørgrav
882312950d Test libc strlcat() and strlcpy().
On systems that have strlcat() and strlcpy() in libc, run the tests twice (once with our implementation and once with the system's) to verify that our tests are correct.
2017-05-01 21:20:50 +02:00
Dag-Erling Smørgrav
d80dc09f3c Improve comments for strlcat() and strlcpy(). 2017-05-01 21:20:50 +02:00
Dag-Erling Smørgrav
d4ae7a43cb Fix compiler warnings in Travis.
Travis forces _FORTIFY_SOURCE, which enables warn_unused_result annotations in glibc. Some of those annotations are of dubious value; in the case of asprintf(3) and vasprintf(3), they flag code that doesn't check the return value as unsafe even if it checks the pointer instead (which is guaranteed to be NULL in case of failure, and arguably more useful than the return value). Unfortunately, gcc intentionally ignores (void) casts, so we have no choice but to quench the warning with -Wno-unused-result. However, some of the compilers we wish to support don't recognize it, so we move it from the developer flags to the Travis environment.

While there, switch Travis from Precious to Trusty.
2017-05-01 16:52:22 +02:00
Dag-Erling Smørgrav
48269ce937 Fix include paths for some tests.
It was wrong to remove $(AM_CPPFLAGS) in d43a6bf2, because it is only used for code for which there is no explicit *_CPPFLAGS.  It is not entirely clear why this did not trip us (or Travis) up until now, although it is possible that it only breaks when $(builddir) != $(srcdir).

On the other hand, there is no reason to use $(INCLUDES).
2017-04-29 18:28:54 +02:00
Dag-Erling Smørgrav
9926ca1118 Use the English name of the University. 2017-04-29 02:31:15 +02:00
Dag-Erling Smørgrav
d43a6bf294 Remove duplicate flags. 2017-04-26 13:07:56 +02:00
Dag-Erling Smørgrav
a610b40c7b Merge pull request #10 from cryb-to/cryb-mpi
Fix equality predicates.
2017-04-22 06:03:03 +02:00
Dag-Erling Smørgrav
a09cdc6318 Fix equality predicates.
The count we passed to memcmp() in mpi_eq() and mpi_eq_abs() was actually the number of significant words in the MPI, rather than the number of bytes we wanted to compare.  Multiply by 4 to get the correct value.

To make the intent of the code more apparent, introduce a private MPI_MSW() macro which evaluates to the number of significant words (or 1-based index of the most significant word).  This also comes in handy in mpi_{add,sub,mul}_abs().

Add a couple of test cases which not only demonstrate the bug we fixed here but also demonstrate why we must compare whole words: on a big-endian machine, we would be comparing the unused upper bytes of the first and only word instead of the lower bytes which actually hold a value...
2017-04-22 05:32:25 +02:00
Dag-Erling Smørgrav
c365b9762a Merge pull request #9 from cryb-to/cryb-cipher
Fix counter increment in Salsa and ChaCha.
2017-04-22 03:33:01 +02:00
Dag-Erling Smørgrav
1036b2adf6 Merge pull request #8 from cryb-to/cryb-rolror
Add unit tests for {rol,ror}{8,16,32,64}.
2017-04-22 03:32:44 +02:00
Dag-Erling Smørgrav
b28507b0e9 Fix counter increment in Salsa and ChaCha.
In my eagerness to eliminate a branch which is taken once per 2^38 bytes of keystream, I forgot that the state words are in host order.  Thus, the counter increment code worked fine on little-endian machines, but not on big-endian ones.  Switch to a simpler (branchful) solution.
2017-04-22 03:10:10 +02:00
Dag-Erling Smørgrav
b69da31597 Add unit tests for {rol,ror}{8,16,32,64}. 2017-04-22 01:41:06 +02:00
Dag-Erling Smørgrav
6e5bac8747 Fix a typo that broke some of the tests on big-endian platforms. 2017-04-21 21:28:47 +02:00
Dag-Erling Smørgrav
bd3e353455 Add missing algorithms. 2017-04-21 18:57:51 +02:00
Dag-Erling Smørgrav
938dcaa450 Avoid any assumptions about the signedness of char. 2017-04-21 18:56:52 +02:00
Dag-Erling Smørgrav
d03b4c1958 New alpha release. 2017-04-06 21:30:15 +02:00
Dag-Erling Smørgrav
dd57dac67f Fix typo that prevented t_mpi.h from being distributed. 2017-04-06 21:29:11 +02:00
Dag-Erling Smørgrav
2597da2b29 Retroactively document 0.20170322. 2017-04-06 21:24:54 +02:00
Dag-Erling Smørgrav
24df7d433f Bump version. 2017-04-06 21:19:23 +02:00
Dag-Erling Smørgrav
ae9609ddf0 Merge pull request #7 from cryb-to/safe-rol-ror
Make rolN / rorN safe for all counts.
2017-04-06 21:14:55 +02:00
Dag-Erling Smørgrav
d2d16d26da Make rolN / rorN safe for all counts.
The current version invokes undefined behavior when the count is negative, zero, or equal to or greater than the width of the operand.  The new version masks the count to avoid these situations.  Although branchless, it is relatively inefficient if the compiler does not recognize it and translate it to a rol or ror instruction.  Empirical tests show that both clang and gcc get it right for constant counts, and recent versions of clang (but not gcc) get it right for variable counts as well.  Note that our current code base has no instances of rolN / rorN with a variable count.
2017-04-06 19:55:27 +02:00
Dag-Erling Smørgrav
c556bc0aa8 Implement MPI division. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
3c2b134fe4 Implement fast increment / decrement functions. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
111efcb949 Correct function descriptions. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
2a66f62078 Implement MPI multiplication. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
5170c0bc41 Print words in the correct order, and tack on the MSB. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
206c6ffc85 Implement ffs() / fls() and use the latter to compute the MSB. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
36739778ce Clear a vector that was supposed to be zero. 2017-04-06 19:52:23 +02:00
Dag-Erling Smørgrav
8477c4ae0b Slightly improve function descriptions. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
094635f394 Remove debugging code. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
115ea66061 Sort prototypes. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
83ca8031c5 Cosmetic fixups. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
b4eb918dad Implement GCD using Stein's binary algorithm. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
a11c52e896 Refactor the comparison predicates, check for identity first. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
47a0bf838f Add functions for comparing an MPI to an integer. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
26e434d64b Add functions that return the LSB and MSB of an MPI. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
7e05fe419a Remove unused headers. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
895d1eb539 Constify where possible. 2017-04-06 19:51:47 +02:00