Commit graph

140 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
95ab26f82c Major cleanup of the MD and SHA digests.
- Use the new vector byte-order conversion functions where appropriate.
- Use memset_s() instead of memset() where appropriate.
- Use consistent names and types for function arguments.
- Reindent, rename and reorganize to conform to Cryb style and idiom.

SHA224 and SHA256 were left mostly unchanged.  MD2 and MD4 were completely rewritten as the previous versions (taken from XySSL) seem to have been copied from RSAREF.

This breaks the ABI as some context structures have grown or shrunk and some function arguments have been changed from int to size_t.
2017-03-21 14:57:19 +01:00
Dag-Erling Smørgrav
8b27222cbb Use the keystream function like we do for other stream ciphers. 2017-03-19 14:52:14 +01:00
Dag-Erling Smørgrav
7c348c4d33 Use CAVP test vectors for AES and DES. 2017-03-19 14:47:11 +01:00
Dag-Erling Smørgrav
548bf31631 Implement DES (single-key ECB only for now). 2017-03-18 17:12:16 +01:00
Dag-Erling Smørgrav
371d519169 Implement the Salsa family of stream ciphers.
Note that we only have unit tests for Salsa20.
2017-03-18 14:42:26 +01:00
Dag-Erling Smørgrav
e6ab68673b Remove incorrect and unnecessary casts. 2017-03-16 18:07:24 +01:00
Dag-Erling Smørgrav
b67f0dbf00 Implement the ChaCha family of stream ciphers. 2017-03-16 18:02:56 +01:00
Dag-Erling Smørgrav
1ca9e1928e Misc cleanup after API change. 2017-03-16 18:00:09 +01:00
Dag-Erling Smørgrav
1073dceed9 Second iteration of the cryb-cipher API.
We now have separate encryption and decryption methods, and can process an arbitrary amount of plaintext or ciphertext per call, rounded down to the block size (if applicable).  For stream ciphers, we also have a keystream method which fills the provided buffer with an arbitrary amount of keystream (once again, rounded down if applicable).
2017-03-16 15:09:34 +01:00
Dag-Erling Smørgrav
5f4d82e99e Remove incorrect CRYB_USED annotations. 2017-03-15 10:22:24 +01:00
Dag-Erling Smørgrav
3917a6dfd7 Annotate t_add_test() as printf()-like and fix the fallout. 2017-03-14 15:07:02 +01:00
Dag-Erling Smørgrav
52cf1f9d3c Rename t_verbose*() to t_printv*().
Not only is this a slightly more logical name, but it allows us to expose the verbose flag, previously private to cryb_t_main.c, as the equally logically named t_verbose.
2017-03-14 14:36:52 +01:00
Dag-Erling Smørgrav
9bf06c258c Improve tests for sloppy padding in encoded input. 2017-03-05 17:18:30 +01:00
Dag-Erling Smørgrav
f70dac496f Mechanically bump copyright dates to the date of the latest commit. 2017-02-19 20:07:43 +01:00
Dag-Erling Smørgrav
9414c8b8f1 Disable coverage analysis of the C++ test. 2017-02-19 17:33:42 +01:00
Dag-Erling Smørgrav
01ffa275ad Increase test coverage for cryb_mpi_add_abs(). 2017-02-19 17:29:07 +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
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
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
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
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
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
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
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
476374323d Vastly improve unit tests for percent-encoding API. 2016-01-10 23:28:04 +01:00
Dag-Erling Smørgrav
f9c8ce7c65 Build system overhaul 2015-12-14 18:08:22 +01:00
Dag-Erling Smørgrav
0995671d43 Don't rely on side effects between sequence points 2015-12-14 17:49:49 +01:00
Dag-Erling Smørgrav
4d7893004c Prepare for moving to Github 2015-12-14 15:55:38 +01:00
Dag-Erling Smørgrav
3e88a08c10 Clean up a bit and add more test cases, including comprehensive tests for
string_append_{cs,string}().
2015-10-13 21:44:37 +00:00
Dag-Erling Smørgrav
4fa82f7c7b Simplify existing tests:
- Set t_malloc_fatal so we don't have to check for allocation failures
  (the driver will catch the SIGABRT).
- Use string_dup_cs() instead of string_new() + string_append_cs().
2015-10-13 20:22:07 +00:00
Dag-Erling Smørgrav
454603d4f1 Add <unistd.h> to more files. FreeBSD's namespace pollution hides these
errors.
2015-10-12 11:45:26 +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
f8ebdbc14d Move the test framework into its own subdirectory 2015-10-04 07:49:48 +00:00
Dag-Erling Smørgrav
cf02f33af7 Implement the full range of test vectors from RFC 6229. 2015-10-04 07:08:36 +00:00
Dag-Erling Smørgrav
ed9403627f Add more AES test vectors 2015-10-03 15:13:17 +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
9042130830 Fix ossifrage underflow error in Adler32 unit test 2015-10-03 14:20:07 +00:00
Dag-Erling Smørgrav
17ccbb2f76 rm leftover code from a copypasto 2015-08-28 10:44:30 +00:00
Dag-Erling Smørgrav
0961e4b2e0 Rewrite unit tests for the Fletcher and Adler checksums to exercise
boundary conditions (low and high word overflow).
2015-08-28 08:38:49 +00:00