You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_rsa.lua 777B

123456789101112131415161718192021222324252627282930313233343536373839
  1. -- Test rsa signing
  2. local pubkey = 'testkey.pub'
  3. local privkey = 'testkey'
  4. local data = 'test.data'
  5. local signature = 'test.sig'
  6. -- Signing test
  7. local rsa_key = rsa_privkey.load(string.format('%s/%s', test_dir, privkey))
  8. if not rsa_key then
  9. return -1
  10. end
  11. local rsa_sig = rsa.sign_file(rsa_key, string.format('%s/%s', test_dir, data))
  12. if not rsa_sig then
  13. return -1
  14. end
  15. rsa_sig:save(string.format('%s/%s', test_dir, signature), true)
  16. -- Verifying test
  17. rsa_key = rsa_pubkey.load(string.format('%s/%s', test_dir, pubkey))
  18. if not rsa_key then
  19. return -1
  20. end
  21. rsa_sig = rsa_signature.load(string.format('%s/%s', test_dir, signature))
  22. if not rsa_sig then
  23. return -1
  24. end
  25. if not rsa.verify_file(rsa_key, rsa_sig, string.format('%s/%s', test_dir, data)) then
  26. return -1
  27. end