Commit graph

337 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
f6905c8edb Fix bugs in cryb_mpi_{add,sub}_abs() caused by assuming that the target is initally positive zero.
If its operands were identical, cryb_mpi_add_abs() would leave the target untouched.  Explicitly call mpi_zero() before returning.  While there, extend the “identical operands” shortcut to also cover equality.

Both cryb_mpi_add_abs() and cryb_mpi_sub_abs() would leave the target's negative flag untouched.  Explicitly clear it before returning.
2017-02-19 17:20:40 +01:00
Dag-Erling Smørgrav
894cc207b9 Additional tests for cryb_mpi_{add,sub}_abs().
These tests reveal that both functions assume that the target is initially positive zero if it is not identical with one of the operands, and fail in various ways if it is not, or if it is uninitialized.
2017-02-19 17:11:02 +01:00
Dag-Erling Smørgrav
ae7f1e909e Rework t_compare_mpi() to improve diagnostics. 2017-02-19 14:38:24 +01:00
Dag-Erling Smørgrav
42f68fb348 Add null pointer checks to t_compare_{ptr,mem,str,strn}(). 2017-02-19 14:38:09 +01:00
Dag-Erling Smørgrav
713cc68a0d Bump version. 2017-02-07 10:29:03 +01:00
Dag-Erling Smørgrav
9f7af230b5 Bump copyright date. 2017-02-07 10:28:49 +01:00
Dag-Erling Smørgrav
912ba9b6ff Add a test that ensures that our headers are compilable in C++. 2017-01-24 15:08:48 +01:00
Dag-Erling Smørgrav
cf28ec163b All our tests are in the test directory. 2017-01-23 11:34:42 +01:00
Dag-Erling Smørgrav
642b34411c Alphabetize. 2016-11-21 14:02:05 +01:00
Dag-Erling Smørgrav
50fbf04eb4 Add version tests for libcryb-oath and libcryb-rand. 2016-11-21 13:52:19 +01:00
Dag-Erling Smørgrav
3da29c38c6 Fix typo in libcryb-enc's dependency list. 2016-11-21 13:47:17 +01:00
Dag-Erling Smørgrav
4cad790446 Fix typo in libcryb-rand's Makefile and ensure that it is built before libcryb-oath, which uses it. 2016-11-21 13:46:49 +01:00
Dag-Erling Smørgrav
071e9e7e32 Fix accidental reintroduction of <cryb/attributes.h>, previously renamed to <cryb/defs.h>. 2016-11-14 13:11:44 +01:00
Dag-Erling Smørgrav
040f5ec69c Fix a couple of header errors. 2016-11-14 13:04:32 +01:00
Dag-Erling Smørgrav
2d507aaee4 Implement our own assert() and, more importantly, assertf(). 2016-11-14 13:00:51 +01:00
Dag-Erling Smørgrav
856571a06d Implement a soft assert for unit tests.
Unlike assert(3), which uses abort(3), this has no other side effects (before raising SIGABRT) than an fprintf() call.  The test framework will catch the SIGABRT, report that the test case failed, and proceed with the next case.
2016-11-14 13:00:16 +01:00
Dag-Erling Smørgrav
c6158a8dbf Don't confuse 2 ^ n with 1 << n in debugging output. 2016-11-14 12:59:13 +01:00
Dag-Erling Smørgrav
2ba5067496 Do not attempt to catch SIGABRT emanating from a test case.
It is reasonable to assume that a SIGABRT originates from a call to abort(3), either directly or via assert(3).  Both the C standard and POSIX give the implementation great latitude with regard to abort(3)'s behavior, and both explicitly mention that it may close all streams before raising SIGABRT.  This means that we cannot safely proceed after a call to abort(3).  One could argue that we can't safely proceed after a SIGBUS or SIGSEGV either, but in practice, the damage is usually quite limited.
2016-11-14 12:59:13 +01:00
Dag-Erling Smørgrav
183f023ab6 Alphabetize. 2016-11-14 12:59:13 +01:00
Dag-Erling Smørgrav
f612ea1b14 Add dependencies on libcryb-core to all other libraries, as already enforced in the configure script. 2016-11-14 12:59:13 +01:00
Dag-Erling Smørgrav
99691252ca Ignore editor droppings. 2016-11-14 12:59:13 +01:00
Dag-Erling Smørgrav
c4798b486c Constify t_compare_ptr(). 2016-10-03 16:55:27 +02:00
Dag-Erling Smørgrav
94c83d5407 Remove tautological condition. 2016-10-03 16:43:05 +02:00
Dag-Erling Smørgrav
86cbac767a Bump version. 2016-10-03 12:32:02 +02:00
Dag-Erling Smørgrav
b77cb1aeb4 Tidy up the headers a bit and make them C++-safe. 2016-10-03 12:31:16 +02:00
Dag-Erling Smørgrav
be954631db Finish and hook up half-written name-to-enum / enum-to-name conversion for OATH modes. 2016-10-03 12:26:30 +02:00
Dag-Erling Smørgrav
a36ae775dd Disable unused-result warnings.
It does not seem that gcc accepts casting to void as an alternative to actually checking the result.  The only recourse we have is to disable the warning.
2016-09-18 23:32:53 +02:00
Dag-Erling Smørgrav
d8e26bc5bb Solve further asprintf() issues by sweeping them under the rug.
All further instances of asprintf() or vasprintf() in our codebase are either in libcryb-test or in individual unit tests, and in all cases, the only consequence of a failed call is that the result will say "no description" instead of either a description of the test or an explanation of how it failed.  Therefore, we can simply ignore the problem and cast the call to void to satisfy gcc.
2016-09-18 22:40:48 +02:00
Dag-Erling Smørgrav
eab216c06a Check the return value from asprintf().
This is actually redundant, because we already check the pointer, which is NULL if and only if asprintf() fails and returns < 0, but the version of gcc used by Travis CI insists.  I have not been able to reproduce the issue on any other platform available to me.
2016-09-18 22:18:02 +02:00
Dag-Erling Smørgrav
7a2defcf42 Correct YAML. 2016-09-18 21:37:52 +02:00
Dag-Erling Smørgrav
ffe1d02acd Clean up and re-add gcc. 2016-09-18 21:24:39 +02:00
Dag-Erling Smørgrav
3e50b04edd Bump version. 2016-09-18 21:22:58 +02:00
Dag-Erling Smørgrav
21cd8118fa Don't call string_expand() unless we know that we need to. 2016-09-17 23:42:09 +02:00
Dag-Erling Smørgrav
d0236914f7 Add test cases for the new string functions. 2016-09-17 23:32:11 +02:00
Dag-Erling Smørgrav
dc43296a47 Centralize most of .gitignore. 2016-09-17 21:38:54 +02:00
Dag-Erling Smørgrav
8396c4193b Add string_buf(), string_compare_cs(), string_equal_cs(). 2016-09-17 21:37:18 +02:00
Dag-Erling Smørgrav
cb6743bace Add wide-character versions of strlcat(), strlcmp(), strlcpy(). 2016-09-17 21:35:42 +02:00
Dag-Erling Smørgrav
66c3bf8c32 Document all the hash and checksum functions. 2016-09-17 17:30:13 +02:00
Dag-Erling Smørgrav
29f404d52c The Adler-32 checksum is described in RFC 1950, not RFC 1905. 2016-09-17 17:22:38 +02:00
Dag-Erling Smørgrav
aafc7e1ab0 Clean up the cryb_strl*(3) man pages. 2016-09-17 16:50:37 +02:00
Dag-Erling Smørgrav
09cb4bacf6 Clean up the cryb_sha1(3) man page and add man pages for the SHA-2 functions. 2016-09-17 16:50:12 +02:00
Dag-Erling Smørgrav
9c1988fa17 Add missing third clause to new files. 2016-09-17 16:22:19 +02:00
Dag-Erling Smørgrav
a36c6ba31c Add tests for each library's cryb_foo_version() function.
This may seem stupid, but I've found bugs in the past which would have been caught by unit tests which I didn't write because they seemed stupid.
2016-09-17 16:14:00 +02:00
Dag-Erling Smørgrav
e78c0f811b Remove unneeded #includes. 2016-09-17 16:05:31 +02:00
Dag-Erling Smørgrav
d9b6740247 Implement the full range of BSD endianness conversion functions. 2016-09-15 11:18:01 +02:00
Dag-Erling Smørgrav
1ce9c07b8b Add support for __builtin_bswap16. 2016-09-15 11:09:34 +02:00
Dag-Erling Smørgrav
acb4f9f1bc Import AX_GCC_BUILTIN from the GNU Autoconf Archive. 2016-09-15 11:09:16 +02:00
Dag-Erling Smørgrav
e276f2b407 Ensure that we always have off_t and ssize_t in scope.
POSIX requires <stdio.h> and <unistd.h> to define off_t and ssize_t like <sys/types.h> does, but not all platforms respect that.  Play it safe by always including <sys/types.h>.
2016-09-15 10:15:00 +02:00
Dag-Erling Smørgrav
8d7b6439ae Fix signed / unsigned mismatch. 2016-09-05 15:46:29 +02:00
Dag-Erling Smørgrav
85f75bba42 Rename a few more files. 2016-09-04 16:34:30 +02:00