aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-06-13 15:47:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-06-13 15:47:32 +0100
commitb346120d244ee4761bb0b0838ae00264376b97e9 (patch)
tree26c9ecd3051b656e93153f426a9140d6bc543b92 /test
parent9deefe925c11413cb4e37bf6ef7fd13730e7af1d (diff)
downloadrspamd-b346120d244ee4761bb0b0838ae00264376b97e9.tar.gz
rspamd-b346120d244ee4761bb0b0838ae00264376b97e9.zip
Add a simple test of rsa utils in lua.
Support RSA signing in lua_rsa module. Add save function for rsa_signature. Fix test logic for lua modules.
Diffstat (limited to 'test')
-rw-r--r--test/lua/test.data19
-rw-r--r--test/lua/test_rsa.lua39
-rw-r--r--test/lua/testkey27
-rw-r--r--test/lua/testkey.pub9
4 files changed, 94 insertions, 0 deletions
diff --git a/test/lua/test.data b/test/lua/test.data
new file mode 100644
index 000000000..05ec159ee
--- /dev/null
+++ b/test/lua/test.data
@@ -0,0 +1,19 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas et adipiscing nunc, non auctor justo. Nunc consectetur nunc eget nibh pulvinar, quis consequat tortor mollis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In eu lectus in mi sodales fermentum. Pellentesque id sapien in augue sodales porta laoreet vel odio. Nam semper massa turpis, sit amet tempus nulla scelerisque non. Sed porttitor sapien est, vitae imperdiet nulla blandit vel.
+
+Proin venenatis neque urna, sit amet elementum risus accumsan in. Nam lectus augue, porttitor a accumsan porta, dignissim ut magna. Cras eleifend orci at eros porttitor posuere. Vestibulum semper accumsan purus, vel varius nisl porta sed. Duis id consectetur ligula, id vestibulum erat. Ut ultricies viverra ipsum sagittis semper. Proin cursus ante at justo pharetra placerat. Donec ultrices eros orci, sed congue libero mattis nec. Ut fringilla quis mauris non condimentum. Proin ante risus, imperdiet et elit vitae, aliquet egestas tortor.
+
+Curabitur tempus, lacus in vehicula pulvinar, odio nisl porta sem, sit amet aliquet metus tellus rhoncus nulla. Morbi condimentum enim vitae lorem imperdiet, ac feugiat nisl suscipit. Proin eleifend laoreet tortor. Sed id risus elementum, sollicitudin nibh et, luctus augue. Cras consequat nec diam in volutpat. Nam tempor nisi nec risus tempus varius quis eget mi. Nunc mauris dolor, imperdiet eget nisi ut, aliquet vulputate massa. Sed consequat diam vitae malesuada vulputate.
+
+Duis ac mollis ante, et suscipit eros. Aenean vel risus nec nisi lacinia aliquam. Phasellus auctor hendrerit facilisis. Etiam at dolor vestibulum, varius quam tempus, adipiscing dolor. Vestibulum erat dui, semper eget orci eget, iaculis laoreet ipsum. Nullam id quam at odio pharetra vestibulum. Morbi porttitor sagittis nunc sed pellentesque. Quisque semper orci ac metus molestie egestas.
+
+Donec mattis commodo magna sit amet pellentesque. In et varius urna. Suspendisse eget tellus nulla. Suspendisse potenti. Praesent a ante sit amet tellus pellentesque ornare id sit amet eros. Donec sed dignissim ligula, nec condimentum nulla. Etiam fermentum leo sit amet tincidunt fringilla. In semper lacus sit amet laoreet volutpat. Curabitur ultricies sem in dui eleifend, at aliquam sapien adipiscing. Aliquam erat volutpat. Maecenas felis eros, posuere quis placerat a, imperdiet ac lectus. Phasellus volutpat lorem sed nulla vehicula pulvinar. Pellentesque ipsum ante, posuere id eros non, vehicula commodo augue. Proin vitae tempor lectus, at commodo elit. Donec luctus commodo erat. Curabitur faucibus, arcu tincidunt vehicula rutrum, quam turpis hendrerit sapien, nec vehicula est est ut turpis.
+
+Suspendisse elementum ligula nibh. Nullam interdum tempor metus sed ultrices. Proin nec venenatis tellus. Donec non tortor at ipsum ultrices sagittis. Integer lectus augue, lacinia quis ante iaculis, iaculis volutpat odio. Fusce porttitor quis nisi vitae condimentum. Nam luctus placerat fringilla. Praesent vulputate aliquet convallis. Nunc vel sagittis sem. Vestibulum vitae ante a ipsum pulvinar faucibus pulvinar ac nulla. Morbi mattis nulla et dui egestas, vitae volutpat nisi pretium. Ut ullamcorper ac orci nec lacinia. Proin ac condimentum diam. Nulla blandit, tellus sit amet volutpat suscipit, purus eros iaculis odio, in euismod nulla nisl at urna. Aliquam erat volutpat. Pellentesque hendrerit dui eget lobortis congue.
+
+Etiam condimentum adipiscing sollicitudin. Curabitur at rhoncus sem. Donec dignissim, erat sodales malesuada fringilla, metus est vehicula nulla, nec volutpat lacus neque ut libero. Suspendisse potenti. Nam vel facilisis massa. Morbi eget quam urna. Suspendisse quis lacus eget justo placerat pulvinar sit amet a nunc. Cras porta magna nec risus feugiat, pharetra rhoncus mauris convallis. Integer pretium dolor massa, a consectetur velit laoreet sed. Nunc rutrum convallis orci, sit amet congue sapien iaculis at.
+
+Etiam leo nibh, ultricies eget dictum non, euismod nec quam. Cras luctus mauris odio, in dapibus risus rhoncus et. Integer ullamcorper elit neque. Nam vel nisl sit amet nunc gravida laoreet. Suspendisse sed neque id nulla tempus laoreet. Aliquam interdum lorem quis erat lacinia, in congue velit euismod. Morbi sit amet viverra dolor, lacinia pretium massa. Proin eu rutrum augue, sit amet condimentum enim. Pellentesque sodales, justo quis gravida lacinia, nulla dolor accumsan sapien, non hendrerit urna dui quis nibh. In posuere non elit eu hendrerit.
+
+Nulla eget justo ultrices tellus tristique cursus. Maecenas in sem et tellus pulvinar rhoncus quis ac urna. Vestibulum imperdiet nisl nibh, at suscipit mi varius eu. Vestibulum adipiscing tellus sed ipsum vehicula, vitae convallis felis ornare. Sed commodo varius adipiscing. Pellentesque eget magna diam. Etiam ac ante ligula. Proin mattis quis odio id placerat. Nam luctus, sapien rhoncus iaculis elementum, diam magna condimentum velit, eu pellentesque orci tortor eget dui. Fusce adipiscing feugiat nunc, ac iaculis lorem ultrices sit amet. Proin vel felis eget nulla consectetur congue vel sed sapien. Morbi sed aliquam neque. Interdum et malesuada fames ac ante ipsum primis in faucibus. In volutpat velit ut est sodales, eget porttitor massa faucibus.
+
+Nunc vel fermentum augue, vitae convallis metus. Pellentesque accumsan ipsum nec condimentum pharetra. Quisque id nisi egestas, ultrices mi nec, faucibus orci. Aenean aliquam, ipsum lobortis tristique facilisis, neque purus commodo est, semper semper nunc metus quis ligula. Praesent faucibus est vel quam eleifend, a accumsan diam tempus. Integer pellentesque rhoncus vehicula. Donec sit amet mollis sem. Vivamus et ipsum at justo iaculis imperdiet a vel felis. Morbi felis augue, condimentum sit amet ligula et, mollis adipiscing purus. In vulputate nibh nec mattis fermentum. In ornare felis in aliquam cursus. Suspendisse magna mi, vehicula ut egestas eu, egestas non eros. Nunc non sem massa. Pellentesque mattis, lacus sit amet luctus scelerisque, lacus est ultricies erat, ut tincidunt nisl orci id leo. Maecenas ut massa volutpat, aliquet odio placerat, luctus massa. Ut sed odio tincidunt, luctus arcu in, dictum leo.
diff --git a/test/lua/test_rsa.lua b/test/lua/test_rsa.lua
new file mode 100644
index 000000000..83a6a9e45
--- /dev/null
+++ b/test/lua/test_rsa.lua
@@ -0,0 +1,39 @@
+-- Test rsa signing
+
+local pubkey = 'testkey.pub'
+local privkey = 'testkey'
+local data = 'test.data'
+local signature = 'test.sig'
+
+-- Signing test
+local rsa_key = rsa_privkey.load(string.format('%s/%s', test_dir, privkey))
+
+if not rsa_key then
+ return -1
+end
+
+local rsa_sig = rsa.sign_file(rsa_key, string.format('%s/%s', test_dir, data))
+
+if not rsa_sig then
+ return -1
+end
+
+rsa_sig:save(string.format('%s/%s', test_dir, signature), true)
+
+-- Verifying test
+rsa_key = rsa_pubkey.load(string.format('%s/%s', test_dir, pubkey))
+
+if not rsa_key then
+ return -1
+end
+
+rsa_sig = rsa_signature.load(string.format('%s/%s', test_dir, signature))
+
+if not rsa_sig then
+ return -1
+end
+
+if not rsa.verify_file(rsa_key, rsa_sig, string.format('%s/%s', test_dir, data)) then
+ return -1
+end
+
diff --git a/test/lua/testkey b/test/lua/testkey
new file mode 100644
index 000000000..4a0325b42
--- /dev/null
+++ b/test/lua/testkey
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowI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kY9D5+UUYYRWYK3Ku9Zk
+ID6kXEwIwTcrb8B2uBaDxQgwH9qq/YT7M56gmfhAe5eykqW5TjRFNxWKTXJE+TjN
+5HBg5i9rGjz7fk0c7Qu7FRyE+EyhiR5hTK5Ip9yvuoZIQePorhL5PAS/b/zhLCQ+
+VbEQ4tJC1cJbnWCsaW/UmQKBgQCH8Xe0qMBAJKBg0BseAcylxuRfi7HuicnqxVDH
+jtY7okLHxTOd7B7FgOctheIfWstPr87B4bzL9HCAbL9bIGXLjlMkxQfeX8JISInE
+6qEaanKrNBgf4Dxr8fvOKrP5ZxeyzgJ2sM1MdNFpxQr9IutVmyEWwHt+Ec9PY6bQ
+Xhh1dwKBgBAGqEz10PnWmJWYylP1wgxNSltS3kGQWP/vqsL7xo4NV0TOYbsu8Iun
+MvLD3C5sSqTD7ycOiweglIFLaZCWtKEp+01WiEsceQ6G9mZ131Zb1uzdp+fmykyi
+IL7R1kM99vpYh0JMj9l8AyNeHG2MKxriOdcDiAOolVxCjYBlnsD0
+-----END RSA PRIVATE KEY-----
diff --git a/test/lua/testkey.pub b/test/lua/testkey.pub
new file mode 100644
index 000000000..6407aa046
--- /dev/null
+++ b/test/lua/testkey.pub
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxUYMGsqMbNZl4vw65Afi
+vuC5rXDzbvP8zqj96L8t9M/2bV7Df1k4Pit+TKBczhs3HolQStq46AmrhoyNbLJx
+yaA8g+8ETXOhHzQUR74ud/xQaPqx02E02kbR3LnQTp/wdrJARMAB8CsPm8X2wrpF
+CRus+DMdDGWQXV3RFc0FbeYFMehn46k3+5dB96Y3Wh4cK3/aS2zpR2ddynN6vBaW
+sSTNfadGbUtIodZgl50ecdyVeExmL/H9HWhcafcNJVUeI0jd79Px90puB1auK6fu
+MVinDv2zJL3HIbz3qUTRAlVHdmphf/UoRq0hkZmnbTR0v9eC0FDwJV/XKspicJbv
+1QIDAQAB
+-----END PUBLIC KEY-----