$ docker run --rm --name validator-libsodium-usage-ruby-rbnacl-util-verify32-2732 -t --mount type=bind,src=/tmp/validator-status-libsodium-usage-ruby-rbnacl-util-verify32,dst=/validator/status validator-libsodium-shared bash -lc 'set -euo pipefail /validator/tests/_shared/install_override_debs.sh exec /validator/tests/_shared/run_library_tests.sh "$@"' validator-testcase libsodium usage-ruby-rbnacl-util-verify32 -- bash -c 'PS4=$1; shift; set -x; source "$@"' validator-xtrace '__VALIDATOR_XTRACE__ ' /validator/tests/libsodium/tests/cases/usage/usage-ruby-rbnacl-util-verify32.sh no override packages found; continuing with apt originals a32 = ("\x10".b * 32) b32 = a32.dup raise "verify32 false-negative" unless RbNaCl::Util.verify32(a32, b32) # Differ in the first byte. diff_first = a32.dup diff_first.setbyte(0, diff_first.getbyte(0) ^ 0x01) raise "verify32 false-positive (first byte)" if RbNaCl::Util.verify32(a32, diff_first) # Differ in the last byte. diff_last = a32.dup diff_last.setbyte(31, diff_last.getbyte(31) ^ 0x01) raise "verify32 false-positive (last byte)" if RbNaCl::Util.verify32(a32, diff_last) # Wrong length must not return true. short = ("\x10".b * 31) ok_short = false begin ok_short = RbNaCl::Util.verify32(a32, short) rescue ArgumentError, RbNaCl::LengthError ok_short = false end raise "verify32 accepted wrong-length input" if ok_short # verify16 mirror check on the same shape. a16 = ("\xa5".b * 16) b16 = a16.dup raise "verify16 false-negative" unless RbNaCl::Util.verify16(a16, b16) diff16 = a16.dup diff16.setbyte(0, diff16.getbyte(0) ^ 0x80) raise "verify16 false-positive" if RbNaCl::Util.verify16(a16, diff16) puts "ok" ' ok