aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-01-13 14:34:10 +0000
committerMatthew Wild <mwild1@gmail.com>2023-01-13 14:34:10 +0000
commit26dc334ae315c37477c8f54d5d04d707215e2769 (patch)
tree8c3925d1f93b60e8234f7f3083e2621d348c3e9e /spec
parent341c8417c29d7ef3d47b8b940aad97e3bd073104 (diff)
downloadprosody-26dc334ae315c37477c8f54d5d04d707215e2769.tar.gz
prosody-26dc334ae315c37477c8f54d5d04d707215e2769.zip
util.crypto: Add support for AES-256-CTR
This is required by PASETO v3.local
Diffstat (limited to 'spec')
-rw-r--r--spec/util_crypto_spec.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/util_crypto_spec.lua b/spec/util_crypto_spec.lua
index 152efed5..77d046ac 100644
--- a/spec/util_crypto_spec.lua
+++ b/spec/util_crypto_spec.lua
@@ -164,4 +164,21 @@ describe("util.crypto", function ()
end
end);
end);
+
+ describe("AES-CTR encryption", function ()
+ it("works", function ()
+ local message = "foo\0bar hello world";
+ local key_256_bit = random.bytes(32);
+ local test_cases = {
+ { crypto.aes_256_ctr_decrypt, crypto.aes_256_ctr_decrypt, key = key_256_bit };
+ };
+ for _, params in pairs(test_cases) do
+ local iv = params.iv or random.bytes(16);
+ local encrypted = params[1](params.key, iv, message);
+ assert.not_equal(message, encrypted);
+ local decrypted = params[2](params.key, iv, encrypted);
+ assert.equal(message, decrypted);
+ end
+ end);
+ end);
end);