Tobias Brunner
b82b5f6398
chunk: Skip all leading zero bytes in chunk_skip_zero() not just the first
2016-04-04 15:39:42 +02:00
Andreas Steffen
b12c53ce77
Use standard unsigned integer types
2016-03-24 18:52:48 +01:00
Martin Willi
9d6e952201
utils: Add a constant time chunk_equals() variant for cryptographic purposes
2015-04-14 12:02:48 +02:00
Tobias Brunner
c6e8b5dc2c
chunk: Fix Doxygen comments for chunk_internet_checksum[_inc]
2014-09-11 17:56:12 +02:00
Tobias Brunner
b557f4a7cd
chunk: Add function to calculate Internet Checksums according to RFC 1071
2014-07-22 11:10:35 +02:00
Martin Willi
460adb5d09
unit-tests: Seed chunk_hash() only once, but before creating any hashtables
...
Due to the removal of pthread_once, we manually create the seed for
chunk_hash(). With the new testable functions interface, this won't work for
the hashtable initiated using __attribute__((constructor)). Enforce seeding
before creating that hashtable.
2014-06-04 15:53:11 +02:00
Martin Willi
c46cee6f6d
chunk: Don't depend on pthread directly
2014-06-04 15:53:00 +02:00
Martin Willi
922ee2c529
windows: Add a common Windows header for platform specific wrappers
...
Include some more basic system headers in utils.h, so we can use that common
header on the different platforms.
2014-06-03 12:24:34 +02:00
Martin Willi
b9ee059ca9
chunk: Externalize error reporting in chunk_write()
...
This avoids passing that arbitrary label just for error messages, and gives
greater flexibility in handling errors.
2014-01-23 15:55:32 +01:00
Martin Willi
1c4a3459f7
chunk: Use dynamically allocated buffer in chunk_from_fd()
...
When acting on files, we can use fstat() to estimate the buffer size. On
non-file FDs, we dynamically increase an allocated buffer.
Additionally we slightly change the function signature to properly handle
zero-length files and add appropriate unit tests.
2014-01-23 15:55:32 +01:00
Martin Willi
595b6d9a82
chunk: Add functions to map file contents to a chunk
2014-01-23 15:55:32 +01:00
Tobias Brunner
20a48e4be3
chunk: Fix signedness warnings caused by chunk_from_* macros
...
There are countless other such warnings because e.g. chunk_create() is called
with char*, but at least we prevent users from causing such warnings
inadvertently when using these macros.
2013-11-27 18:28:44 +01:00
Tobias Brunner
46cded2627
chunk: Add helper function to create a chunk from data read from a file descriptor
2013-10-23 17:20:39 +02:00
Tobias Brunner
f0c54e8c15
chunk: Print chunks without separator if + modifier is used
2013-08-24 16:22:51 +02:00
Tobias Brunner
ed235dbbf2
chunk: Add predictable hash function
...
Since chunk_hash() is randomized its output is not predictable, that is,
it is only within the same process.
2013-06-28 17:00:29 +02:00
Tobias Brunner
c1be5d66cd
Use local variable in chunk_from_str()
...
This allows using strdup() or other string functions as argument
without calling them twice.
2013-06-11 11:03:12 +02:00
Tobias Brunner
d1953fe403
Replace chunk_hash() with output from chunk_mac()
...
The quality is way better, the calculation is a bit slower though.
The key is statically initialized to zero, which will be changed later
to prevent hash flooding.
2013-06-11 11:03:11 +02:00
Tobias Brunner
1255de5a20
Adding chunk_mac() which calculates a 64-bit MAC using SipHash-2-4
2013-06-11 11:03:11 +02:00
Martin Willi
47af9848a2
Add a chunk_from_str() initializer that does not include 0-terminator
2013-01-15 17:43:05 +01:00
Tobias Brunner
bca34c3717
Moved utils.[ch] to utils folder
2012-10-24 16:07:53 +02:00
Tobias Brunner
125b37af6d
Moved chunk_t to utils folder
2012-10-24 16:00:50 +02:00