summaryrefslogtreecommitdiff
path: root/tests/test3.lua
blob: b3b9eb9858231d0682a5b2d701e576fc69d01d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 - 1)
    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