Problem: Using bitwise operations on booleans doesn't make any sense,
and I didn't even catch that this was a problem until I ran `tsc` on the
codebase and saw the complaint. Static analysis rocks. In the libsodium
code these methods return `0` or `-1`, so the bitwise OR acts like a
boolean AND (`(0 | -1) === -1` like `(true && false === false)`.
Solution: Convert bitwise OR to boolean AND and then confirm that this
is the reason that the faulty truncated comparison fixed in fa39bc5 is
now captured by the tests in my pull request into sodium-test.
See-Also: https://github.com/sodium-friends/sodium-test/pull/14
Problem: The comparison was happening on the last 32 bytes instead of
the first 32.
Solution: Change the offset from 32 to 0, and set the end at 32 bytes.
Problem: The crypto_auth constants are the exact same as some other
constants because they refer to the same thing. These shouldn't be
re-declared as their own integers.
Solution: Refer to the previously declared constants instead of
redeclaring.
This builds on heaps of work by @chm-diederichs and is basically just
the cherry on top that exposes all of the underlying work that they've
done. The changes from this commit:
- Expose crypto_auth() and crypto_auth_verify().
- Fix 'crypto_auth_hmacsha512_BYTES' typo.
- Change output in crypto_auth_hmacsha512256().
- Change crypto_verify_n() to return booleans.