summaryrefslogtreecommitdiff
path: root/tests/test3.lua
blob: 15c59e35b6a78c1ca738f312272cf77a6dd78ccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function test3()
    print "testing rsa"
    local bits = 2048
    local e = 65537
    local key = rsa:gen_key(bits, 65537)
    --for k, v in pairs(key) do print(k.."=lcrypt.bigint(lcrypt.fromhex('"..lcrypt.tohex(tostring(v)).."'))") end

    msg = lcrypt.random(bits/8 - 5)
    s = rsa:sign_oaep(msg, 'jello', key)
    if rsa:verify_oaep(s, msg, 'jello', key) then
        print "ok"
    else
        --for k, v in pairs(key) do print(k.."=lcrypt.bigint(lcrypt.fromhex('"..lcrypt.tohex(tostring(v)).."'))") end
        error "rsa failure"
    end
end