mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-28 22:21:15 -07:00
6bece9c8c4
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
31 lines
417 B
Plaintext
31 lines
417 B
Plaintext
30313233343536373839414243444546
|
|
bin2hex(..., guard_page, 0):
|
|
bin2hex(..., "", 0):
|
|
4:cafe6942
|
|
dt1: 11
|
|
4:cafe6942
|
|
dt2: 2
|
|
dt3: 11
|
|
dt4: 11
|
|
dt5: 11
|
|
dt6: 11
|
|
+/DxMDEyMzQ1Njc4OUFCQ0RFRmFi
|
|
+/DxMDEyMzQ1Njc4OUFCQ0RFRmFiYw
|
|
-_DxMDEyMzQ1Njc4OUFCQ0RFRmFi
|
|
-_DxMDEyMzQ1Njc4OUFCQ0RFRmFiYw
|
|
|
|
YQ==
|
|
YWI=
|
|
YWJj
|
|
|
|
YQ
|
|
YWI
|
|
YWJj
|
|
[]
|
|
[BpcyBhIGpvdXJu
|
|
ZXkgaW50by Bzb3VuZA==]
|
|
[This is a journey into sound]
|
|
[This is a journ]
|
|
[
|
|
ZXkgaW50by Bzb3VuZA==]
|