$ docker run --rm --name validator-libsodium-usage-r-cran-sodium-r11-data-encrypt-roundtrip-2732 -t --mount type=bind,src=/tmp/validator-status-libsodium-usage-r-cran-sodium-r11-data-encrypt-roundtrip,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-r-cran-sodium-r11-data-encrypt-roundtrip -- bash -c 'PS4=$1; shift; set -x; source "$@"' validator-xtrace '__VALIDATOR_XTRACE__ ' /validator/tests/libsodium/tests/cases/usage/usage-r-cran-sodium-r11-data-encrypt-roundtrip.sh no override packages found; continuing with apt originals suppressMessages(library(sodium)) key <- as.raw(rep(0x11, 32)) nonce <- as.raw(rep(0x22, 24)) msg <- charToRaw("r-cran-sodium r11 data_encrypt payload") ct <- data_encrypt(msg, key, nonce) stopifnot(is.raw(ct)) stopifnot(length(ct) == length(msg) + 16L) stopifnot(!identical(ct, msg)) pt <- data_decrypt(ct, key, nonce) stopifnot(identical(pt, msg)) ct_bad <- ct ct_bad[1] <- as.raw(bitwXor(as.integer(ct_bad[1]), 0x01L)) ok <- tryCatch({ data_decrypt(ct_bad, key, nonce) FALSE }, error = function(e) TRUE) if (!ok) { stop("forged ciphertext was accepted") } cat("ok\n") ' ok