aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
authorIvan Stakhov <50211739+left-try@users.noreply.github.com>2024-09-18 19:10:59 +0300
committerGitHub <noreply@github.com>2024-09-18 17:10:59 +0100
commit92b679d17ca41f85009c9e33cdd5967f955b5557 (patch)
treeeeef4e285e0f00b1ec5a55338e2af33db802249b /test/lua
parent206195f2197631a3625a0c6b7d17eb55da86ce46 (diff)
downloadrspamd-92b679d17ca41f85009c9e33cdd5967f955b5557.tar.gz
rspamd-92b679d17ca41f85009c9e33cdd5967f955b5557.zip
[Feature] Add rspamadm secretbox command
* [Minor] Small fix for error messages * [Feature] Create rspamadm util to decrypt header * [Feature] Create python example to encrypt/decrypt header * [Minor] Small clean up * [Minor] Change c-rspamadm util to lua-rspamadm util * [Minor] Small clean up * [Minor] Add some debug * [Feature] Add secretbox command * [Minor] Debug * [Minor] Add additional return for encrypted string(noce + encrypted string * [Minor] Small debug * [Minor] Add a way to provide encrypted text concatenated with nonce * [Minor] Add nonce to encrypt text * [Minor] Clean up * [Minor] Clean up unused variable * [Minor] Small fix * [Minor] Fix return issue * [Minor] Add blake2b for key derivation * [Minor] Small upgrade to debug * [Minor] Small clean up * [Minor] Change return to more convenient form * [Minor] Change print to test form * [Test] Provide tests for encrypt/decrypt with rspamadm util and python script * [Minor] Change python to python3 * [Minor] Add stderr check * [Minor] Make the function return nonce+text * [Minor] Change unit tests to new return format * [Minor] Add flag to manage encodings * [Minor] Add --encoding argument to manage encodings * [Minor] Change tests for new input format * [Minor] Fix lua format * [Minor] Small fix * [Minor] Provide full support for new return format of maybe_encrypt_header * [Test] Test small fix * [Test] Small fix * [Minor] Clean up * [Minor] Small fix for name of variable * [Minor] Small clean up * [Minor] Change format of command to a mre convenient * [Minor] Change tests to be same as a format of a command * [Minor] Change description of flags * [Minor] Small fix --------- Co-authored-by: Ivan Stakhov <50211739+LeftTry@users.noreply.github.com>
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/unit/lua_util.maybe_encrypt_decrypt_header.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/lua/unit/lua_util.maybe_encrypt_decrypt_header.lua b/test/lua/unit/lua_util.maybe_encrypt_decrypt_header.lua
index 613101068..ef31f5e9b 100644
--- a/test/lua/unit/lua_util.maybe_encrypt_decrypt_header.lua
+++ b/test/lua/unit/lua_util.maybe_encrypt_decrypt_header.lua
@@ -15,7 +15,8 @@ context("Lua util - maybe encrypt/decrypt header", function()
assert_true(false, 'Failed to encrypt header')
end
- local decrypted_header = util.maybe_decrypt_header(encrypted_header, settings, settings.prefix)
+ local text = string.sub(tostring(encrypted_header), 6)
+ local decrypted_header = util.maybe_decrypt_header(text, settings, settings.prefix)
if decrypted_header == encrypted_header or decrypted_header == nil then
assert_true(false, 'Failed to decrypt header')
end
@@ -36,13 +37,15 @@ context("Lua util - maybe encrypt/decrypt header", function()
prefix_key = 'key'
}
- local encrypted_header, nonce = util.maybe_encrypt_header(header, settings, settings.prefix)
+ local encrypted_header = util.maybe_encrypt_header(header, settings, settings.prefix)
if encrypted_header == header or encrypted_header == nil then
assert_true(false, 'Failed to encrypt header')
end
- local decrypted_header = util.maybe_decrypt_header(encrypted_header, settings,
- settings.prefix, nonce)
+ local nonce = string.sub(tostring(encrypted_header), 1, 24)
+ local text = string.sub(tostring(encrypted_header), 25)
+ local decrypted_header = util.maybe_decrypt_header(text, settings, settings.prefix, nonce)
+
if decrypted_header == encrypted_header or decrypted_header == nil then
assert_true(false, 'Failed to decrypt header')
end