Commit graph

100 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
c29ef6e2c5 Centralize most of .gitignore. 2016-09-17 21:38:54 +02:00
Dag-Erling Smørgrav
1dea8111a7 Add string_buf(), string_compare_cs(), string_equal_cs(). 2016-09-17 21:37:18 +02:00
Dag-Erling Smørgrav
4241e6ce04 Add wide-character versions of strlcat(), strlcmp(), strlcpy(). 2016-09-17 21:35:42 +02:00
Dag-Erling Smørgrav
c8be5ec837 Document all the hash and checksum functions. 2016-09-17 17:30:13 +02:00
Dag-Erling Smørgrav
859ef07fa0 The Adler-32 checksum is described in RFC 1950, not RFC 1905. 2016-09-17 17:22:38 +02:00
Dag-Erling Smørgrav
0471eb2d33 Clean up the cryb_strl*(3) man pages. 2016-09-17 16:50:37 +02:00
Dag-Erling Smørgrav
615c273ae2 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
f7a2f301ef Rename a few more files. 2016-09-04 16:34:30 +02:00
Dag-Erling Smørgrav
df0b4f11d6 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
68f20a9213 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
Dag-Erling Smørgrav
bf36ff7a8c Correct context length for SHA digests 2015-10-03 13:56:07 +00:00
Dag-Erling Smørgrav
398abda6b0 Fix various bugs relating to digest algorithm registration and wrapping 2015-10-03 09:32:44 +00:00
Dag-Erling Smørgrav
8d087eeb64 Fix endian.h includes 2015-10-03 09:31:57 +00:00
Dag-Erling Smørgrav
f99073058c Whitespace cleanup to reduce diffs between SHA-512 and SHA-384. 2015-09-15 10:09:09 +00:00
Dag-Erling Smørgrav
531eeec36b Add a simple implementation of the Adler-32 checksum. 2015-08-18 13:27:06 +00:00
Dag-Erling Smørgrav
1609b4e08a Cite the Fletcher paper. 2015-08-18 10:42:41 +00:00
Dag-Erling Smørgrav
aa97da3335 Add simple implementations of Fletcher's checksum. 2015-08-17 15:21:47 +00:00
Dag-Erling Smørgrav
dc75f2edd8 Add a memset_s() implementation (cf. C11 / WG14 N1381) 2015-02-15 09:18:18 +00:00
Dag-Erling Smørgrav
342ac3fd78 Note that rand_bytes() is just a placeholder for the sake of liboath. 2015-01-08 12:24:19 +00:00
Dag-Erling Smørgrav
a33f58cad7 Fix equality predicate. 2015-01-07 19:23:38 +00:00
Dag-Erling Smørgrav
d0fb2359f1 Implement mpi_{add,sub}() in terms of mpi_{add,sub}_abs(). 2015-01-07 18:59:44 +00:00
Dag-Erling Smørgrav
7a90ca7b42 Since X may point to the same MPI as either G or L (or even both), we
can't set the carry flag based on the contents of G or L after having
modified X.  Instead, compute and stash the new carry value first.
2014-12-30 19:14:59 +00:00
Dag-Erling Smørgrav
0d483f20ab Fix msb calculation. We may have to backtrack quite a bit, for
instance when subtracting two nearly equal large numbers.
2014-12-30 16:45:18 +00:00