Commit Graph

16 Commits

Author SHA1 Message Date
Ilya Maykov
6bece9c8c4 Relax most __attribute__ ((nonnull)) to allow 0-length inputs to be NULL.
Justifications:
- crypto_(auth|hash|generichash|onetimeauth|shorthash)*:
  it's legal to hash or HMAC a 0-length message
- crypto_box*: it's legal to encrypt a 0-length message
- crypto_sign*: it's legal to sign a 0-length message
- utils:
  comparing two 0-length byte arrays is legal
  memzero on a 0-length byte array is a no-op
  converting an empty hex string to binary results in an empty binary string
  converting an empty binary string to hex results in an empty hex string
  converting an empty b64 string to binary results in an empty binary string
  converting an empty binary string to b64 results in an empty b64 string
  sodium_add / sodium_sub on zero-length arrays is a no-op

For the functions declared in utils.h, I moved the logic into private functions that
have the __attribute__ ((nonnull)) check, but they are only called when the
corresponding length argument is non-0. I didn't do this for the hash/box/sign
functions since it would have been a lot more work and quite a large refactor.

Only memset() may have issues with a zero length.

Fix tests, use guard page instead of NULL because of Wasm
2019-04-26 15:36:58 +02:00
Frank Denis
5351efb122 Indentx 2017-02-23 11:15:29 +01:00
Frank Denis
8af252bf87 use crypto_*_keygen() in tests 2017-02-19 21:20:45 +01:00
Frank Denis
3e2bef97dc Reduce a few expensive tests 2015-12-07 09:09:04 +01:00
Frank Denis
d8b9b395a3 Mark everything as static in tests 2015-11-23 16:07:13 +01:00
Frank Denis
4921836512 Move quirks inclusion to cmptest.h, emscsripten quirks to quirks.h 2015-01-23 10:41:28 +01:00
Frank Denis
4724440492 quirks\windows\windows-quirks.h -> quirks\quirks.h 2015-01-23 10:35:20 +01:00
Frank Denis
2f7d98a73d Fix format in auth5 test 2014-09-14 12:58:50 -07:00
Frank Denis
82bc039d6c Consistent syle for the tests. 2014-09-14 11:32:55 -07:00
Frank Denis
0e559b94d5 Make the tests a little bit more readable 2014-09-14 10:34:16 -07:00
Frank Denis
4d276a81e7 Include header files commonly used by the tests to cmptest.h 2014-09-13 14:11:12 -07:00
Frank Denis
3b680e0a52 Use high-level APIs in tests 2014-09-13 13:56:41 -07:00
Frank Denis
942c371d3c Use rand() instead of random() in regression tests. 2013-04-28 01:02:52 -07:00
Frank Denis
0afc36c827 Tests: use size_t for sizes, not int.
Remove unused variables by the way.
2013-04-26 23:25:14 -07:00
Frank Denis
faa399c3df Only include sodium.h in tests.
Tests should always be passing by just including that.
2013-04-21 17:32:04 -07:00
Frank Denis
5c946f9c61 Move tests to test/default and windows to quirks/windows.
test/default contains only tests using the default primitives
for a given operation. We need to add other tests as well.
2013-02-09 04:21:32 +08:00