Commit graph

406 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
837d7f3a99 New alpha release. 2017-09-04 21:53:12 +02:00
Dag-Erling Smørgrav
636bd7a259 Better macros for unreachable code.
This adds a `CRYB_UNREACHABLE` macro which will cause a segfault if reached, and modifies `CRYB_NO_DEFAULT_CASE` to have essentially the same semantics.  It also removes the conditionals since the coverage macros are always defined.
2017-09-04 21:01:39 +02:00
Dag-Erling Smørgrav
06c2f1280a Add a missing break.
This was harmless as it would either fall through to an empty default statement (if CRYB_COVERAGE was defined) or out of the switch, but it's still bad style.
2017-09-04 21:00:01 +02:00
Dag-Erling Smørgrav
2e5134e217 Bump version. 2017-09-04 16:33:37 +02:00
Dag-Erling Smørgrav
e3e6a0032c Merge pull request #14 from cryb-to/cryb-core
Add strchrnul() and wcschrnul().
2017-08-23 14:24:44 +02:00
Dag-Erling Smørgrav
7744c45b8b Remove unnecessary header. 2017-08-23 13:42:00 +02:00
Dag-Erling Smørgrav
d77ba2a458 Fix unit test for strchrnul(). 2017-08-23 13:41:40 +02:00
Dag-Erling Smørgrav
5c8745138e Add strchrnul(), wcschrnul(), and tests for the former. 2017-08-23 13:41:40 +02:00
Dag-Erling Smørgrav
85f4aa359a Add CRYB_DEQUAL() to strip qualifiers from pointers. 2017-08-23 13:41:40 +02:00
Dag-Erling Smørgrav
944782f506 Remove unnecessary headers. 2017-08-23 13:19:59 +02:00
Dag-Erling Smørgrav
2f71ba6289 Improved unit tests for division. 2017-08-21 14:09:37 +02:00
Dag-Erling Smørgrav
47d81e3dcc Merge pull request #13 from cryb-to/cryb-test
Add a minimal test for the cryb-test allocator and improve leak detection.
2017-05-11 00:32:36 +02:00
Dag-Erling Smørgrav
562ffa391e Slight cleanup. 2017-05-11 00:08:45 +02:00
Dag-Erling Smørgrav
8e0f4a293e Determine the default for CRYB_LEAKTEST at run-time.
When cryb-test is used as a framework for another project, the compile-time test is useless since cryb-test itself will have been built with coverage disabled.  Besides, it is not a reliable indicator of whether leak detection will work.  Instead, check if the heap is already dirty when we first gain control.
2017-05-11 00:08:45 +02:00
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