Commit graph

113 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
85f75bba42 Rename a few more files. 2016-09-04 16:34:30 +02:00
Dag-Erling Smørgrav
04d737a258 Include <unistd.h> for ssize_t, which is used by the string library. 2016-09-04 16:20:24 +02:00
Dag-Erling Smørgrav
06a757e878 Big reorganization and cleanup 2016-09-04 14:56:39 +02:00
Dag-Erling Smørgrav
401465d8ea Move main() from libcryb-test to the test program.
Instead of having libcryb-test provide main() and assume that the test program defines t_prepare() and t_cleanup(), have libcryb-test provide a t_main() function which the test program calls with pointers to its prepare and cleanup functions.
2016-03-15 14:29:44 +01:00
Dag-Erling Smørgrav
4d1703c77a Don't try to memset NULL if allocation fails.
Always emit UTRACE records, even for failed allocations.
When allocating more than was requested, fill the slop with garbage.
2016-02-19 12:23:17 +01:00
Dag-Erling Smørgrav
1d0f2a4ff3 Reserve room in the label buffer for the terminating NUL. 2016-02-19 12:20:25 +01:00
Dag-Erling Smørgrav
c044f2580b Fix buffer over-read in percent_decode().
When decoding a trigram, percent_decode() would correctly increment the input pointer by an extra two characters (three total) but would not decrement the input length by the same amount.  This would result in a buffer over-read when decoding unterminated strings.
2016-01-10 23:29:03 +01:00
Dag-Erling Smørgrav
e40f2f7d4b Improve and document percent-encoding API.
- Ensure that the output is always NUL-terminated.
- Always include the terminating NUL in the returned length.
- Allow out == NULL, allowing the caller to check how much space is required before allocating.
- Add man page.
2016-01-10 23:25:28 +01:00
Dag-Erling Smørgrav
6eaaac308f Add a t_compare_strn() function which is to t_compare_str() what strncmp() is to
strcmp().
2016-01-10 18:49:19 +01:00
Dag-Erling Smørgrav
da40b1fad8 Add man pages for a few functions. 2016-01-08 17:27:27 +01:00
Dag-Erling Smørgrav
f9c8ce7c65 Build system overhaul 2015-12-14 18:08:22 +01:00
Dag-Erling Smørgrav
278ff6d113 GC empty directory 2015-12-14 17:51:01 +01:00
Dag-Erling Smørgrav
4d7893004c Prepare for moving to Github 2015-12-14 15:55:38 +01:00
Dag-Erling Smørgrav
5584b68908 Fix t_malloc_snapshot(): stash the difference between nalloc and nfree,
not the numbers themselves.

In t_malloc_printstats(), show information about mapped allocations.

In t_malloc_leaked(), check for leaked mapped allocations.  Note that
they would show up anyway since the metadata are allocated from the
bucket allocator, but this makes them more visible.
2015-11-02 19:45:12 +00:00
Dag-Erling Smørgrav
955cbc3013 Add t_malloc_snapshot() which writes a snapshot of the allocator state to
a caller-provided buffer.  Use it to warn about leaks in each individual
test case.  Note that we can't fail a test case for leaking, because
individual test cases in a unit may modify shared state which is cleaned
up at the end of the series.
2015-11-02 19:34:03 +00:00
Dag-Erling Smørgrav
fd515ccd79 Clear up confusion between lengths and sizes.
Fix a harmless bug in string_shrink().
2015-10-13 21:42:57 +00:00
Dag-Erling Smørgrav
0a9f2c21fe When running a test, make sure it didn't leave allocation failure enabled.
Add predicates for null and non-null pointers.
Staticize some internal allocator state.
2015-10-13 21:39:47 +00:00
Dag-Erling Smørgrav
2acf532339 libtest is not just for internal use. 2015-10-12 11:41:47 +00:00
Dag-Erling Smørgrav
e6049c1d6a Add string_len() (return length of string) and string_dup_cs() (create a
string from a null-terminated string).  Add test for string_trunc().
2015-10-12 10:23:24 +00:00
Dag-Erling Smørgrav
eb61dac230 <unistd.h> required for t_compare_ssz() 2015-10-12 10:20:14 +00:00
Dag-Erling Smørgrav
b5d5f111ca Add missing Makefile 2015-10-04 07:51:08 +00:00
Dag-Erling Smørgrav
f8ebdbc14d Move the test framework into its own subdirectory 2015-10-04 07:49:48 +00:00
Dag-Erling Smørgrav
ab8f712584 Correctly register AES192 and AES256 2015-10-04 07:19:52 +00:00
Dag-Erling Smørgrav
476c9f27f7 Use our own endianness conversion macros. 2015-10-04 07:07:53 +00:00
Dag-Erling Smørgrav
03bd9ea902 Code cleanup 2015-10-03 15:33:47 +00:00
Dag-Erling Smørgrav
dd466ab29b Move some code around 2015-10-03 14:47:59 +00:00
Dag-Erling Smørgrav
023ec74be2 Implement cipher algorithm list and rename some files. 2015-10-03 14:44:59 +00:00
Dag-Erling Smørgrav
a9e733f0ca Use an enum for encrypt / decrypt + minor cleanup 2015-10-03 14:43:33 +00:00
Dag-Erling Smørgrav
dd18cd2995 Kick off libcryb-cipher with AES (from XySSL) and RC4 (my own). 2015-10-03 14:24:59 +00:00
Dag-Erling Smørgrav
94471e9923 Always clear the negative flag in mpi_zero() 2015-10-03 14:23:32 +00:00