diff options
author | Matthew Wild <mwild1@gmail.com> | 2023-01-13 14:34:10 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2023-01-13 14:34:10 +0000 |
commit | 26dc334ae315c37477c8f54d5d04d707215e2769 (patch) | |
tree | 8c3925d1f93b60e8234f7f3083e2621d348c3e9e /spec | |
parent | 341c8417c29d7ef3d47b8b940aad97e3bd073104 (diff) | |
download | prosody-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.lua | 17 |
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); |